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