blob: e0f8614caca0f7c39aef5f2954ecf178637b84bc [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 */
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;
Brian O'Connor6de2e202015-05-21 14:30:41 -070022import org.onosproject.net.resource.link.LinkResourceService;
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
34 @Override
35 public double cost(Link link, LinkResourceService resourceService) {
36 return 1;
37 }
38
39 @Override
40 public boolean validate(Path path, LinkResourceService resourceService) {
41 return true;
42 }
43
44 @Override
45 public int hashCode() {
46 return Objects.hashCode(true);
47 }
48
49 @Override
50 public boolean equals(Object obj) {
51 if (this == obj) {
52 return true;
53 }
54 if (obj == null || getClass() != obj.getClass()) {
55 return false;
56 }
57 return true;
58 }
59
60 @Override
61 public String toString() {
62 return toStringHelper(this).toString();
63 }
64}