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.PCEPCloseObject;
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 Close Message.
21 * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close Message</a>
23 public class PCEPCloseMessage implements Message {
25 private final PCEPCloseObject closeObj;
27 private final List<PCEPObject> objects;
30 * Constructs a new Close Message, which has to include PCEP Close Object. Is used to close an established session
33 * @throws IllegalArgumentException if the CloseObject passed, is null.
35 * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close Message</a>
37 * @param closeObj Can't be null.
39 public PCEPCloseMessage(final PCEPCloseObject closeObj) {
41 throw new IllegalArgumentException("PCEPCloseObject is mandatory. Can't be null.");
43 this.closeObj = closeObj;
44 this.objects = Lists.newArrayList();
46 this.objects.add(closeObj);
50 * Gets {@link PCEPCloseObject}, which is mandatory object of PCEP Close Message.
52 * @return {@link PCEPCloseObject} . Can't be null.
54 public PCEPCloseObject getCloseObject() {
58 public List<PCEPObject> getAllObjects() {
63 public int hashCode() {
65 int result = super.hashCode();
66 result = prime * result + ((this.closeObj == null) ? 0 : this.closeObj.hashCode());
71 public boolean equals(final Object obj) {
74 if (!super.equals(obj))
76 if (this.getClass() != obj.getClass())
78 final PCEPCloseMessage other = (PCEPCloseMessage) obj;
79 if (this.closeObj == null) {
80 if (other.closeObj != null)
82 } else if (!this.closeObj.equals(other.closeObj))
88 public String toString() {
89 final StringBuilder builder = new StringBuilder();
90 builder.append("PCEPCloseMessage [closeObj=");
91 builder.append(this.closeObj);
93 return builder.toString();