Remove instance-level mapping function (in ReactiveMapper1) in favor of static Mapper.fromTuple()
@@ -23,32 +23,25 @@ import org.immutables.criteria.repository.Mappers;
import org.reactivestreams.Publisher;
import java.util.Optional;
-import java.util.function.Function;
public class ReactiveMapper1<T1> extends ReactiveFetcher<T1> {
private final Query query;
private final Backend.Session session;
- private final Function<ProjectedTuple, ?> mapFn;
public ReactiveMapper1(Query query, Backend.Session session) {
super(query, session);
this.query = query;
this.session = session;
- this.mapFn = Mappers.fromTuple();
}
public ReactiveFetcher<Optional<T1>> asOptional() {
- @SuppressWarnings("unchecked")
- Function<ProjectedTuple, T1> mapFn = (Function<ProjectedTuple, T1>) this.mapFn;
- return new ReactiveFetcher<ProjectedTuple>(query, session).map(mapFn.andThen(Optional::ofNullable));
+ return new ReactiveFetcher<ProjectedTuple>(query, session).map(Mappers.<T1>fromTuple().andThen(Optional::ofNullable));
}
@Override
public Publisher<T1> fetch() {
- @SuppressWarnings("unchecked")
- Function<ProjectedTuple, T1> mapFn = (Function<ProjectedTuple, T1>) this.mapFn;
- return new ReactiveFetcher<ProjectedTuple>(query, session).map(mapFn).fetch();
+ return new ReactiveFetcher<ProjectedTuple>(query, session).map(Mappers.<T1>fromTuple()).fetch();
}
}
