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.Collections;
11 import java.util.List;
13 import org.opendaylight.protocol.pcep.PCEPOFCodes;
14 import org.opendaylight.protocol.pcep.PCEPObject;
15 import org.opendaylight.protocol.pcep.PCEPTlv;
16 import com.google.common.base.Objects.ToStringHelper;
19 * Indicates the desired/required objective function to be applied by the PCE
20 * during path computation or within a PCRep message so as to indicate the
21 * objective function that was used by the PCE during path computation.
23 * @see <a href="http://tools.ietf.org/html/rfc5541#section-3.1">OF Object</a>
25 public class PCEPObjectiveFunctionObject extends PCEPObject {
27 private final PCEPOFCodes code;
29 private final List<PCEPTlv> tlvs;
32 * Constructs objective function object only with mandatory objects.
41 public PCEPObjectiveFunctionObject(PCEPOFCodes code, boolean processed, boolean ignored) {
42 this(code, null, processed, ignored);
46 * Constructs objective function object also with optional objects.
57 public PCEPObjectiveFunctionObject(PCEPOFCodes code, List<PCEPTlv> tlvs, boolean processed, boolean ignored) {
58 super(processed, ignored);
62 this.tlvs = Collections.emptyList();
68 * Gets the objective function code
70 * @return the PCEPOFCodes
72 public PCEPOFCodes getCode() {
77 * Gets the list of tlvs
79 * @return the list of tlvs
81 public List<PCEPTlv> getTlvs() {
86 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
87 toStringHelper.add("code", this.code);
88 toStringHelper.add("tlvs", this.tlvs);
89 return super.addToStringAttributes(toStringHelper);
93 public int hashCode() {
95 int result = super.hashCode();
96 result = prime * result + ((this.code == null) ? 0 : this.code.hashCode());
97 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
102 public boolean equals(Object obj) {
105 if (!super.equals(obj))
107 if (this.getClass() != obj.getClass())
109 final PCEPObjectiveFunctionObject other = (PCEPObjectiveFunctionObject) obj;
110 if (this.code != other.code)
112 if (this.tlvs == null) {
113 if (other.tlvs != null)
115 } else if (!this.tlvs.equals(other.tlvs))