GlenKPeterson / Paguro

Generic, Null-safe, Immutable Collections and Functional Transformations for the JVM
Other
312 stars 24 forks source link

Return of StaticImports.xform #14

Closed BrenoTrancoso closed 7 years ago

BrenoTrancoso commented 7 years ago

StaticImports:

public static <T> Transformable<T> xform(Iterable iterable); public static <T> Transformable<T> xformArray(T... items);

To

public static <T> Xform<T> xform(Iterable iterable); public static <T> Xform<T> xformArray(T... items);

GlenKPeterson commented 7 years ago

Thank you for your interest! What is the benefit of exposing the implementation instead of the interface? What do you need from Xform that you don't get from Transformable?

BrenoTrancoso commented 7 years ago

xform(new ArrayList<>()).forEach(x -> {}) -> forEach doesn't exists. Xform.of(new ArrayList<>()).forEach(x -> {}) -> forEach exists.

xform(new ArrayList()).flatMap(x -> xform(new ArrayList())) -> Type mismatch: cannot convert from Transformable to Iterable xform(new ArrayList()).flatMap(x -> Xform.of(new ArrayList())) -> OK

Maybe to public static <T> UnmodIterable<T> xform(Iterable iterable);

GlenKPeterson commented 7 years ago

Thank you for finding and reporting this. I really like your suggestion to use UnmodIterable instead of Transformable and have made that change as you suggest in Paguro 2.0.16.