Skip to content

Instantly share code, notes, and snippets.

@jmbataller
Created April 8, 2015 21:38
Show Gist options
  • Save jmbataller/55baf0cf067e66ae3d18 to your computer and use it in GitHub Desktop.
Save jmbataller/55baf0cf067e66ae3d18 to your computer and use it in GitHub Desktop.
Builder pattern in Java 8
@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