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.concepts.AbstractMetric;
11 import org.opendaylight.protocol.pcep.PCEPObject;
12 import com.google.common.base.Objects.ToStringHelper;
15 * Structure of PCEP Metric Object.
17 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.8">PCEP Metric
20 public class PCEPMetricObject extends PCEPObject {
22 private final boolean bound;
24 private final boolean computedMetric;
26 private final AbstractMetric<?> metric;
29 * Constructs PCEP Metric Object.
33 * @param computedMetric
42 public PCEPMetricObject(boolean bound, boolean computedMetric, AbstractMetric<?> metric, boolean processed, boolean ignored) {
43 super(processed, ignored);
45 this.computedMetric = computedMetric;
47 throw new IllegalArgumentException("Mandatory parameter metric cannot be null.");
56 public boolean isBound() {
61 * Gets Computed Metric flag.
65 public boolean isComputedMetric() {
66 return this.computedMetric;
70 * Gets {@link AbstractMetric<?>}.
72 * @return AbstractMetric<?>
74 public AbstractMetric<?> getMetric() {
79 public int hashCode() {
81 int result = super.hashCode();
82 result = prime * result + (this.bound ? 1231 : 1237);
83 result = prime * result + (this.computedMetric ? 1231 : 1237);
84 result = prime * result + ((this.metric == null) ? 0 : this.metric.hashCode());
89 public boolean equals(Object obj) {
92 if (!super.equals(obj))
94 if (this.getClass() != obj.getClass())
96 final PCEPMetricObject other = (PCEPMetricObject) obj;
97 if (this.bound != other.bound)
99 if (this.computedMetric != other.computedMetric)
101 if (this.metric == null) {
102 if (other.metric != null)
104 } else if (!this.metric.equals(other.metric))
110 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
111 toStringHelper.add("bound", this.bound);
112 toStringHelper.add("computedMetric", this.computedMetric);
113 toStringHelper.add("metric", this.metric);
114 return super.addToStringAttributes(toStringHelper);