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) {
40 if (closeObj == null) {
41 throw new IllegalArgumentException("PCEPCloseObject is mandatory. Can't be null.");
44 this.closeObj = closeObj;
45 this.objects = Lists.newArrayList();
46 if (closeObj != null) {
47 this.objects.add(closeObj);
52 * Gets {@link PCEPCloseObject}, which is mandatory object of PCEP Close Message.
54 * @return {@link PCEPCloseObject} . Can't be null.
56 public PCEPCloseObject getCloseObject() {
60 public List<PCEPObject> getAllObjects() {
65 public int hashCode() {
67 int result = super.hashCode();
68 result = prime * result + ((this.closeObj == null) ? 0 : this.closeObj.hashCode());
73 public boolean equals(final Object obj) {
77 if (!super.equals(obj)) {
80 if (this.getClass() != obj.getClass()) {
83 final PCEPCloseMessage other = (PCEPCloseMessage) obj;
84 if (this.closeObj == null) {
85 if (other.closeObj != null) {
88 } else if (!this.closeObj.equals(other.closeObj)) {
95 public String toString() {
96 final StringBuilder builder = new StringBuilder();
97 builder.append("PCEPCloseMessage [closeObj=");
98 builder.append(this.closeObj);
100 return builder.toString();
104 public Class<Message> getImplementedInterface() {
105 return Message.class;