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();
39 this.objects.add(openObj);
41 throw new IllegalArgumentException("PCEPOpenObject is mandatory.");
43 this.openObj = openObj;
47 * Gets {@link PCEPOpenObject}
49 * @return {@link PCEPOpenObject}. Can't be null.
51 public PCEPOpenObject getOpenObject() {
55 public List<PCEPObject> getAllObjects() {
60 public int hashCode() {
62 int result = super.hashCode();
63 result = prime * result + ((this.openObj == null) ? 0 : this.openObj.hashCode());
68 public boolean equals(final Object obj) {
71 if (!super.equals(obj))
73 if (this.getClass() != obj.getClass())
75 final PCEPOpenMessage other = (PCEPOpenMessage) obj;
76 if (this.openObj == null) {
77 if (other.openObj != null)
79 } else if (!this.openObj.equals(other.openObj))
85 public String toString() {
86 final StringBuilder builder = new StringBuilder();
87 builder.append("PCEPOpenMessage [openObj=");
88 builder.append(this.openObj);
90 return builder.toString();