Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 1 | /* |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent.constraint; |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 17 | |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.net.Link; |
| 20 | import org.onosproject.net.Path; |
| 21 | import org.onosproject.net.intent.Constraint; |
Sho SHIMIZU | b1681bd | 2016-02-22 12:47:50 -0800 | [diff] [blame] | 22 | import org.onosproject.net.intent.ResourceContext; |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 23 | |
| 24 | import java.util.Objects; |
| 25 | |
| 26 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 27 | |
| 28 | /** |
| 29 | * Constraint that serves as a request for asymmetric bi-directional path. |
| 30 | */ |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 31 | @Beta |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 32 | public class AsymmetricPathConstraint implements Constraint { |
| 33 | |
Sho SHIMIZU | b1681bd | 2016-02-22 12:47:50 -0800 | [diff] [blame] | 34 | // doesn't use LinkResourceService |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 35 | @Override |
Sho SHIMIZU | b1681bd | 2016-02-22 12:47:50 -0800 | [diff] [blame] | 36 | public double cost(Link link, ResourceContext context) { |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 37 | return 1; |
| 38 | } |
| 39 | |
Sho SHIMIZU | b1681bd | 2016-02-22 12:47:50 -0800 | [diff] [blame] | 40 | // doesn't use LinkResourceService |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 41 | @Override |
Sho SHIMIZU | b1681bd | 2016-02-22 12:47:50 -0800 | [diff] [blame] | 42 | public boolean validate(Path path, ResourceContext context) { |
Thomas Vachuska | 5dd52f7 | 2014-11-28 19:27:45 -0800 | [diff] [blame] | 43 | 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 | } |