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.subobject;
10 import org.opendaylight.protocol.concepts.Prefix;
13 * Parametrized structure of IP Prefix Subobject. Defined in RFC5521.
15 * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route
16 * Object definition</a>
21 public class XROIPPrefixSubobject<T extends Prefix<?>> extends ExcludeRouteSubobject {
23 private final XROSubobjectAttribute attribute;
25 private final T prefix;
28 * Constructs IPPrefix Subobject.
35 * XROSubobjectAttribute
37 public XROIPPrefixSubobject(T prefix, boolean mandatory, XROSubobjectAttribute attribute) {
39 this.attribute = attribute;
44 * Gets specific {@link Prefix}.
48 public T getPrefix() {
53 * Gets the attribute of the subobject
55 * @return the attribute
57 public XROSubobjectAttribute getAttribute() {
58 return this.attribute;
62 public int hashCode() {
64 int result = super.hashCode();
65 result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
66 result = prime * result + ((this.prefix == null) ? 0 : this.prefix.hashCode());
71 public boolean equals(Object obj) {
74 if (!super.equals(obj))
76 if (this.getClass() != obj.getClass())
78 final XROIPPrefixSubobject<?> other = (XROIPPrefixSubobject<?>) obj;
79 if (this.attribute != other.attribute)
81 if (this.prefix == null) {
82 if (other.prefix != null)
84 } else if (!this.prefix.equals(other.prefix))
90 public String toString() {
91 final StringBuilder builder = new StringBuilder();
92 builder.append("XROIPPrefixSubobject [attribute=");
93 builder.append(this.attribute);
94 builder.append(", prefix=");
95 builder.append(this.prefix);
96 builder.append(", mandatory=");
97 builder.append(this.mandatory);
99 return builder.toString();