Skip to content

Instantly share code, notes, and snippets.

@jeffwf
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffwf/9629861 to your computer and use it in GitHub Desktop.
Save jeffwf/9629861 to your computer and use it in GitHub Desktop.
@Entity
public class Person {
@Value
private String firstName;
@Value
private String middleName;
@Value
private String lastName;
Person() {}
public Person(
String firstName,
Optional<String> middleName,
String lastName) {
Objects.requireNonNull(firstName);
Objects.requireNonNull(lastName);
this.firstName = firstName;
this.middleName = middleName.orNull();
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public Optional<String> getMiddleName() {
return Optional.fromNullable(middleName);
}
public String getLastName() {
return lastName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment