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.");
46 this.notifications = notifications;
50 * Gets list of {@link org.opendaylight.protocol.pcep.object.CompositeNotifyObject CompositeNotifyObjects}.
52 * @return List<CompositeNotifyObject>. Can't be null or empty.
54 public List<CompositeNotifyObject> getNotifications() {
55 return this.notifications;
58 public List<PCEPObject> getAllObjects() {
63 public int hashCode() {
65 int result = super.hashCode();
66 result = prime * result + ((this.notifications == null) ? 0 : this.notifications.hashCode());
71 public boolean equals(final Object obj) {
74 if (!super.equals(obj))
76 if (this.getClass() != obj.getClass())
78 final PCEPNotificationMessage other = (PCEPNotificationMessage) obj;
79 if (this.notifications == null) {
80 if (other.notifications != null)
82 } else if (!this.notifications.equals(other.notifications))
88 public String toString() {
89 final StringBuilder builder = new StringBuilder();
90 builder.append("PCEPNotificationMessage [notifications=");
91 builder.append(this.notifications);
93 return builder.toString();