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

org.simpleflatmapper.converter.ComposedContextualConverter 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: 9.0.2
Show newest version
package org.simpleflatmapper.converter;

public class ComposedContextualConverter implements ContextualConverter {

    public final ContextualConverter c1;
    public final ContextualConverter c2;

    public ComposedContextualConverter(ContextualConverter c1, ContextualConverter c2) {
        if (c1 == null || c2 == null)
            throw new NullPointerException();
        this.c1 = c1;
        this.c2 = c2;
    }


    @Override
    public O convert(I in, Context context) throws Exception {
        return c2.convert(c1.convert(in, context), context);
    }

    @Override
    public String toString() {
        return "ComposedConverter{" +
                "c1=" + c1 +
                ", c2=" + c2 +
                '}';
    }
    
    public int depth() {
        int i = 2;
        if (c1 instanceof ComposedContextualConverter) {
            i += ((ComposedContextualConverter) c1).depth();
        }
        if (c2 instanceof ComposedContextualConverter) {
            i += ((ComposedContextualConverter) c2).depth();
        }
        return i;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy