blob: 878818a817d2c1b24bc09923f39abaf139693e3a [file] [log] [blame]
Thomas Vachuskabf916ea2015-05-20 18:24:34 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuskabf916ea2015-05-20 18:24:34 -07003 *
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.incubator.net.tunnel;
wei wei89ddc322015-03-22 16:29:04 -050017
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21import java.util.Optional;
22
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040023import com.google.common.annotations.Beta;
wei wei89ddc322015-03-22 16:29:04 -050024import org.onosproject.net.AbstractModel;
25import org.onosproject.net.Annotations;
26import org.onosproject.net.ElementId;
27import org.onosproject.net.PortNumber;
28import org.onosproject.net.provider.ProviderId;
29
30/**
jcc4a20a5f2015-04-30 15:43:39 +080031 * Default optical tunnel point model implementation.
wei wei89ddc322015-03-22 16:29:04 -050032 */
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040033@Beta
jcc4a20a5f2015-04-30 15:43:39 +080034public class DefaultOpticalTunnelEndPoint extends AbstractModel implements OpticalTunnelEndPoint {
wei wei89ddc322015-03-22 16:29:04 -050035 private final Optional<ElementId> elementId;
36 private final Optional<PortNumber> portNumber;
jcc4a20a5f2015-04-30 15:43:39 +080037 private final Optional<OpticalTunnelEndPoint> parentPoint;
wei wei89ddc322015-03-22 16:29:04 -050038 private final Type type;
jcc4a20a5f2015-04-30 15:43:39 +080039 private final OpticalLogicId id;
wei wei89ddc322015-03-22 16:29:04 -050040 private final boolean isGlobal;
41
42 /**
jcc4a20a5f2015-04-30 15:43:39 +080043 * Creates a optical tunnel point attributed to the specified provider (may be null).
44 * if provider is null, which means the optical tunnel point is not managed by the SB.
wei wei89ddc322015-03-22 16:29:04 -050045 *
wei weia6681222015-04-21 14:58:22 -050046 * @param providerId tunnelProvider Id
47 * @param elementId parent network element
wei wei89ddc322015-03-22 16:29:04 -050048 * @param number port number
jcc4a20a5f2015-04-30 15:43:39 +080049 * @param parentPoint parent port or parent label
wei wei89ddc322015-03-22 16:29:04 -050050 * @param type port type
51 * @param id LabelId
52 * @param isGlobal indicator whether the label is global significant or not
53 * @param annotations optional key/value annotations
54 */
jcc4a20a5f2015-04-30 15:43:39 +080055 public DefaultOpticalTunnelEndPoint(ProviderId providerId, Optional<ElementId> elementId,
56 Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint,
57 Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) {
wei wei89ddc322015-03-22 16:29:04 -050058 super(providerId, annotations);
59 this.elementId = elementId;
60 this.portNumber = number;
jcc4a20a5f2015-04-30 15:43:39 +080061 this.parentPoint = parentPoint;
wei wei89ddc322015-03-22 16:29:04 -050062 this.id = id;
63 this.type = type;
64 this.isGlobal = isGlobal;
65 }
66
67 @Override
jcc4a20a5f2015-04-30 15:43:39 +080068 public OpticalLogicId id() {
wei wei89ddc322015-03-22 16:29:04 -050069 return id;
70 }
71
72 @Override
73 public Optional<ElementId> elementId() {
74 return elementId;
75 }
76
77 @Override
78 public Optional<PortNumber> portNumber() {
79 return portNumber;
80 }
81
82 @Override
jcc4a20a5f2015-04-30 15:43:39 +080083 public Optional<OpticalTunnelEndPoint> parentPoint() {
84 return parentPoint;
wei wei89ddc322015-03-22 16:29:04 -050085 }
86
87 @Override
88 public boolean isGlobal() {
89 return isGlobal;
90 }
91
92 @Override
93 public Type type() {
94 return type;
95 }
96
97 @Override
98 public int hashCode() {
jcc4a20a5f2015-04-30 15:43:39 +080099 return Objects.hash(elementId, portNumber, parentPoint, id);
wei wei89ddc322015-03-22 16:29:04 -0500100 }
101
102 @Override
103 public boolean equals(Object obj) {
104 if (this == obj) {
105 return true;
106 }
jcc4a20a5f2015-04-30 15:43:39 +0800107 if (obj instanceof DefaultOpticalTunnelEndPoint) {
108 final DefaultOpticalTunnelEndPoint other = (DefaultOpticalTunnelEndPoint) obj;
wei wei89ddc322015-03-22 16:29:04 -0500109 return Objects.equals(this.id, other.id) &&
110 Objects.equals(this.type, other.type) &&
111 Objects.equals(this.isGlobal, other.isGlobal) &&
112 Objects.equals(this.elementId, other.elementId) &&
113 Objects.equals(this.portNumber, other.portNumber) &&
jcc4a20a5f2015-04-30 15:43:39 +0800114 Objects.equals(this.parentPoint, other.parentPoint);
wei wei89ddc322015-03-22 16:29:04 -0500115 }
116 return false;
117 }
118
119 @Override
120 public String toString() {
121 return toStringHelper(this)
122 .add("elementId", elementId)
123 .add("portNumber", portNumber)
jcc4a20a5f2015-04-30 15:43:39 +0800124 .add("parentPoint", parentPoint)
wei wei89ddc322015-03-22 16:29:04 -0500125 .add("type", type)
126 .add("id", id)
127 .add("isGlobal", isGlobal)
128 .toString();
129 }
130
131}