wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 1 | package org.onosproject.net.tunnel; |
| 2 | |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 4 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 5 | |
| 6 | import java.util.Objects; |
| 7 | import java.util.Optional; |
| 8 | |
| 9 | import org.onosproject.net.AbstractModel; |
| 10 | import org.onosproject.net.Annotations; |
| 11 | import org.onosproject.net.ElementId; |
| 12 | import org.onosproject.net.PortNumber; |
| 13 | import org.onosproject.net.provider.ProviderId; |
| 14 | |
| 15 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 16 | * Default optical tunnel point model implementation. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 17 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 18 | public class DefaultOpticalTunnelEndPoint extends AbstractModel implements OpticalTunnelEndPoint { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 19 | private final Optional<ElementId> elementId; |
| 20 | private final Optional<PortNumber> portNumber; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 21 | private final Optional<OpticalTunnelEndPoint> parentPoint; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 22 | private final Type type; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 23 | private final OpticalLogicId id; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 24 | private final boolean isGlobal; |
| 25 | |
| 26 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 27 | * Creates a optical tunnel point attributed to the specified provider (may be null). |
| 28 | * if provider is null, which means the optical tunnel point is not managed by the SB. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 29 | * |
wei wei | a668122 | 2015-04-21 14:58:22 -0500 | [diff] [blame] | 30 | * @param providerId tunnelProvider Id |
| 31 | * @param elementId parent network element |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 32 | * @param number port number |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 33 | * @param parentPoint parent port or parent label |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 34 | * @param type port type |
| 35 | * @param id LabelId |
| 36 | * @param isGlobal indicator whether the label is global significant or not |
| 37 | * @param annotations optional key/value annotations |
| 38 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 39 | public DefaultOpticalTunnelEndPoint(ProviderId providerId, Optional<ElementId> elementId, |
| 40 | Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint, |
| 41 | Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 42 | super(providerId, annotations); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 43 | checkNotNull(type, "type cannot be null"); |
| 44 | checkNotNull(id, "id cannot be null"); |
| 45 | checkNotNull(isGlobal, "isGlobal cannot be null"); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 46 | this.elementId = elementId; |
| 47 | this.portNumber = number; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 48 | this.parentPoint = parentPoint; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 49 | this.id = id; |
| 50 | this.type = type; |
| 51 | this.isGlobal = isGlobal; |
| 52 | } |
| 53 | |
| 54 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 55 | public OpticalLogicId id() { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 56 | return id; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public Optional<ElementId> elementId() { |
| 61 | return elementId; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public Optional<PortNumber> portNumber() { |
| 66 | return portNumber; |
| 67 | } |
| 68 | |
| 69 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 70 | public Optional<OpticalTunnelEndPoint> parentPoint() { |
| 71 | return parentPoint; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean isGlobal() { |
| 76 | return isGlobal; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public Type type() { |
| 81 | return type; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public int hashCode() { |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 86 | return Objects.hash(elementId, portNumber, parentPoint, id); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public boolean equals(Object obj) { |
| 91 | if (this == obj) { |
| 92 | return true; |
| 93 | } |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 94 | if (obj instanceof DefaultOpticalTunnelEndPoint) { |
| 95 | final DefaultOpticalTunnelEndPoint other = (DefaultOpticalTunnelEndPoint) obj; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 96 | return Objects.equals(this.id, other.id) && |
| 97 | Objects.equals(this.type, other.type) && |
| 98 | Objects.equals(this.isGlobal, other.isGlobal) && |
| 99 | Objects.equals(this.elementId, other.elementId) && |
| 100 | Objects.equals(this.portNumber, other.portNumber) && |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 101 | Objects.equals(this.parentPoint, other.parentPoint); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 102 | } |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public String toString() { |
| 108 | return toStringHelper(this) |
| 109 | .add("elementId", elementId) |
| 110 | .add("portNumber", portNumber) |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 111 | .add("parentPoint", parentPoint) |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 112 | .add("type", type) |
| 113 | .add("id", id) |
| 114 | .add("isGlobal", isGlobal) |
| 115 | .toString(); |
| 116 | } |
| 117 | |
| 118 | } |