Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / object / PCEPUnreachedDestinationObject.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.pcep.object;
9
10 import java.util.List;
11
12 import org.opendaylight.protocol.concepts.NetworkAddress;
13 import org.opendaylight.protocol.pcep.PCEPObject;
14 import com.google.common.base.Objects.ToStringHelper;
15
16 public class PCEPUnreachedDestinationObject<T extends NetworkAddress<T>> extends PCEPObject {
17
18     private final List<T> unreachedDestinations;
19
20     public PCEPUnreachedDestinationObject(List<T> unreachedDestinations, boolean processed, boolean ignored) {
21         super(processed, ignored);
22         if (unreachedDestinations == null || unreachedDestinations.isEmpty())
23             throw new IllegalArgumentException("At least one destination have to be specified.");
24
25         this.unreachedDestinations = unreachedDestinations;
26     }
27
28     public List<T> getUnreachedDestinations() {
29         return this.unreachedDestinations;
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = super.hashCode();
36         result = prime * result + ((this.unreachedDestinations == null) ? 0 : this.unreachedDestinations.hashCode());
37         return result;
38     }
39
40     @Override
41     public boolean equals(Object obj) {
42         if (this == obj)
43             return true;
44         if (!super.equals(obj))
45             return false;
46         if (this.getClass() != obj.getClass())
47             return false;
48         final PCEPUnreachedDestinationObject<?> other = (PCEPUnreachedDestinationObject<?>) obj;
49         if (this.unreachedDestinations == null) {
50             if (other.unreachedDestinations != null)
51                 return false;
52         } else if (!this.unreachedDestinations.equals(other.unreachedDestinations))
53             return false;
54         return true;
55     }
56
57     @Override
58         protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
59                 toStringHelper.add("unreachedDestinations", this.unreachedDestinations);
60                 return super.addToStringAttributes(toStringHelper);
61         }
62
63 }