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
8 package org.opendaylight.protocol.pcep.concepts;
10 import org.opendaylight.protocol.concepts.NetworkAddress;
13 * Basic structure of Extended Tunnel Identifier.
16 * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-7.2.2">LSP
17 * Identifiers TLVs</a>
20 public abstract class AbstractExtendedTunnelIdentifier<T extends NetworkAddress<T>> implements Comparable<ExtendedTunnelIdentifier<T>>, ExtendedTunnelIdentifier<T> {
22 private static final long serialVersionUID = 110737862492677555L;
24 private final T identifier;
26 protected AbstractExtendedTunnelIdentifier(final T identifier) {
27 this.identifier = identifier;
31 public T getIdentifier() {
32 return this.identifier;
36 public int compareTo(final ExtendedTunnelIdentifier<T> other) {
37 if (this.identifier == other.getIdentifier())
39 if (this.identifier == null)
41 if (other.getIdentifier() == null)
43 return this.identifier.compareTo(other.getIdentifier());
47 public int hashCode() {
50 result = prime * result + ((this.identifier == null) ? 0 : this.identifier.hashCode());
55 public boolean equals(Object obj) {
60 if (this.getClass() != obj.getClass())
62 final AbstractExtendedTunnelIdentifier<?> other = (AbstractExtendedTunnelIdentifier<?>) obj;
63 if (this.identifier == null) {
64 if (other.identifier != null)
66 } else if (!this.identifier.equals(other.identifier))
72 public String toString() {
73 final StringBuilder builder = new StringBuilder();
74 builder.append("AbstractExtendedTunnelIdentifier [identifier=");
75 builder.append(this.identifier);
77 return builder.toString();