blob: 3b7b47e2c3eb975c0d4d9cd56ab2eddb836a8765 [file] [log] [blame]
Mahesh Poojary Sf920ec02016-05-17 23:16:09 +05301/*
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.pce.pcestore;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.List;
21import java.util.Objects;
22
23import org.onosproject.net.DeviceId;
24import org.onosproject.net.intent.Constraint;
25import org.onosproject.pce.pceservice.LspType;
26
27/**
28 * Input path information to compute CSPF path.
29 * This path information will be stored in pce store and will be used later to recalculate the path.
30 */
31public final class PcePathInfo {
32
33 private DeviceId src; // source path
34
35 private DeviceId dst; // destination path
36
37 private String name; // tunnel name
38
39 private List<Constraint> constraints; // list of constraints (cost, bandwidth, etc.)
40
41 private LspType lspType; // lsp type
42
43 /**
44 * Initialization of member variables.
45 *
46 * @param src source device id
47 * @param dst destination device id
48 * @param name tunnel name
49 * @param constraints list of constraints
50 * @param lspType lsp type
51 */
52 public PcePathInfo(DeviceId src,
53 DeviceId dst,
54 String name,
55 List<Constraint> constraints,
56 LspType lspType) {
57 this.src = src;
58 this.dst = dst;
59 this.name = name;
60 this.constraints = constraints;
61 this.lspType = lspType;
62 }
63
64 /**
65 * Initialization for serialization.
66 */
67 public PcePathInfo() {
68 this.src = null;
69 this.dst = null;
70 this.name = null;
71 this.constraints = null;
72 this.lspType = null;
73 }
74
75 /**
76 * Returns source device id.
77 *
78 * @return source device id
79 */
80 public DeviceId src() {
81 return src;
82 }
83
84 /**
85 * Sets source device id.
86 *
87 * @param id source device id
88 */
89 public void src(DeviceId id) {
90 this.src = id;
91 }
92
93 /**
94 * Returns destination device id.
95 *
96 * @return destination device id
97 */
98 public DeviceId dst() {
99 return dst;
100 }
101
102 /**
103 * Sets destination device id.
104 *
105 * @param id destination device id
106 */
107 public void dst(DeviceId id) {
108 this.dst = id;
109 }
110
111
112 /**
113 * Returns tunnel name.
114 *
115 * @return name
116 */
117 public String name() {
118 return name;
119 }
120
121 /**
122 * Sets tunnel name.
123 *
124 * @param name tunnel name
125 */
126 public void name(String name) {
127 this.name = name;
128 }
129
130 /**
131 * Returns list of constraints including cost, bandwidth, etc.
132 *
133 * @return list of constraints
134 */
135 public List<Constraint> constraints() {
136 return constraints;
137 }
138
139 /**
140 * Sets list of constraints.
141 * @param constraints list of constraints
142 */
143 public void constraints(List<Constraint> constraints) {
144 this.constraints = constraints;
145 }
146
147 /**
148 * Returns lsp type.
149 *
150 * @return lsp type
151 */
152 public LspType lspType() {
153 return lspType;
154 }
155
156 /**
157 * Sets lsp type.
158 *
159 * @param lspType lsp type
160 */
161 public void lspType(LspType lspType) {
162 this.lspType = lspType;
163 }
164
165 @Override
166 public int hashCode() {
167 return Objects.hash(src, dst, name, constraints, lspType);
168 }
169
170 @Override
171 public boolean equals(Object obj) {
172 if (this == obj) {
173 return true;
174 }
175 if (obj instanceof PcePathInfo) {
176 final PcePathInfo other = (PcePathInfo) obj;
177 return Objects.equals(this.src, other.src) &&
178 Objects.equals(this.dst, other.dst) &&
179 Objects.equals(this.name, other.name) &&
180 Objects.equals(this.constraints, other.constraints) &&
181 Objects.equals(this.lspType, other.lspType);
182 }
183 return false;
184 }
185
186 @Override
187 public String toString() {
188 return MoreObjects.toStringHelper(getClass())
189 .omitNullValues()
190 .add("Source", src.toString())
191 .add("Destination", dst.toString())
192 .add("Name", name.toString())
193 .add("Constraints", constraints.toString())
194 .add("LspType", lspType.toString())
195 .toString();
196 }
197}