Skip to content

Instantly share code, notes, and snippets.

@teigen
Created January 21, 2012 18:37
Show Gist options
  • Save teigen/1653535 to your computer and use it in GitHub Desktop.
Save teigen/1653535 to your computer and use it in GitHub Desktop.
Java Lens api I just made up
Lens<Person, Address> personAddressLens = new LensApiThatIJustMadeUp<Person, Address>(){
@Override
public Address get(@Nullable Person person) {
return person.getAddress();
}
@Override
public Person set(Person person, Address address) {
return new Person(person.getFirstName(), person.getLastName(), address);
}
};
Person person = new Person("Jack", "Smith", new Address("Default", "Default", "Default", 0));
Lens<Person, Integer> personZipCodeLens = personAddressLens.andThen(addressZipCodeLens);
personZipCodeLens.set(person, personZipCodeLens.get(person) + 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment