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.ExcludeRouteSubobject;
14 import com.google.common.base.Objects.ToStringHelper;
17 * Provides a list of network resources that the PCE is requested to exclude
18 * from the path that it computes. Flags associated with each list member
19 * instruct the PCE as to whether the network resources must be excluded from
20 * the computed path, or whether the PCE should make best efforts to exclude the
21 * resources from the computed path.
23 * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1"> Exclude
24 * Route Object definition</a>
26 public class PCEPExcludeRouteObject extends PCEPObject {
28 private final boolean fail;
30 private final List<ExcludeRouteSubobject> subobjects;
33 * Constructs Exclude Route Object.
36 * List<PCEPXROSubobject>. Can't be null or empty.
44 public PCEPExcludeRouteObject(List<ExcludeRouteSubobject> subobjects, boolean fail, boolean processed, boolean ignored) {
45 super(processed, ignored);
46 if (subobjects == null || subobjects.isEmpty())
47 throw new IllegalArgumentException("Subobjects can't be null or empty.");
50 this.subobjects = subobjects;
54 * Gets list of sub-objects
56 * @return List<PCEPXROSubobject>. Can't be null or empty.
58 public List<ExcludeRouteSubobject> getSubobjects() {
59 return this.subobjects;
63 * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1"> Exclude
64 * Route Object definition</a>
66 * @return if returns true, the requesting PCC requires the computation of a
67 * new path for an existing TE LSP that has failed
69 public boolean isFail() {
74 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
75 toStringHelper.add("fail", this.fail);
76 toStringHelper.add("subobjects", this.subobjects);
77 return super.addToStringAttributes(toStringHelper);
81 public int hashCode() {
83 int result = super.hashCode();
84 result = prime * result + ((this.subobjects == null) ? 0 : this.subobjects.hashCode());
89 public boolean equals(Object obj) {
92 if (!super.equals(obj))
94 if (this.getClass() != obj.getClass())
96 final PCEPExcludeRouteObject other = (PCEPExcludeRouteObject) obj;
97 if (this.subobjects == null) {
98 if (other.subobjects != null)
100 } else if (!this.subobjects.equals(other.subobjects))