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.PCEPErrors;
14 import org.opendaylight.protocol.pcep.PCEPObject;
15 import org.opendaylight.protocol.pcep.PCEPTlv;
16 import com.google.common.base.Objects.ToStringHelper;
19 * Structure of PCEP Error Object.
21 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.15">PCEP Error
24 public class PCEPErrorObject extends PCEPObject {
26 private final PCEPErrors error;
28 private final List<PCEPTlv> tlvs;
31 * Constructs Error Object only with mandatory object.
34 * PCEPErrors. Can't be null.
36 public PCEPErrorObject(PCEPErrors type) {
41 * Constructs Error Object also with optional objects.
44 * PCEPErrors. Can't be null
48 public PCEPErrorObject(PCEPErrors type, List<PCEPTlv> tlvs) {
54 this.tlvs = Collections.emptyList();
58 * Gets {@link PCEPErrors}
60 * @return PCEPErrors. Can't be null.
62 public PCEPErrors getError() {
67 * Gets list of {@link PCEPTlv}
69 * @return List<PCEPTlv>. Can't be null, but may be empty.
71 public List<PCEPTlv> getTlvs() {
76 public int hashCode() {
78 int result = super.hashCode();
79 result = prime * result + ((this.error == null) ? 0 : this.error.hashCode());
80 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
85 public boolean equals(Object obj) {
88 if (!super.equals(obj))
90 if (this.getClass() != obj.getClass())
92 final PCEPErrorObject other = (PCEPErrorObject) obj;
93 if (this.error != other.error)
95 if (this.tlvs == null) {
96 if (other.tlvs != null)
98 } else if (!this.tlvs.equals(other.tlvs))
104 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
105 toStringHelper.add("error", this.error);
106 toStringHelper.add("tlvs", this.tlvs);
107 return super.addToStringAttributes(toStringHelper);