Created
March 8, 2014 14:34
-
-
Save wfaler/9431370 to your computer and use it in GitHub Desktop.
ImmutableBean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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