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

org.sfm.map.MappingContext 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: 1.10.3
Show newest version
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();
            }
        }
    }


}