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

org.simpleflatmapper.util.TupleHelper 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.util;

import java.lang.reflect.Type;

public class TupleHelper {

    private TupleHelper() {}

    public static boolean isTuple(Type type) {
        return isSfmTuple(type) || isJoolTuple(type) || isKotlinTuple(type);
    }

    private static boolean isKotlinTuple(Type type) {
        String className = TypeHelper.toClass(type).getName();
        return className.equals("kotlin.Pair") || className.equals("kotlin.Triple");
    }

    public static boolean isSfmTuple(Type type) {
        String className = TypeHelper.toClass(type).getName();
        return className.startsWith("org.simpleflatmapper.tuple.Tuple")
                && !className.endsWith("Tuples");
    }

    public static boolean isJoolTuple(Type type) {
        Class clazz = TypeHelper.toClass(type);
        while(clazz != null) {
            for(Class i : clazz.getInterfaces()) {
                if ("org.jooq.lambda.tuple.Tuple".equals(i.getName())) {
                    return true;
                }
            }
            clazz = clazz.getSuperclass();
        }
        return false;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy