Clean pcep/base-parser code
[bgpcep.git] / pcep / base-parser / src / main / java / org / opendaylight / protocol / pcep / parser / message / PCEPNotificationMessageParser.java
index ccf6e2cb3e2de11758f1b88d48a252821495b91c..f0eda243e9411928a0a047f8f9800215ae11cc32 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp;
 
 /**
- * Parser for {@link PcntfMessage}
+ * Parser for {@link PcntfMessage}.
  */
 public class PCEPNotificationMessageParser extends AbstractMessageParser {
 
@@ -43,7 +43,8 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
 
     @Override
     public void serializeMessage(final Message message, final ByteBuf out) {
-        Preconditions.checkArgument(message instanceof PcntfMessage, "Wrong instance of Message. Passed instance of %s. Need PcntfMessage.", message.getClass());
+        Preconditions.checkArgument(message instanceof PcntfMessage,
+                "Wrong instance of Message. Passed instance of %s. Need PcntfMessage.", message.getClass());
         final ByteBuf buffer = Unpooled.buffer();
         for (final Notifications n : ((PcntfMessage) message).getPcntfMessage().getNotifications()) {
             if (n.getRps() != null) {
@@ -51,8 +52,10 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                     serializeObject(rps.getRp(), buffer);
                 }
             }
-            Preconditions.checkArgument(n.getNotifications() != null && !n.getNotifications().isEmpty(), "Message must contain at least one notification object");
-            for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications not : n.getNotifications()) {
+            Preconditions.checkArgument(n.getNotifications() != null && !n.getNotifications().isEmpty(),
+                    "Message must contain at least one notification object");
+            for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+                    .message.pcntf.message.notifications.Notifications not : n.getNotifications()) {
                 serializeObject(not.getCNotification(), buffer);
             }
         }
@@ -60,7 +63,8 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
     }
 
     @Override
-    protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
+    protected Message validate(final List<Object> objects, final List<Message> errors)
+            throws PCEPDeserializerException {
         Preconditions.checkArgument(objects != null, "Passed list can't be null.");
         if (objects.isEmpty()) {
             throw new PCEPDeserializerException("Notification message cannot be empty.");
@@ -81,12 +85,14 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
         if (!objects.isEmpty()) {
             throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
         }
-        return new PcntfBuilder().setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
+        return new PcntfBuilder()
+                .setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
     }
 
     private static Notifications getValidNotificationComposite(final List<Object> objects, final List<Message> errors) {
         final List<Rps> requestParameters = new ArrayList<>();
-        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications> notifications = new ArrayList<>();
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+            .message.pcntf.message.notifications.Notifications> notifications = new ArrayList<>();
         Object obj;
 
         State state = State.INIT;
@@ -104,11 +110,15 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
             return null;
         }
 
-        return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.NotificationsBuilder().setNotifications(
-                notifications).setRps(requestParameters).build();
+        return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+                .message.pcntf.message.NotificationsBuilder().setNotifications(notifications)
+                .setRps(requestParameters).build();
     }
 
-    private static State insertObject(final State state, final Object obj, final List<Message> errors, final List<Rps> requestParameters, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications> notifications) {
+    private static State insertObject(final State state, final Object obj, final List<Message> errors,
+            final List<Rps> requestParameters,
+            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+                .message.pcntf.message.notifications.Notifications> notifications) {
         switch (state) {
             case INIT:
                 if (obj instanceof Rp) {
@@ -120,16 +130,15 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                     requestParameters.add(new RpsBuilder().setRp(rp).build());
                     return State.INIT;
                 }
-                // fall-through
+                // fallthrough
             case RP_IN:
                 if (obj instanceof CNotification) {
                     final CNotification n = (CNotification) obj;
                     notifications.add(new NotificationsBuilder().setCNotification(n).build());
                     return State.RP_IN;
                 }
-                // fall-through
+                // fallthrough
             case NOTIFICATION_IN:
-                // fall-through
             case END:
                 return State.END;
             default: