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