Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | */ |
| 16 | package org.onosproject.tetopology.management.api.node; |
| 17 | |
| 18 | import java.util.List; |
| 19 | |
| 20 | import org.onosproject.tetopology.management.api.KeyId; |
| 21 | |
| 22 | import com.google.common.base.MoreObjects; |
| 23 | import com.google.common.base.Objects; |
| 24 | |
| 25 | /** |
| 26 | * TE termination point representation. |
| 27 | */ |
| 28 | public class TeTerminationPoint { |
| 29 | private KeyId teTpId; |
| 30 | private List<InterfaceSwitchingCapability> capabilities; |
| 31 | private long interLayerLockId; |
| 32 | |
| 33 | /** |
| 34 | * Creates an instance of TeTerminationPoint. |
| 35 | * |
| 36 | * @param teTpId TE termination point identifier |
| 37 | * @param capabilities capability descriptor for termination point |
| 38 | * @param interLayerLockId inter-layer lock identifier |
| 39 | */ |
| 40 | public TeTerminationPoint(KeyId teTpId, |
| 41 | List<InterfaceSwitchingCapability> capabilities, long interLayerLockId) { |
| 42 | this.teTpId = teTpId; |
| 43 | this.capabilities = capabilities; |
| 44 | this.interLayerLockId = interLayerLockId; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Creates an instance of TeTerminationPoint with teTpId only. |
| 49 | * |
| 50 | * @param teTpId TE termination point id |
| 51 | */ |
| 52 | public TeTerminationPoint(KeyId teTpId) { |
| 53 | this.teTpId = teTpId; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the TE termination point id. |
| 58 | * |
| 59 | * @return value of teTpId |
| 60 | */ |
| 61 | public KeyId teTpId() { |
| 62 | return teTpId; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the interface switching capabilities. |
| 67 | * |
| 68 | * @return interface switching capabilities |
| 69 | */ |
| 70 | public List<InterfaceSwitchingCapability> interfaceSwitchingCapabilities() { |
| 71 | return capabilities; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the interLayerLockId. |
| 76 | * |
| 77 | * @return interlayer lock id |
| 78 | */ |
| 79 | public long getInterLayerLockId() { |
| 80 | return interLayerLockId; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Sets the te tp Id. |
| 85 | * |
| 86 | * @param teTpId the teTpId to set |
| 87 | */ |
| 88 | public void setTeTpId(KeyId teTpId) { |
| 89 | this.teTpId = teTpId; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Sets the interface switching capabilities. |
| 94 | * |
| 95 | * @param capabilities the capabilities to set |
| 96 | */ |
| 97 | public void setInterfaceSwitchingCapabilities(List<InterfaceSwitchingCapability> capabilities) { |
| 98 | this.capabilities = capabilities; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Sets the inter layer lockId. |
| 103 | * |
| 104 | * @param interLayerLockId the interLayerLockId to set |
| 105 | */ |
| 106 | public void setInterLayerLockId(long interLayerLockId) { |
| 107 | this.interLayerLockId = interLayerLockId; |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public int hashCode() { |
| 112 | return Objects.hashCode(teTpId, capabilities, interLayerLockId); |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public boolean equals(Object object) { |
| 117 | if (this == object) { |
| 118 | return true; |
| 119 | } |
| 120 | if (object instanceof TeTerminationPoint) { |
| 121 | TeTerminationPoint that = (TeTerminationPoint) object; |
| 122 | return Objects.equal(this.teTpId, that.teTpId) && |
| 123 | Objects.equal(this.capabilities, that.capabilities) && |
| 124 | Objects.equal(this.interLayerLockId, that.interLayerLockId); |
| 125 | } |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | @Override |
| 130 | public String toString() { |
| 131 | return MoreObjects.toStringHelper(this) |
| 132 | .add("teTpId", teTpId) |
| 133 | .add("capabilities", capabilities) |
| 134 | .add("interLayerLockId", interLayerLockId) |
| 135 | .toString(); |
| 136 | } |
| 137 | |
| 138 | } |