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;
12 import org.opendaylight.protocol.framework.ProtocolMessage;
15 * Basic structure for PCEP Message. Cannot be instantiated directly. Current PCEP version is 1. Each message contains a
16 * list of PCEP objects.
19 public abstract class PCEPMessage implements ProtocolMessage {
21 private static final long serialVersionUID = 4293319459468168384L;
24 * Current supported version of PCEP.
26 public static final int PCEP_VERSION = 1;
28 private final List<PCEPObject> objects;
31 * Constructor is protected to prevent direct instantiation, but to allow to call this constructor via super().
35 protected PCEPMessage(final List<PCEPObject> objects) {
36 if (objects.contains(null))
37 throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
39 this.objects = objects;
43 * Returns list of all objects that the message contains
45 * @return list of all objects that the message contains
47 public List<PCEPObject> getAllObjects() {
52 public int hashCode() {
55 result = prime * result + ((this.objects == null) ? 0 : this.objects.hashCode());
60 public boolean equals(final Object obj) {
65 if (this.getClass() != obj.getClass())
67 final PCEPMessage other = (PCEPMessage) obj;
68 if (this.objects == null) {
69 if (other.objects != null)
71 } else if (!this.objects.equals(other.objects))
77 public String toString() {
78 final StringBuilder builder = new StringBuilder();
79 builder.append("PCEPMessage [objects=");
80 builder.append(this.objects);
82 return builder.toString();