org.simpleflatmapper.map.impl.StaticMapperEnumerable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-map Show documentation
Show all versions of sfm-map Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
The newest version!
package org.simpleflatmapper.map.impl;
import org.simpleflatmapper.map.SourceMapper;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.util.Enumerable;
public class StaticMapperEnumerable implements Enumerable {
private final SourceMapper mapper;
private final MappingContext super S> mappingContext;
private final Enumerable sourceEnumerable;
private T currentValue;
public StaticMapperEnumerable(SourceMapper mapper,
MappingContext super S> mappingContext,
Enumerable sourceEnumerable) {
this.mapper = mapper;
this.mappingContext = mappingContext;
this.sourceEnumerable = sourceEnumerable;
}
@Override
public boolean next() {
if (sourceEnumerable.next()) {
currentValue = mapper.map(sourceEnumerable.currentValue(), mappingContext);
return true;
} else return false;
}
@Override
public T currentValue() {
return currentValue;
}
@Override
public String toString() {
return "StaticMapperEnumerable{" +
"jdbcMapper=" + mapper +
'}';
}
}