
com.miragesql.miragesql.util.ReflectionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of miragesql Show documentation
Show all versions of miragesql Show documentation
Mirage-SQL is an easy and powerful SQL centric database access library for Java (or JVM based languages) which provides dynamic SQL templates in plain SQL files.
package com.miragesql.miragesql.util;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
public class ReflectionUtil {
public static Field getField(Class> clazz, String name){
while(clazz != Object.class){
try {
Field field = clazz.getDeclaredField(name);
if(field != null){
return field;
}
} catch(Exception ex){
// ignore
}
clazz = clazz.getSuperclass();
}
return null;
}
public static Class> getElementTypeOfList(final Type parameterizedList) {
return GenericUtil.getRawClass(GenericUtil
.getElementTypeOfList(parameterizedList));
}
public static Class> getElementTypeOfListFromFieldType(final Field field) {
final Type type = field.getGenericType();
return getElementTypeOfList(type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy