blob: f47f0d99c5d7211dd00799f630107e93363ed617 [file] [log] [blame]
Yixiao Chen68bfab22016-11-11 11:04:10 -05001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Yixiao Chen68bfab22016-11-11 11:04:10 -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.impl;
17
18import java.util.List;
19
20import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
21import org.onosproject.tetopology.management.api.node.TerminationPoint;
22import org.onosproject.tetopology.management.api.node.TerminationPointKey;
23
24import com.google.common.base.MoreObjects;
25import com.google.common.base.Objects;
26import com.google.common.collect.ImmutableList;
27import com.google.common.collect.Lists;
28
29/**
30 * The TerminationPoint representation in store.
31 */
32public class InternalTerminationPoint {
33 private TeLinkTpGlobalKey teTpKey;
34 private List<TerminationPointKey> supportingTpIds;
35
36 /**
37 * Creates an instance of InternalTerminationPoint.
38 *
39 * @param tp the termination point
40 */
41 public InternalTerminationPoint(TerminationPoint tp) {
42 this.supportingTpIds = tp
43 .supportingTpIds() == null ? null
44 : Lists.newArrayList(tp
45 .supportingTpIds());
46 }
47
48 /**
49 * Returns the TE termination point key.
50 *
51 * @return the teTpKey
52 */
53 public TeLinkTpGlobalKey teTpKey() {
54 return teTpKey;
55 }
56
57 /**
58 * Returns the supporting termination point Ids.
59 *
60 * @return the supportingTpIds
61 */
62 public List<TerminationPointKey> supportingTpIds() {
63 return supportingTpIds == null ? null
64 : ImmutableList.copyOf(supportingTpIds);
65 }
66
67 /**
68 * Sets the TE termination point key.
69 *
70 * @param teTpKey the teTpKey to set
71 */
72 public void setTeTpKey(TeLinkTpGlobalKey teTpKey) {
73 this.teTpKey = teTpKey;
74 }
75
76 /**
77 * Sets the supporting termination point Ids.
78 *
79 * @param supportingTpIds the supportingTpIds to set
80 */
81 public void setSupportingTpIds(List<TerminationPointKey> supportingTpIds) {
82 this.supportingTpIds = supportingTpIds == null ? null
83 : Lists.newArrayList(supportingTpIds);
84 }
85
86 @Override
87 public int hashCode() {
88 return Objects.hashCode(supportingTpIds, teTpKey);
89 }
90
91 @Override
92 public boolean equals(Object object) {
93 if (this == object) {
94 return true;
95 }
96 if (object instanceof InternalTerminationPoint) {
97 InternalTerminationPoint that = (InternalTerminationPoint) object;
98 return Objects.equal(supportingTpIds, that.supportingTpIds)
99 && Objects.equal(teTpKey, that.teTpKey);
100 }
101 return false;
102 }
103
104 @Override
105 public String toString() {
106 return MoreObjects.toStringHelper(this)
107 .add("supportingTpIds", supportingTpIds)
108 .add("teTpKey", teTpKey)
109 .toString();
110 }
111
112}