BUG-47 : removed PCEPMessage interface, switched to generated Message.
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / message / PCCreateMessage.java
index df64f480d2bb53d7d5edb60a5a2cd1afdb17d425..b12b6bdec0b1e1b2f7d0061a5ab544461f291a01 100644 (file)
@@ -7,60 +7,55 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeInstantiationObject;
 import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
- * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1.  The LSP Create Message</a>
+ * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1. The LSP Create Message</a>
  */
-public class PCCreateMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -2407399568579836171L;
+public class PCCreateMessage implements Message {
 
        private final List<CompositeInstantiationObject> lsps;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs {@link PCCreateMessage}.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeInstantiationObject}
-        *             in the list.
-        *
-        * @param lsps
-        *            List<CompositeInstantiationObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeInstantiationObject} in the list.
+        * 
+        * @param lsps List<CompositeInstantiationObject>. Can't be empty or null.
         */
        public PCCreateMessage(final List<CompositeInstantiationObject> lsps) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               if (lsps != null)
-                                       for (final CompositeInstantiationObject cio : lsps) {
-                                               this.addAll(cio.getCompositeAsList());
-                                       }
-                       }
-               });
                if (lsps == null || lsps.isEmpty())
                        throw new IllegalArgumentException("At least one CompositeStateReportObject is mandatory.");
 
                this.lsps = lsps;
+               this.objects = Lists.newArrayList();
+               for (final CompositeInstantiationObject cio : lsps) {
+                       this.objects.addAll(cio.getCompositeAsList());
+               }
        }
 
        /**
         * Gets list of {@link CompositeStateReportObject}.
-        *
+        * 
         * @return List<CompositeStateReportObject>. Can't be null or empty.
         */
        public List<CompositeInstantiationObject> getLSPs() {
                return this.lsps;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        /* (non-Javadoc)
         * @see java.lang.Object#hashCode()
         */
@@ -76,7 +71,7 @@ public class PCCreateMessage extends PCEPMessage {
         * @see java.lang.Object#equals(java.lang.Object)
         */
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))