Added ReflectionUtils helper class to find Fields with @Interpolate annotation in superclasses (Interpolators didn't account for Fields in AdvancedPosition inherited by Position)

This commit is contained in:
CrushedPixel
2015-07-12 03:31:52 +02:00
parent 824c80d0d2
commit 6a6873c3d7
3 changed files with 30 additions and 13 deletions

View File

@@ -0,0 +1,24 @@
package eu.crushedpixel.replaymod.utils;
import eu.crushedpixel.replaymod.interpolation.Interpolate;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
public class ReflectionUtils {
public static List<Field> getFieldsToInterpolate(Class clazz) {
List<Field> fields = new ArrayList<Field>();
for(Field f : clazz.getDeclaredFields()) {
if(f.isAnnotationPresent(Interpolate.class)) fields.add(f);
}
if(clazz.getSuperclass() != Object.class) {
fields.addAll(getFieldsToInterpolate(clazz.getSuperclass()));
}
return fields;
}
}