org.simpleflatmapper.map.context.impl.ValuedMappingContextFactory Maven / Gradle / Ivy
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;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy