Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java 8 Supplier as withBuilderInterface #133

Closed
drekbour opened this issue Apr 25, 2017 · 3 comments
Closed

Support Java 8 Supplier as withBuilderInterface #133

drekbour opened this issue Apr 25, 2017 · 3 comments

Comments

@drekbour
Copy link
Contributor

PBs should be capable of implementing java.util.function.Supplier<T>. Currently I need to write:

/**
 * Supplier Facade for PojoBuilder.
 */
public interface SupplierBuilder<T> extends Supplier<T> {
    T build();

    default T get() {
        return build();
    }

    static <T> Collector<Supplier<T>, ?, List<T>> toSuppliedList() {
        return mapping(Supplier::get, toList());
    }

}

then give that as directive withBuilderInterface = SupplierBuilder.class

@mkarneim
Copy link
Owner

This looks perfectly good for me.
I would do it the same.

What exactly do you want to change about this?

@drekbour
Copy link
Contributor Author

Users don't want to have to have to write facades for this, however small. The value of PB over, say, and IDE-generated builder is the depth of features that can be added "just work".

withBuilderInterface = Supplier.class either as a special case (this is a language feature) or by generalising the public T build() check to public T <anything>()

@drekbour drekbour changed the title Support Java 8 Supplier functional interface Support Java 8 Supplier as withBuilderInterface Apr 26, 2017
@mkarneim
Copy link
Owner

Alright.
I will add support for 'builder' interfaces that hava a get() method as an alternative to build().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants