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 java.util.List;
12 import org.opendaylight.protocol.concepts.NetworkAddress;
13 import com.google.common.base.Objects.ToStringHelper;
15 public class PCEPP2MPEndPointsObject<T extends NetworkAddress<T>> extends PCEPEndPoints {
17 private final long leafType;
19 private final T sourceAddress;
21 private final List<T> destinationAddresses;
23 public PCEPP2MPEndPointsObject(long leafType, T sourceAddress, List<T> destinationAddresses, boolean processed, boolean ignored) {
24 super(processed, ignored);
25 this.leafType = leafType;
26 this.sourceAddress = sourceAddress;
27 if (destinationAddresses == null || destinationAddresses.isEmpty())
28 throw new IllegalArgumentException("At least one destination have to be specified.");
30 this.destinationAddresses = destinationAddresses;
34 * @return the leafType
36 public long getLeafType() {
41 * @return the sourceAddress
43 public T getSourceAddress() {
44 return this.sourceAddress;
48 * @return the destinationAddresses
50 public List<T> getDestinationAddresses() {
51 return this.destinationAddresses;
55 public int hashCode() {
57 int result = super.hashCode();
58 result = prime * result + ((this.destinationAddresses == null) ? 0 : this.destinationAddresses.hashCode());
59 result = prime * result + (int) (this.leafType ^ (this.leafType >>> 32));
60 result = prime * result + ((this.sourceAddress == null) ? 0 : this.sourceAddress.hashCode());
65 public boolean equals(Object obj) {
68 if (!super.equals(obj))
70 if (this.getClass() != obj.getClass())
72 final PCEPP2MPEndPointsObject<?> other = (PCEPP2MPEndPointsObject<?>) obj;
73 if (this.destinationAddresses == null) {
74 if (other.destinationAddresses != null)
76 } else if (!this.destinationAddresses.equals(other.destinationAddresses))
78 if (this.leafType != other.leafType)
80 if (this.sourceAddress == null) {
81 if (other.sourceAddress != null)
83 } else if (!this.sourceAddress.equals(other.sourceAddress))
89 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
90 toStringHelper.add("leafType", this.leafType);
91 toStringHelper.add("sourceAddress", this.sourceAddress);
92 toStringHelper.add("destinationAddresses", this.destinationAddresses);
93 return super.addToStringAttributes(toStringHelper);