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.ArrayList;
11 import java.util.List;
13 import org.opendaylight.protocol.pcep.PCEPMessage;
14 import org.opendaylight.protocol.pcep.PCEPObject;
15 import org.opendaylight.protocol.pcep.object.CompositeUpdateRequestObject;
18 * Structure of Update Request Message.
21 * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.2">Update
24 public class PCEPUpdateRequestMessage extends PCEPMessage {
26 private static final long serialVersionUID = 3577204028363946097L;
28 private final List<CompositeUpdateRequestObject> updateRequests;
31 * Constructs new Update Request Message.
33 * @throws IllegalArgumentException
34 * if there is not even one {@link CompositeUpdateRequestObject}
37 * @param updateRequests
38 * List<CompositeUpdateRequestObject>. Can't be empty or null.
40 public PCEPUpdateRequestMessage(final List<CompositeUpdateRequestObject> updateRequests) {
41 super(new ArrayList<PCEPObject>() {
43 private static final long serialVersionUID = 8591736379229064997L;
46 if (updateRequests != null)
47 for (final CompositeUpdateRequestObject curo : updateRequests) {
48 this.addAll(curo.getCompositeAsList());
53 if (updateRequests == null || updateRequests.isEmpty())
54 throw new IllegalArgumentException("At least one CompositeUpdateRequestObject is mandatory.");
55 this.updateRequests = updateRequests;
59 * Gets list of {@link CompositeUpdateRequestObject}.
61 * @return List<CompositeUpdateRequestObject>. Can't be null or empty.
63 public List<CompositeUpdateRequestObject> getUpdateRequests() {
64 return this.updateRequests;
68 public int hashCode() {
70 int result = super.hashCode();
71 result = prime * result + ((this.updateRequests == null) ? 0 : this.updateRequests.hashCode());
76 public boolean equals(Object obj) {
79 if (!super.equals(obj))
81 if (this.getClass() != obj.getClass())
83 final PCEPUpdateRequestMessage other = (PCEPUpdateRequestMessage) obj;
84 if (this.updateRequests == null) {
85 if (other.updateRequests != null)
87 } else if (!this.updateRequests.equals(other.updateRequests))
93 public String toString() {
94 final StringBuilder builder = new StringBuilder();
95 builder.append("PCEPUpdateRequestMessage [updateRequests=");
96 builder.append(this.updateRequests);
98 return builder.toString();