From 004c160aacc4a762f6e6e3217979e88639855ff1 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 16 Apr 2012 13:47:50 -0700 Subject: [PATCH] Prefer checkNotNull when appropriate Calling checkNotNull on parameters better captures our intent. --- .../strategy/impl/AdaptingComputeServiceStrategies.java | 8 ++++---- core/src/main/java/org/jclouds/io/Payloads.java | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index 88a91a9722..2e232caf11 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -162,10 +162,10 @@ public class AdaptingComputeServiceStrategies implements CreateNodeW */ @Override public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { - checkState(group != null, "group (that which groups identical nodes together) must be specified"); - checkState(name != null && name.indexOf(group) != -1, "name should have %s encoded into it", group); - checkState(template != null, "template was null"); - checkState(template.getOptions() != null, "template options was null"); + checkNotNull(group, "group (that which groups identical nodes together) must be specified"); + checkNotNull(name, "name should have %s encoded into it", group); + checkNotNull(template, "template was null"); + checkNotNull(template.getOptions(), "template options was null"); NodeAndInitialCredentials from = client.createNodeWithGroupEncodedIntoName(group, name, template); LoginCredentials fromNode = from.getCredentials(); diff --git a/core/src/main/java/org/jclouds/io/Payloads.java b/core/src/main/java/org/jclouds/io/Payloads.java index ca2a6ed7b0..0fe038fb74 100644 --- a/core/src/main/java/org/jclouds/io/Payloads.java +++ b/core/src/main/java/org/jclouds/io/Payloads.java @@ -19,7 +19,6 @@ package org.jclouds.io; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static com.google.common.io.ByteStreams.toByteArray; import java.io.File; @@ -141,7 +140,7 @@ public class Payloads { * @see #calculateMD5(Payload, MessageDigest) */ public static T calculateMD5(T payloadEnclosing, MessageDigest md5) throws IOException { - checkState(payloadEnclosing != null, "payloadEnclosing"); + checkNotNull(payloadEnclosing, "payloadEnclosing"); Payload newPayload = calculateMD5(payloadEnclosing.getPayload(), md5); if (newPayload != payloadEnclosing.getPayload()) payloadEnclosing.setPayload(newPayload);