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.message;
10 import java.util.List;
12 import org.opendaylight.protocol.pcep.PCEPObject;
13 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
16 import com.google.common.collect.Lists;
19 * Structure of Open Message.
21 * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.2">Open Message</a>
23 public class PCEPOpenMessage implements Message {
25 private final PCEPOpenObject openObj;
27 private final List<PCEPObject> objects;
30 * Constructs new Open Message.
32 * @throws IllegalArgumentException if the PCEPOpenObject is null.
34 * @param openObj {@link PCEPOpenObject}. Can't be null.
36 public PCEPOpenMessage(final PCEPOpenObject openObj) {
37 this.objects = Lists.newArrayList();
38 if (openObj != null) {
39 this.objects.add(openObj);
41 throw new IllegalArgumentException("PCEPOpenObject is mandatory.");
44 this.openObj = openObj;
48 * Gets {@link PCEPOpenObject}
50 * @return {@link PCEPOpenObject}. Can't be null.
52 public PCEPOpenObject getOpenObject() {
56 public List<PCEPObject> getAllObjects() {
61 public int hashCode() {
63 int result = super.hashCode();
64 result = prime * result + ((this.openObj == null) ? 0 : this.openObj.hashCode());
69 public boolean equals(final Object obj) {
73 if (!super.equals(obj)) {
76 if (this.getClass() != obj.getClass()) {
79 final PCEPOpenMessage other = (PCEPOpenMessage) obj;
80 if (this.openObj == null) {
81 if (other.openObj != null) {
84 } else if (!this.openObj.equals(other.openObj)) {
91 public String toString() {
92 final StringBuilder builder = new StringBuilder();
93 builder.append("PCEPOpenMessage [openObj=");
94 builder.append(this.openObj);
96 return builder.toString();
100 public Class<Message> getImplementedInterface() {
101 return Message.class;