Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.incubator.net.tunnel; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | import java.util.Optional; |
| 22 | |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 23 | import com.google.common.annotations.Beta; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 24 | import org.onosproject.net.AbstractModel; |
| 25 | import org.onosproject.net.Annotations; |
| 26 | import org.onosproject.net.ElementId; |
| 27 | import org.onosproject.net.PortNumber; |
| 28 | import org.onosproject.net.provider.ProviderId; |
| 29 | |
| 30 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 31 | * Default optical tunnel point model implementation. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 32 | */ |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 33 | @Beta |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 34 | public class DefaultOpticalTunnelEndPoint extends AbstractModel implements OpticalTunnelEndPoint { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 35 | private final Optional<ElementId> elementId; |
| 36 | private final Optional<PortNumber> portNumber; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 37 | private final Optional<OpticalTunnelEndPoint> parentPoint; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 38 | private final Type type; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 39 | private final OpticalLogicId id; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 40 | private final boolean isGlobal; |
| 41 | |
| 42 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 43 | * 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 wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 45 | * |
wei wei | a668122 | 2015-04-21 14:58:22 -0500 | [diff] [blame] | 46 | * @param providerId tunnelProvider Id |
| 47 | * @param elementId parent network element |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 48 | * @param number port number |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 49 | * @param parentPoint parent port or parent label |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 50 | * @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 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 55 | public DefaultOpticalTunnelEndPoint(ProviderId providerId, Optional<ElementId> elementId, |
| 56 | Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint, |
| 57 | Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 58 | super(providerId, annotations); |
| 59 | this.elementId = elementId; |
| 60 | this.portNumber = number; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 61 | this.parentPoint = parentPoint; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 62 | this.id = id; |
| 63 | this.type = type; |
| 64 | this.isGlobal = isGlobal; |
| 65 | } |
| 66 | |
| 67 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 68 | public OpticalLogicId id() { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 69 | 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 |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 83 | public Optional<OpticalTunnelEndPoint> parentPoint() { |
| 84 | return parentPoint; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 85 | } |
| 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() { |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 99 | return Objects.hash(elementId, portNumber, parentPoint, id); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public boolean equals(Object obj) { |
| 104 | if (this == obj) { |
| 105 | return true; |
| 106 | } |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 107 | if (obj instanceof DefaultOpticalTunnelEndPoint) { |
| 108 | final DefaultOpticalTunnelEndPoint other = (DefaultOpticalTunnelEndPoint) obj; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 109 | 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) && |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 114 | Objects.equals(this.parentPoint, other.parentPoint); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 115 | } |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public String toString() { |
| 121 | return toStringHelper(this) |
| 122 | .add("elementId", elementId) |
| 123 | .add("portNumber", portNumber) |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 124 | .add("parentPoint", parentPoint) |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 125 | .add("type", type) |
| 126 | .add("id", id) |
| 127 | .add("isGlobal", isGlobal) |
| 128 | .toString(); |
| 129 | } |
| 130 | |
| 131 | } |