blob: 9d0886bd73904d25f4d2367042299078168437db [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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.tetopology.management.api.link;
17
18import java.util.List;
19
20import org.onosproject.tetopology.management.api.node.TerminationPointKey;
21
22import com.google.common.base.MoreObjects;
23import com.google.common.base.Objects;
24
25/**
26 * Represents the TE link underlay path data.
27 */
28public class UnderlayPath {
29 private int protectionType;
30 private UnderlayPrimaryPath primaryPath;
31 private List<UnderlayBackupPath> backupPaths;
32 private TerminationPointKey trailSrc;
33 private TerminationPointKey trailDes;
34
35 /**
36 * Creates an instance of Underlay.
37 */
38 public UnderlayPath() {
39 }
40
41 /**
42 * Sets the protection type.
43 *
44 * @param protectionType the protectionType to set
45 */
46 public void setProtectionType(int protectionType) {
47 this.protectionType = protectionType;
48 }
49
50 /**
51 * Sets the primary path.
52 *
53 * @param primaryPath the primaryPath to set
54 */
55 public void setPrimaryPath(UnderlayPrimaryPath primaryPath) {
56 this.primaryPath = primaryPath;
57 }
58
59 /**
60 * Sets the link of backup paths.
61 *
62 * @param backupPaths the backupPath to set
63 */
64 public void setBackupPath(List<UnderlayBackupPath> backupPaths) {
65 this.backupPaths = backupPaths;
66 }
67
68 /**
69 * Sets the trail source.
70 *
71 * @param trailSrc the trailSrc to set
72 */
73 public void setTrailSrc(TerminationPointKey trailSrc) {
74 this.trailSrc = trailSrc;
75 }
76
77 /**
78 * Sets the trail destination.
79 *
80 * @param trailDes the trailDes to set
81 */
82 public void setTrailDes(TerminationPointKey trailDes) {
83 this.trailDes = trailDes;
84 }
85
86 /**
87 * Returns the protection type.
88 *
89 * @return path protection type
90 */
91 public int protectionType() {
92 return protectionType;
93 }
94
95 /**
96 * Returns the primary path.
97 *
98 * @return underlay primary path
99 */
100 public UnderlayPrimaryPath primaryPath() {
101 return primaryPath;
102 }
103
104 /**
105 * Returns the backup paths.
106 *
107 * @return list of underlay backup paths
108 */
109 public List<UnderlayBackupPath> backupPaths() {
110 return backupPaths;
111 }
112
113 /**
114 * Returns the trail source.
115 *
116 * @return trail source
117 */
118 public TerminationPointKey trailSrc() {
119 return trailSrc;
120 }
121
122 /**
123 * Returns the trail destination.
124 *
125 * @return trail destination
126 */
127 public TerminationPointKey trailDes() {
128 return trailDes;
129 }
130
131 @Override
132 public int hashCode() {
133 return Objects.hashCode(protectionType, primaryPath,
134 backupPaths, trailSrc, trailDes);
135 }
136
137 @Override
138 public boolean equals(Object object) {
139 if (this == object) {
140 return true;
141 }
142 if (object instanceof UnderlayPath) {
143 UnderlayPath that = (UnderlayPath) object;
144 return Objects.equal(this.protectionType, that.protectionType) &&
145 Objects.equal(this.primaryPath, that.primaryPath) &&
146 Objects.equal(this.backupPaths, that.backupPaths) &&
147 Objects.equal(this.trailSrc, that.trailSrc) &&
148 Objects.equal(this.trailDes, that.trailDes);
149 }
150 return false;
151 }
152
153 @Override
154 public String toString() {
155 return MoreObjects.toStringHelper(this)
156 .add("protectionType", protectionType)
157 .add("primaryPath", primaryPath)
158 .add("backupPaths", backupPaths)
159 .add("trailSrc", trailSrc)
160 .add("trailDes", trailDes)
161 .toString();
162 }
163
164}