IllegalArgument Exception changed to Preconditions checks
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / message / PCEPNotificationMessageParser.java
index 626e172e2aab104d4b395a5ea285c043e155fc4b..307a62c7c0ffd2aa08a805941252c7ae2d8e0869 100644 (file)
@@ -51,9 +51,7 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                     serializeObject(rps.getRp(), buffer);
                 }
             }
-            if (n.getNotifications() == null || n.getNotifications().isEmpty()) {
-                throw new IllegalArgumentException("Message must contain at least one notification object");
-            }
+            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.rev131005.pcntf.message.pcntf.message.notifications.Notifications not : n.getNotifications()) {
                 serializeObject(not.getCNotification(), buffer);
             }
@@ -63,9 +61,7 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
 
     @Override
     protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
-        if (objects == null) {
-            throw new IllegalArgumentException("Passed list can't be null.");
-        }
+        Preconditions.checkArgument(objects != null, "Passed list can't be null.");
         if (objects.isEmpty()) {
             throw new PCEPDeserializerException("Notification message cannot be empty.");
         }