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

org.simpleflatmapper.reflect.meta.ArrayAliasProvider Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

The newest version!
package org.simpleflatmapper.reflect.meta;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;

public class ArrayAliasProvider implements AliasProvider {
    private final AliasProvider[] providers;

    public ArrayAliasProvider(AliasProvider... providers) {
        this.providers = providers;
    }

    @Override
    public String getAliasForMethod(Method method) {
        for(AliasProvider ap : providers) {
            String alias = ap.getAliasForMethod(method);
            if (alias != null) return alias;
        }
        return null;
    }

    @Override
    public String getAliasForField(Field field) {
        for(AliasProvider ap : providers) {
            String alias = ap.getAliasForField(field);
            if (alias != null) return alias;
        }
        return null;
    }

    @Override
    public Table getTable(Class target) {
        for(AliasProvider ap : providers) {
            Table table = ap.getTable(target);
            if (! Table.isNull(table)) return table;
        }
        return Table.NULL;
    }

    public AliasProvider[] providers() {
        return Arrays.copyOf(providers, providers.length);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy