> @@ -30,15 +34,7 @@
>     @Override
>     public void validate(Long partSizeInMB) throws IllegalArgumentException {
>        checkNotNull(partSizeInMB, "partSizeInMB");
> -      if (partSizeInMB < MIN_PART_SIZE || partSizeInMB > MAX_PART_SIZE || 
> (partSizeInMB & (partSizeInMB - 1)) != 0)
> -         throw exception(partSizeInMB, "partSizeInMB must be a power of 2 
> between 1 and 4096.");
> -   }
> -
> -   protected static IllegalArgumentException exception(Long size, String 
> reason) {
> -      return new IllegalArgumentException(
> -            String.format(
> -                  "Part size '%s' doesn't match Glacier Multipart upload 
> rules. "
> -                        + "Reason: %s. For more info, please refer to 
> http://http://docs.aws.amazon.com/amazonglacier/latest/dev/api-multipart-initiate-upload.html.";,
> -                  size, reason));
> +      checkArgument(!(partSizeInMB < MIN_PART_SIZE || partSizeInMB > 
> MAX_PART_SIZE || (partSizeInMB & (partSizeInMB - 1)) != 0),

You can write this more clearly with `Long.bitCount`.  Recent JDK optimize this 
into a single x86 POPCNT instruction on modern hardware.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-aws/pull/20/files#r14000767

Reply via email to