Created
January 21, 2012 18:37
-
-
Save teigen/1653535 to your computer and use it in GitHub Desktop.
Java Lens api I just made up
This file contains 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
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