Skip to content

Instantly share code, notes, and snippets.

@theboreddev
Created June 9, 2020 16:44
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 theboreddev/9051b5b24569cd53af7f6d199628af6e to your computer and use it in GitHub Desktop.
Save theboreddev/9051b5b24569cd53af7f6d199628af6e to your computer and use it in GitHub Desktop.
wrongOptionalUse
static class Customer {
private final String firstName;
private final String surname;
private final Optional<Integer> age;
private final Optional<String> address;
private final Optional<String> phoneNumber;
private final Optional<Sex> sex;
public Customer(String firstName, String surname, Optional<Integer> age, Optional<String> address, Optional<String> phoneNumber, Optional<Sex> sex) {
this.firstName = firstName;
this.surname = surname;
this.age = age;
this.address = address;
this.phoneNumber = phoneNumber;
this.sex = sex;
}
public String getFirstName() {
return firstName;
}
public String getSurname() {
return surname;
}
public Optional<Integer> getAge() {
return age;
}
public Optional<String> getAddress() {
return address;
}
public Optional<String> getPhoneNumber() {
return phoneNumber;
}
public Optional<Sex> getSex() {
return sex;
}
}
static enum Sex {
FEMALE,
MALE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment