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.");
41 this.objects = Lists.newArrayList();
42 for (final CompositeInstantiationObject cio : lsps) {
43 this.objects.addAll(cio.getCompositeAsList());
48 * Gets list of {@link CompositeStateReportObject}.
50 * @return List<CompositeStateReportObject>. Can't be null or empty.
52 public List<CompositeInstantiationObject> getLSPs() {
56 public List<PCEPObject> getAllObjects() {
61 * @see java.lang.Object#hashCode()
64 public int hashCode() {
66 int result = super.hashCode();
67 result = prime * result + ((this.lsps == null) ? 0 : this.lsps.hashCode());
72 * @see java.lang.Object#equals(java.lang.Object)
75 public boolean equals(final Object obj) {
79 if (!super.equals(obj)) {
82 if (!(obj instanceof PCCreateMessage)) {
85 final PCCreateMessage other = (PCCreateMessage) obj;
86 if (this.lsps == null) {
87 if (other.lsps != null) {
90 } else if (!this.lsps.equals(other.lsps)) {
97 * @see java.lang.Object#toString()
100 public String toString() {
101 final StringBuilder builder = new StringBuilder();
102 builder.append("PCCreateMessage [lsps=");
103 builder.append(this.lsps);
105 return builder.toString();
109 public Class<Message> getImplementedInterface() {
110 return Message.class;