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;
10 import java.util.List;
13 * Basic structure for PCEP Message. Cannot be instantiated directly. Current PCEP version is 1. Each message contains a
14 * list of PCEP objects.
17 public abstract class PCEPMessage {
19 private static final long serialVersionUID = 4293319459468168384L;
22 * Current supported version of PCEP.
24 public static final int PCEP_VERSION = 1;
26 private final List<PCEPObject> objects;
29 * Constructor is protected to prevent direct instantiation, but to allow to call this constructor via super().
33 protected PCEPMessage(final List<PCEPObject> objects) {
34 if (objects.contains(null)) {
35 throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
38 this.objects = objects;
42 * Returns list of all objects that the message contains
44 * @return list of all objects that the message contains
46 public List<PCEPObject> getAllObjects() {
51 public int hashCode() {
54 result = prime * result + ((this.objects == null) ? 0 : this.objects.hashCode());
59 public boolean equals(final Object obj) {
66 if (this.getClass() != obj.getClass()) {
69 final PCEPMessage other = (PCEPMessage) obj;
70 if (this.objects == null) {
71 if (other.objects != null) {
74 } else if (!this.objects.equals(other.objects)) {
81 public String toString() {
82 final StringBuilder builder = new StringBuilder();
83 builder.append("PCEPMessage [objects=");
84 builder.append(this.objects);
86 return builder.toString();