blob: 43bfd7572bfef4d4071e1eba83b3646c104c1a18 [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
Henry Yu4b4a7eb2016-11-09 20:07:53 -05003 *
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.tetopology.management.api.link;
17
18import java.util.Collections;
19import java.util.List;
20import java.util.Objects;
21
22import com.google.common.base.MoreObjects;
23import com.google.common.collect.Lists;
24
25/**
26 * Represents the common definition of an underlay path that supports a TE link.
27 */
28public class UnderlayAbstractPath {
29 private final List<PathElement> pathElements;
30 private final Boolean loose;
31
32 /**
33 * Creates a underlay abstract path.
34 *
35 * @param pathElements the list of elements along the path
36 * @param loose loose if true, or otherwise strict
37 */
38 public UnderlayAbstractPath(List<PathElement> pathElements, Boolean loose) {
39 this.pathElements = Lists.newArrayList(pathElements);
40 this.loose = loose;
41 }
42
43 /**
44 * Returns the loose flag, indicating whether the path is loose or strict.
45 *
46 * @return true if the path is loose, false if it is strict.
47 */
48 public Boolean loose() {
49 return loose;
50 }
51
52 /**
53 * Returns the list of path elements.
54 *
55 * @return list of path elements
56 */
57 public List<PathElement> pathElements() {
58 return Collections.unmodifiableList(pathElements);
59 }
60
61 @Override
62 public int hashCode() {
63 return Objects.hash(pathElements, loose);
64 }
65
66 @Override
67 public boolean equals(Object obj) {
68 if (this == obj) {
69 return true;
70 }
71 if (obj instanceof UnderlayAbstractPath) {
72 UnderlayAbstractPath other = (UnderlayAbstractPath) obj;
73 return Objects.equals(pathElements, other.pathElements) &&
74 Objects.equals(loose, other.loose);
75 }
76 return false;
77 }
78
79 @Override
80 public String toString() {
81 return MoreObjects.toStringHelper(getClass())
82 .add("pathElements", pathElements)
83 .add("loose", loose)
84 .toString();
85 }
86}