blob: 3cb120ca378722436cc06d52577275cab63eed29 [file] [log] [blame]
jaegonkim7e876632017-01-25 06:01:49 +09001/*
2 * Copyright 2014-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 * A constraint for intent.hashCode() based path selection.
25 */
26public class HashedPathSelectionConstraint implements Constraint {
27
28 @Override
29 public double cost(Link link, ResourceContext context) {
30 return 1;
31 }
32
33 @Override
34 public boolean validate(Path path, ResourceContext context) {
35 return true;
36 }
37
38 @Override
39 public int hashCode() {
40 return 1;
41 }
42
43 @Override
44 public boolean equals(Object obj) {
45 if (this == obj) {
46 return true;
47 }
48
49 return (obj != null && getClass().equals(obj.getClass()));
50 }
51
52 @Override
53 public String toString() {
54 return "HashedPathSelectionConstraint";
55 }
56}