org.sfm.map.MappingContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.map;
import org.sfm.jdbc.impl.BreakDetector;
public class MappingContext {
private final BreakDetector[] breakDetectors;
private final BreakDetector rootDetector;
public MappingContext(BreakDetector[] breakDetectors, BreakDetector rootDetector) {
this.breakDetectors = breakDetectors;
this.rootDetector = rootDetector;
}
public BreakDetector getBreakDetector(int i) {
return breakDetectors[i];
}
public boolean broke(int i) {
return getBreakDetector(i).isBroken();
}
public boolean rootBroke() {
return rootDetector == null || rootDetector.isBroken();
}
public void handle(S source) {
for(BreakDetector bs : breakDetectors) {
if (bs != null) {
bs.handle(source);
}
}
}
public void markAsBroken() {
for(BreakDetector bs : breakDetectors) {
if (bs != null) {
bs.markAsBroken();
}
}
}
}