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