blob: cfeb8f7feff333293b0a955732657496c7de9efe [file] [log] [blame]
Thomas Vachuska5dd52f72014-11-28 19:27:45 -08001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
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 */
16package org.onlab.onos.net.intent.constraint;
17
18import org.onlab.onos.net.Link;
19import org.onlab.onos.net.Path;
20import org.onlab.onos.net.intent.Constraint;
21import org.onlab.onos.net.resource.LinkResourceService;
22
23import java.util.Objects;
24
25import static com.google.common.base.MoreObjects.toStringHelper;
26
27/**
28 * Constraint that serves as a request for asymmetric bi-directional path.
29 */
30public class AsymmetricPathConstraint implements Constraint {
31
32 @Override
33 public double cost(Link link, LinkResourceService resourceService) {
34 return 1;
35 }
36
37 @Override
38 public boolean validate(Path path, LinkResourceService resourceService) {
39 return true;
40 }
41
42 @Override
43 public int hashCode() {
44 return Objects.hashCode(true);
45 }
46
47 @Override
48 public boolean equals(Object obj) {
49 if (this == obj) {
50 return true;
51 }
52 if (obj == null || getClass() != obj.getClass()) {
53 return false;
54 }
55 return true;
56 }
57
58 @Override
59 public String toString() {
60 return toStringHelper(this).toString();
61 }
62}