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