Yuta HIGUCHI | e37560f | 2017-02-02 19:53:26 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Yuta HIGUCHI | e37560f | 2017-02-02 19:53:26 -0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net.intent.constraint; |
| 17 | |
| 18 | import org.onosproject.net.Link; |
| 19 | import org.onosproject.net.Path; |
| 20 | import org.onosproject.net.intent.Constraint; |
| 21 | import org.onosproject.net.intent.ResourceContext; |
| 22 | |
| 23 | /** |
| 24 | * Abstract Constraint for constraints not intended to influence |
| 25 | * individual link cost or path validity. |
| 26 | */ |
| 27 | public abstract class MarkerConstraint implements Constraint { |
| 28 | |
| 29 | @Override |
| 30 | public final double cost(Link link, ResourceContext context) { |
| 31 | // random value, should never be used. |
| 32 | return 1.0; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public final boolean validate(Path path, ResourceContext context) { |
| 37 | return true; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public int hashCode() { |
| 42 | return this.getClass().hashCode(); |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public boolean equals(Object obj) { |
| 47 | if (this == obj) { |
| 48 | return true; |
| 49 | } |
| 50 | return obj != null && this.getClass() == obj.getClass(); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public String toString() { |
| 55 | return getClass().getSimpleName().replace("Constraint", ""); |
| 56 | } |
| 57 | } |