All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleflatmapper.map.TransformEnumerable Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.map;

import org.simpleflatmapper.util.Enumerable;
import org.simpleflatmapper.util.Function;

public class TransformEnumerable implements Enumerable {

    private final Enumerable delegate;
    private final Function transformer;


    public TransformEnumerable(Enumerable delegate, Function transformer) {
        this.delegate = delegate;
        this.transformer = transformer;
    }

    @Override
    public boolean next() {
        return delegate.next();
    }

    @Override
    public O currentValue() {
        return transformer.apply(delegate.currentValue());
    }

    @Override
    public String toString() {
        return "TransformEnumerable{" +
                "delegate=" + delegate +
                ", transformer=" + transformer +
                '}';
    }
}