2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.pcep.object;
10 import java.util.List;
12 import org.opendaylight.protocol.pcep.PCEPObject;
13 import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
14 import com.google.common.base.Objects.ToStringHelper;
19 public abstract class PCEPBranchNodeObject extends PCEPObject {
21 protected final List<ExplicitRouteSubobject> subobjects;
24 * Constructs Branch Node list object.
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;
41 * Gets list of {@link ExplicitRouteSubobject}
43 * @return List<ExplicitRouteSubobject>. Can't be null or empty.
45 public List<ExplicitRouteSubobject> getSubobjects() {
46 return this.subobjects;
50 public int hashCode() {
52 int result = super.hashCode();
53 result = prime * result + ((this.subobjects == null) ? 0 : this.subobjects.hashCode());
58 public boolean equals(Object obj) {
61 if (!super.equals(obj))
63 if (this.getClass() != obj.getClass())
65 final PCEPBranchNodeObject other = (PCEPBranchNodeObject) obj;
66 if (this.subobjects == null) {
67 if (other.subobjects != null)
69 } else if (!this.subobjects.equals(other.subobjects))
75 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
76 toStringHelper.add("subobjects", this.subobjects);
77 return super.addToStringAttributes(toStringHelper);