Skip to content

Instantly share code, notes, and snippets.

@wfaler
Created March 8, 2014 14:34
Show Gist options
  • Save wfaler/9431370 to your computer and use it in GitHub Desktop.
Save wfaler/9431370 to your computer and use it in GitHub Desktop.
ImmutableBean
public final class ImmutableBean{
public final String name;
public final Integer age;
public ImmutableBean(String name, Integer age){
if(name == null || name.length < 1 || age == null || age < 0)
throw new IllegalArgumentException("name must be set and age must be 0 or over");
this.name = name;
this.age = age;
}
// implement equals, toString and hashCode as well!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment