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.CompositeUpdateRequestObject;
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 Update Request Message.
21 * @see <a href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.2">Update Request Message</a>
23 public class PCEPUpdateRequestMessage implements Message {
25 private final List<CompositeUpdateRequestObject> updateRequests;
27 private final List<PCEPObject> objects;
30 * Constructs new Update Request Message.
32 * @throws IllegalArgumentException if there is not even one {@link CompositeUpdateRequestObject} in the list.
34 * @param updateRequests List<CompositeUpdateRequestObject>. Can't be empty or null.
36 public PCEPUpdateRequestMessage(final List<CompositeUpdateRequestObject> updateRequests) {
37 this.objects = Lists.newArrayList();
38 if (updateRequests != null)
39 for (final CompositeUpdateRequestObject curo : updateRequests) {
40 this.objects.addAll(curo.getCompositeAsList());
43 if (updateRequests == null || updateRequests.isEmpty())
44 throw new IllegalArgumentException("At least one CompositeUpdateRequestObject is mandatory.");
45 this.updateRequests = updateRequests;
49 * Gets list of {@link CompositeUpdateRequestObject}.
51 * @return List<CompositeUpdateRequestObject>. Can't be null or empty.
53 public List<CompositeUpdateRequestObject> getUpdateRequests() {
54 return this.updateRequests;
57 public List<PCEPObject> getAllObjects() {
62 public int hashCode() {
64 int result = super.hashCode();
65 result = prime * result + ((this.updateRequests == null) ? 0 : this.updateRequests.hashCode());
70 public boolean equals(final Object obj) {
73 if (!super.equals(obj))
75 if (this.getClass() != obj.getClass())
77 final PCEPUpdateRequestMessage other = (PCEPUpdateRequestMessage) obj;
78 if (this.updateRequests == null) {
79 if (other.updateRequests != null)
81 } else if (!this.updateRequests.equals(other.updateRequests))
87 public String toString() {
88 final StringBuilder builder = new StringBuilder();
89 builder.append("PCEPUpdateRequestMessage [updateRequests=");
90 builder.append(this.updateRequests);
92 return builder.toString();