blob: bc2c107d95e48c53ea9fd84f4ee69579d30e3970 [file] [log] [blame]
Yuta HIGUCHIe37560f2017-02-02 19:53:26 -08001/*
2 * Copyright 2016-present 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.onosproject.net.intent.constraint;
17
18import org.onosproject.net.Link;
19import org.onosproject.net.Path;
20import org.onosproject.net.intent.Constraint;
21import org.onosproject.net.intent.ResourceContext;
22
23/**
24 * Abstract Constraint for constraints not intended to influence
25 * individual link cost or path validity.
26 */
27public 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}