BUG-47 : removed PCEPMessage interface, switched to generated Message.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / PCEPMessageFactory.java
index 10bc6ecc9d6b4038096f4b93ac6ab9d4f7ef9ed9..99ee06896443bf509d0cfd8850079e4d2c2f5f22 100644 (file)
@@ -14,23 +14,23 @@ import org.opendaylight.protocol.framework.DeserializerException;
 import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.spi.RawMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 import com.google.common.base.Preconditions;
 
 /**
  * A PCEP message parser which also does validation.
  */
-public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
+public final class PCEPMessageFactory implements ProtocolMessageFactory<Message> {
        private static final RawPCEPMessageFactory rawFactory = new RawPCEPMessageFactory();
 
        @Override
-       public List<PCEPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
-               final List<PCEPMessage> parsed = rawFactory.parse(bytes);
-               final List<PCEPMessage> validated = new ArrayList<>(parsed.size());
+       public List<Message> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+               final List<Message> parsed = rawFactory.parse(bytes);
+               final List<Message> validated = new ArrayList<>(parsed.size());
 
-               for (PCEPMessage msg : parsed) {
+               for (final Message msg : parsed) {
                        Preconditions.checkState(msg instanceof RawMessage);
                        final RawMessage raw = (RawMessage) msg;
 
@@ -38,7 +38,7 @@ public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMess
                                validated.addAll(PCEPMessageValidator.getValidator(raw.getMsgType()).validate(raw.getAllObjects()));
                        } catch (final PCEPDeserializerException e) {
                                // FIXME: at validation time we may want to terminate with:
-                               //logger.error("Malformed message, terminating. ", e);
+                               // logger.error("Malformed message, terminating. ", e);
                                // this.terminate(Reason.MALFORMED_MSG);
                                throw e;
                        }
@@ -48,7 +48,7 @@ public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMess
        }
 
        @Override
-       public byte[] put(final PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                return rawFactory.put(msg);
        }
 }