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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
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 Object definition</a>
17 * @param <T> subtype of Prefix
19 public class XROIPPrefixSubobject extends ExcludeRouteSubobject {
21 private final XROSubobjectAttribute attribute;
23 private final IpPrefix prefix;
26 * Constructs IPPrefix Subobject.
29 * @param mandatory boolean
30 * @param attribute XROSubobjectAttribute
32 public XROIPPrefixSubobject(final IpPrefix prefix, final boolean mandatory, final XROSubobjectAttribute attribute) {
34 this.attribute = attribute;
39 * Gets specific {@link Prefix}.
43 public IpPrefix getPrefix() {
48 * Gets the attribute of the subobject
50 * @return the attribute
52 public XROSubobjectAttribute getAttribute() {
53 return this.attribute;
57 public int hashCode() {
59 int result = super.hashCode();
60 result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
61 result = prime * result + ((this.prefix == null) ? 0 : this.prefix.hashCode());
66 public boolean equals(final Object obj) {
69 if (!super.equals(obj))
71 if (this.getClass() != obj.getClass())
73 final XROIPPrefixSubobject other = (XROIPPrefixSubobject) obj;
74 if (this.attribute != other.attribute)
76 if (this.prefix == null) {
77 if (other.prefix != null)
79 } else if (!this.prefix.equals(other.prefix))
85 public String toString() {
86 final StringBuilder builder = new StringBuilder();
87 builder.append("XROIPPrefixSubobject [attribute=");
88 builder.append(this.attribute);
89 builder.append(", prefix=");
90 builder.append(this.prefix);
91 builder.append(", mandatory=");
92 builder.append(this.mandatory);
94 return builder.toString();