IllegalArgument Exception changed to Preconditions checks
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / message / PCEPReplyMessageParser.java
index d948fcf0eefdf35bb68b8b6ce5c35355d72b0bd0..baec04d8e54b6a571c31475892b2fc1bd6b02525 100644 (file)
@@ -66,14 +66,10 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
     public void serializeMessage(final Message message, final ByteBuf out) {
         Preconditions.checkArgument(message instanceof Pcrep, "Wrong instance of Message. Passed instance of %s. Need Pcrep.", message.getClass());
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.PcrepMessage repMsg = ((Pcrep) message).getPcrepMessage();
-        if (repMsg.getReplies() == null || repMsg.getReplies().isEmpty()) {
-            throw new IllegalArgumentException("Replies cannot be null or empty.");
-        }
+        Preconditions.checkArgument(repMsg.getReplies() != null && !repMsg.getReplies().isEmpty(), "Replies cannot be null or empty.");
         final ByteBuf buffer = Unpooled.buffer();
         for (final Replies reply : repMsg.getReplies()) {
-            if (reply.getRp() == null) {
-                throw new IllegalArgumentException("Reply must contain RP object.");
-            }
+            Preconditions.checkArgument(reply.getRp() != null, "Reply must contain RP object.");
             serializeReply(reply, buffer);
         }
         MessageUtil.formatMessage(TYPE, buffer, out);
@@ -152,9 +148,7 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
 
     @Override
     protected Pcrep 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("Pcrep message cannot be empty.");
         }