Skip to content

Instantly share code, notes, and snippets.

@php-coder
Created September 24, 2011 14:50
Show Gist options
  • Save php-coder/1239410 to your computer and use it in GitHub Desktop.
Save php-coder/1239410 to your computer and use it in GitHub Desktop.
Guava Preconditions class usage example
void setObject(Integer number) {
this.number = checkNotNull(number);
}
checkArgument(count > 0, "Invalid count %s: should be greater than zero", count);
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>10.0.1</version>
</dependency>
if (count <= 0) {
throw IllegalArgumentException("Count should be greater than zero");
}
import static com.google.common.base.Preconditions.checkArgument;
checkArgument(count > 0, "Count should be greater than zero");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment