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.CompositeInstantiationObject;
14 import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
17 import com.google.common.collect.Lists;
20 * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1. The LSP Create Message</a>
22 public class PCCreateMessage implements Message {
24 private final List<CompositeInstantiationObject> lsps;
26 private final List<PCEPObject> objects;
29 * Constructs {@link PCCreateMessage}.
31 * @throws IllegalArgumentException if there is not even one {@link CompositeInstantiationObject} in the list.
33 * @param lsps List<CompositeInstantiationObject>. Can't be empty or null.
35 public PCCreateMessage(final List<CompositeInstantiationObject> lsps) {
36 if (lsps == null || lsps.isEmpty())
37 throw new IllegalArgumentException("At least one CompositeStateReportObject is mandatory.");
40 this.objects = Lists.newArrayList();
41 for (final CompositeInstantiationObject cio : lsps) {
42 this.objects.addAll(cio.getCompositeAsList());
47 * Gets list of {@link CompositeStateReportObject}.
49 * @return List<CompositeStateReportObject>. Can't be null or empty.
51 public List<CompositeInstantiationObject> getLSPs() {
55 public List<PCEPObject> getAllObjects() {
60 * @see java.lang.Object#hashCode()
63 public int hashCode() {
65 int result = super.hashCode();
66 result = prime * result + ((this.lsps == null) ? 0 : this.lsps.hashCode());
71 * @see java.lang.Object#equals(java.lang.Object)
74 public boolean equals(final Object obj) {
77 if (!super.equals(obj))
79 if (!(obj instanceof PCCreateMessage))
81 final PCCreateMessage other = (PCCreateMessage) obj;
82 if (this.lsps == null) {
83 if (other.lsps != null)
85 } else if (!this.lsps.equals(other.lsps))
91 * @see java.lang.Object#toString()
94 public String toString() {
95 final StringBuilder builder = new StringBuilder();
96 builder.append("PCCreateMessage [lsps=");
97 builder.append(this.lsps);
99 return builder.toString();