@@ -0,0 +1,3009 @@
+package com.github.aureliano.almamater.core.helper;%0A%0Aimport static org.reflections.ReflectionUtils.getAllFields;%0Aimport static org.reflections.ReflectionUtils.withName;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.lang.reflect.Method;%0Aimport java.lang.reflect.ParameterizedType;%0Aimport java.util.Collection;%0Aimport java.util.Set;%0A%0Aimport org.reflections.ReflectionUtils;%0A%0Aimport com.github.aureliano.almamater.core.exception.AlmaMaterException;%0A%0Apublic class ReflectionHelper %7B%0A%0A    @SuppressWarnings(%22unchecked%22)%0A%09public static Field getField(Class%3C?%3E clazz, String fieldName) %7B%0A        Set%3CField%3E fields = getAllFields(clazz, withName(fieldName));%0A        if (fields.size() != 1) %7B%0A        %09throw new AlmaMaterException(String.format(%22Unable to find field %25s for class %25s%22, fieldName, clazz.getSimpleName()));%0A        %7D%0A        Field field = fields.iterator().next();%0A        field.setAccessible(true);%0A        return field;%0A    %7D%0A%0A    public static Object getFieldValue(Object object, String fieldName) %7B%0A        Field field = getField(object.getClass(), fieldName);%0A        return getFieldValue(object, field);%0A    %7D%0A%0A    public static Object getFieldValue(Object object, Field field) %7B%0A        try %7B%0A            field.setAccessible(true);%0A            return field.get(object);%0A        %7D catch (IllegalAccessException ex) %7B%0A            throw new AlmaMaterException(ex);%0A        %7D%0A    %7D%0A%0A    public static Class%3C?%3E getGenericType(Field field) %7B%0A        if (!Collection.class.isAssignableFrom(field.getType())) %7B%0A            return field.getType();%0A        %7D%0A        ParameterizedType type = (ParameterizedType) field.getGenericType();%0A        return (Class%3C?%3E) type.getActualTypeArguments()%5B0%5D;%0A    %7D%0A%0A    public static Class%3C?%3E getGenericType(Method method) %7B%0A        if (!Collection.class.isAssignableFrom(method.getReturnType())) %7B%0A            return method.getReturnType();%0A        %7D%0A        ParameterizedType type = (ParameterizedType) method.getGenericReturnType();%0A        return (Class%3C?%3E) type.getActualTypeArguments()%5B0%5D;%0A    %7D%0A    %0A    public static Object callMethod(Object object, String methodName, Class%3C?%3E%5B%5D parametersType, Object%5B%5D methodParameters) %7B%0A    %09Class%3C?%3E clazz = object.getClass();%0A    %09try %7B%0A    %09%09Method method = clazz.getMethod(methodName, parametersType);%0A    %09%09return method.invoke(object, methodParameters);%0A    %09%7D catch (Exception ex) %7B%0A    %09%09throw new AlmaMaterException(ex);%0A    %09%7D%0A    %7D%0A    %0A    public static Object newInstance(Class%3C?%3E clazz) %7B%0A    %09try %7B%0A    %09%09return clazz.newInstance();%0A    %09%7D catch (Exception ex) %7B%0A    %09%09throw new AlmaMaterException(ex);%0A    %09%7D%0A    %7D%0A    %0A    public static Object newInstance(String fullClassName) %7B%0A    %09Class%3C?%3E clazz = ReflectionUtils.forName(fullClassName);%0A    %09return newInstance(clazz);%0A    %7D%0A    %0A    public static String getSimpleAccessMethodName(Method method) %7B%0A    %09String name = method.getName().replaceFirst(%22%5E(get%7Cis%7Cset%7Cwith)%22, %22%22);%0A    %09return Character.toLowerCase(name.charAt(0)) + name.substring(1);%0A    %7D%0A%7D

Create reflection helper.