org.simpleflatmapper.map.context.impl.ValuedMappingContextFactory 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.context.impl;
import org.simpleflatmapper.map.MappingContext;
import org.simpleflatmapper.map.context.MappingContextFactory;
import org.simpleflatmapper.util.Supplier;
import java.util.List;
public class ValuedMappingContextFactory implements MappingContextFactory {
private final Supplier>[] suppliers;
public ValuedMappingContextFactory(List> suppliers) {
this.suppliers = suppliers.toArray(new Supplier[0]);
}
@Override
public MappingContext newContext() {
return new ValuedMappingContext(getObjects());
}
protected Object[] getObjects() {
Object[] values = new Object[suppliers.length];
for(int i = 0; i < suppliers.length; i ++) {
Supplier> s = suppliers[i];
if (s != null) {
values[i] = s.get();
}
}
return values;
}
}