Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / object / PCEPBranchNodeObject.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.pcep.PCEPObject;
13 import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
14 import com.google.common.base.Objects.ToStringHelper;
15
16 /**
17  *
18  */
19 public abstract class PCEPBranchNodeObject extends PCEPObject {
20
21     protected final List<ExplicitRouteSubobject> subobjects;
22
23     /**
24      * Constructs Branch Node list object.
25      *
26      * @param subobjects
27      *            List<PCEPSubobject>
28      * @param processed
29      *            boolean
30      * @param ignored
31      *            boolean
32      */
33     public PCEPBranchNodeObject(List<ExplicitRouteSubobject> subobjects, boolean processed, boolean ignored) {
34         super(processed, ignored);
35         if (subobjects == null || subobjects.isEmpty())
36             throw new IllegalArgumentException("Subobjects can't be null or empty.");
37         this.subobjects = subobjects;
38     }
39
40     /**
41      * Gets list of {@link ExplicitRouteSubobject}
42      *
43      * @return List<ExplicitRouteSubobject>. Can't be null or empty.
44      */
45     public List<ExplicitRouteSubobject> getSubobjects() {
46         return this.subobjects;
47     }
48
49     @Override
50     public int hashCode() {
51         final int prime = 31;
52         int result = super.hashCode();
53         result = prime * result + ((this.subobjects == null) ? 0 : this.subobjects.hashCode());
54         return result;
55     }
56
57     @Override
58     public boolean equals(Object obj) {
59         if (this == obj)
60             return true;
61         if (!super.equals(obj))
62             return false;
63         if (this.getClass() != obj.getClass())
64             return false;
65         final PCEPBranchNodeObject other = (PCEPBranchNodeObject) obj;
66         if (this.subobjects == null) {
67             if (other.subobjects != null)
68                 return false;
69         } else if (!this.subobjects.equals(other.subobjects))
70             return false;
71         return true;
72     }
73
74         @Override
75         protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
76                 toStringHelper.add("subobjects", this.subobjects);
77                 return super.addToStringAttributes(toStringHelper);
78         }
79 }