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 org.opendaylight.protocol.pcep.PCEPObject;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
13 import com.google.common.base.Objects.ToStringHelper;
16 * Basic structure of Bandwidth Object.
18 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.7">PCEP Bandwidth Object</a>
20 public abstract class PCEPBandwidthObject extends PCEPObject {
22 private final Bandwidth bandwidth;
25 * Constructs basic Bandwidth Object.
27 * @param bandwidth Bandwidth
28 * @param processed boolean
29 * @param ignored boolean
31 public PCEPBandwidthObject(final Bandwidth bandwidth, final boolean processed, final boolean ignored) {
32 super(processed, ignored);
33 if (bandwidth == null)
34 this.bandwidth = new Bandwidth(new byte[] { 0 });
36 this.bandwidth = bandwidth;
40 * Gets {@link PCEPBandwidthObject}.
42 * @return Bandwidth. Can't be null.
44 public Bandwidth getBandwidth() {
45 return this.bandwidth;
49 public int hashCode() {
51 int result = super.hashCode();
52 result = prime * result + ((this.bandwidth == null) ? 0 : this.bandwidth.hashCode());
57 public boolean equals(final Object obj) {
60 if (!super.equals(obj))
62 if (this.getClass() != obj.getClass())
64 final PCEPBandwidthObject other = (PCEPBandwidthObject) obj;
65 if (this.bandwidth == null) {
66 if (other.bandwidth != null)
68 } else if (!this.bandwidth.equals(other.bandwidth))
74 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
75 toStringHelper.add("bandwidth", this.bandwidth);
76 return super.addToStringAttributes(toStringHelper);