blob: c42163b242bf5f71f2ecbc89b077ce2058d9c0ac [file] [log] [blame]
Thomas Vachuska5dd52f72014-11-28 19:27:45 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska5dd52f72014-11-28 19:27:45 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent.constraint;
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080017
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.net.Link;
20import org.onosproject.net.Path;
21import org.onosproject.net.intent.Constraint;
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080022import org.onosproject.net.intent.ResourceContext;
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080023
24import java.util.Objects;
25
26import static com.google.common.base.MoreObjects.toStringHelper;
27
28/**
29 * Constraint that serves as a request for asymmetric bi-directional path.
30 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040031@Beta
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080032public class AsymmetricPathConstraint implements Constraint {
33
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080034 // doesn't use LinkResourceService
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080035 @Override
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080036 public double cost(Link link, ResourceContext context) {
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080037 return 1;
38 }
39
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080040 // doesn't use LinkResourceService
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080041 @Override
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080042 public boolean validate(Path path, ResourceContext context) {
Thomas Vachuska5dd52f72014-11-28 19:27:45 -080043 return true;
44 }
45
46 @Override
47 public int hashCode() {
48 return Objects.hashCode(true);
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj) {
54 return true;
55 }
56 if (obj == null || getClass() != obj.getClass()) {
57 return false;
58 }
59 return true;
60 }
61
62 @Override
63 public String toString() {
64 return toStringHelper(this).toString();
65 }
66}