Created
April 8, 2015 21:38
-
-
Save jmbataller/55baf0cf067e66ae3d18 to your computer and use it in GitHub Desktop.
Builder pattern in Java 8
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
@FunctionalInterface | |
public interface ObjectEntitySetter extends Consumer<ObjectEntity> {} | |
public static ObjectEntity build(ObjectEntitySetter... ObjectEntitySetters) { | |
final ObjectEntity object = new ObjectEntity(); | |
Stream.of(ObjectEntitySetters).forEach( | |
s -> s.accept(object) | |
); | |
return object; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment