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.CompositeNotifyObject;
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 Notification Message.
21 * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.6">Notification Message</a>
23 public class PCEPNotificationMessage implements Message {
25 private final List<CompositeNotifyObject> notifications;
27 private final List<PCEPObject> objects;
30 * Constructs new Notification Message.
32 * @throws IllegalArgumentException if there is not even one {@link CompositeNotifyObject} in the list.
34 * @param notifications List<CompositeNotifyObject>. Can't be empty or null.
36 public PCEPNotificationMessage(final List<CompositeNotifyObject> notifications) {
37 this.objects = Lists.newArrayList();
38 if (notifications != null) {
39 for (final CompositeNotifyObject cno : notifications) {
40 this.objects.addAll(cno.getCompositeAsList());
43 if (notifications == null || notifications.isEmpty()) {
44 throw new IllegalArgumentException("At least one CompositeNotifyObject is mandatory.");
47 this.notifications = notifications;
51 * Gets list of {@link org.opendaylight.protocol.pcep.object.CompositeNotifyObject CompositeNotifyObjects}.
53 * @return List<CompositeNotifyObject>. Can't be null or empty.
55 public List<CompositeNotifyObject> getNotifications() {
56 return this.notifications;
59 public List<PCEPObject> getAllObjects() {
64 public int hashCode() {
66 int result = super.hashCode();
67 result = prime * result + ((this.notifications == null) ? 0 : this.notifications.hashCode());
72 public boolean equals(final Object obj) {
76 if (!super.equals(obj)) {
79 if (this.getClass() != obj.getClass()) {
82 final PCEPNotificationMessage other = (PCEPNotificationMessage) obj;
83 if (this.notifications == null) {
84 if (other.notifications != null) {
87 } else if (!this.notifications.equals(other.notifications)) {
94 public String toString() {
95 final StringBuilder builder = new StringBuilder();
96 builder.append("PCEPNotificationMessage [notifications=");
97 builder.append(this.notifications);
99 return builder.toString();
103 public Class<Message> getImplementedInterface() {
104 return Message.class;