2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.pcep.tlv;
11 import org.opendaylight.protocol.concepts.NetworkAddress;
12 import org.opendaylight.protocol.pcep.concepts.ExtendedTunnelIdentifier;
13 import org.opendaylight.protocol.pcep.concepts.LSPIdentifier;
14 import org.opendaylight.protocol.pcep.concepts.TunnelIdentifier;
17 * Basic structure of LSP Identifiers TLV.
20 * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-7.2.2">LSP
21 * Identifiers TLVs</a>
24 public abstract class AbstractLSPIdentifiersTlv<T extends NetworkAddress<T>> implements LSPIdentifiersTlv<T> {
25 private static final long serialVersionUID = 2386922658825295806L;
27 private final T senderAddress;
29 private final LSPIdentifier lspID;
31 private final TunnelIdentifier tunnelID;
33 private final ExtendedTunnelIdentifier<T> extendedTunnelID;
36 * Construct LSP Identifier TLV with mandatory objects.
38 * @param senderAddress
41 * @param extendedTunnelID
43 protected AbstractLSPIdentifiersTlv(T senderAddress, LSPIdentifier lspID, TunnelIdentifier tunnelID, ExtendedTunnelIdentifier<T> extendedTunnelID) {
44 if (senderAddress == null)
45 throw new IllegalArgumentException("SenderAdress is mandatory.");
46 this.senderAddress = senderAddress;
49 throw new IllegalArgumentException("LspID is mandatory.");
53 throw new IllegalArgumentException("TunnelID is mandatory.");
54 this.tunnelID = tunnelID;
56 if (extendedTunnelID == null)
57 throw new IllegalArgumentException("ExtendedTunnelID is mandatory.");
58 this.extendedTunnelID = extendedTunnelID;
62 public T getSenderAddress() {
63 return this.senderAddress;
67 public LSPIdentifier getLspID() {
72 public TunnelIdentifier getTunnelID() {
77 public ExtendedTunnelIdentifier<T> getExtendedTunnelID() {
78 return this.extendedTunnelID;
82 public int hashCode() {
85 result = prime * result + ((this.extendedTunnelID == null) ? 0 : this.extendedTunnelID.hashCode());
86 result = prime * result + ((this.lspID == null) ? 0 : this.lspID.hashCode());
87 result = prime * result + ((this.senderAddress == null) ? 0 : this.senderAddress.hashCode());
88 result = prime * result + ((this.tunnelID == null) ? 0 : this.tunnelID.hashCode());
93 public boolean equals(Object obj) {
98 if (this.getClass() != obj.getClass())
100 final AbstractLSPIdentifiersTlv<?> other = (AbstractLSPIdentifiersTlv<?>) obj;
101 if (this.extendedTunnelID == null) {
102 if (other.extendedTunnelID != null)
104 } else if (!this.extendedTunnelID.equals(other.extendedTunnelID))
106 if (this.lspID == null) {
107 if (other.lspID != null)
109 } else if (!this.lspID.equals(other.lspID))
111 if (this.senderAddress == null) {
112 if (other.senderAddress != null)
114 } else if (!this.senderAddress.equals(other.senderAddress))
116 if (this.tunnelID == null) {
117 if (other.tunnelID != null)
119 } else if (!this.tunnelID.equals(other.tunnelID))
125 public String toString() {
126 final StringBuilder builder = new StringBuilder();
127 builder.append("AbstractLSPIdentifiersTlv [senderAddress=");
128 builder.append(this.senderAddress);
129 builder.append(", lspID=");
130 builder.append(this.lspID);
131 builder.append(", tunnelID=");
132 builder.append(this.tunnelID);
133 builder.append(", extendedTunnelID=");
134 builder.append(this.extendedTunnelID);
136 return builder.toString();