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.object;
10 import org.opendaylight.protocol.concepts.NetworkAddress;
11 import com.google.common.base.Objects.ToStringHelper;
14 * Parameterized structure of PCEP End Points Object.
16 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.6">PCEP
19 * subtype of NetworkAddress
21 public class PCEPEndPointsObject<T extends NetworkAddress<T>> extends PCEPEndPoints {
23 private final T sourceAddress;
25 private final T destinationAddress;
28 * Constructs Close Object with mandatory object.
30 * @param sourceAddress
32 * @param destinationAddress
35 public PCEPEndPointsObject(T sourceAddress, T destinationAddress) {
37 if (sourceAddress == null)
38 throw new IllegalArgumentException("Source address is mantadory.");
39 this.sourceAddress = sourceAddress;
40 if (destinationAddress == null)
41 throw new IllegalArgumentException("Destination address is mantadory.");
42 this.destinationAddress = destinationAddress;
46 * Gets source address of type T.
48 * @return T. Can't be null.
50 public T getSourceAddress() {
51 return this.sourceAddress;
55 * Gets destination address of type T.
57 * @return T. Can't be null.
59 public T getDestinationAddress() {
60 return this.destinationAddress;
64 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
65 toStringHelper.add("sourceAddress", this.sourceAddress);
66 toStringHelper.add("destinationAddress", this.destinationAddress);
67 return super.addToStringAttributes(toStringHelper);
71 public int hashCode() {
73 int result = super.hashCode();
74 result = prime * result + ((this.destinationAddress == null) ? 0 : this.destinationAddress.hashCode());
75 result = prime * result + ((this.sourceAddress == null) ? 0 : this.sourceAddress.hashCode());
80 public boolean equals(Object obj) {
83 if (!super.equals(obj))
85 if (!(obj instanceof PCEPEndPointsObject))
87 final PCEPEndPointsObject<?> other = (PCEPEndPointsObject<?>) obj;
88 if (this.destinationAddress == null) {
89 if (other.destinationAddress != null)
91 } else if (!this.destinationAddress.equals(other.destinationAddress))
93 if (this.sourceAddress == null) {
94 if (other.sourceAddress != null)
96 } else if (!this.sourceAddress.equals(other.sourceAddress))