Skip to content

Commit

Permalink
implementations & bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
n9Mtq4 committed Jun 16, 2015
1 parent 5a39daf commit ba8afaa
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/com/n9mtq4/reflection/ReflectionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static int getInt(Field field, Object obj) {
*/
public static int getInt(String fieldName, Object obj, Class clazz) {
try {
Field field = clazz.getDeclaredField(fieldName);
Field field = getAllDeclaredField(fieldName, clazz);
return getInt(field, obj);
}catch (NoSuchFieldException e) {
e.printStackTrace();
Expand Down Expand Up @@ -103,7 +103,7 @@ public static void setInt(int x, Field field, Object obj) {
*/
public static void setInt(int x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setInt(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -157,7 +157,7 @@ public static int getStaticInt(Field field) {
*/
public static int getStaticInt(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticInt(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -189,7 +189,7 @@ public static void setStaticInt(int x, Field field) {
*/
public static void setStaticInt(int x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticInt(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -223,7 +223,7 @@ public static byte getByte(Field field, Object obj) {
*/
public static byte getByte(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getByte(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -257,7 +257,7 @@ public static void setByte(byte x, Field field, Object obj) {
*/
public static void setByte(byte x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
f.setAccessible(true);
f.setByte(obj, x);
}catch (Exception e) {
Expand Down Expand Up @@ -312,7 +312,7 @@ public static byte getStaticByte(Field field) {
*/
public static byte getStaticByte(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticByte(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -344,7 +344,7 @@ public static void setStaticByte(byte x, Field field) {
*/
public static void setStaticByte(byte x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticByte(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -378,7 +378,7 @@ public static boolean getBoolean(Field field, Object obj) {
*/
public static boolean getBoolean(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getBoolean(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -412,7 +412,7 @@ public static void setBoolean(boolean x, Field field, Object obj) {
*/
public static void setBoolean(boolean x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setBoolean(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -466,7 +466,7 @@ public static boolean getStaticBoolean(Field field) {
*/
public static boolean getStaticBoolean(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticBoolean(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -498,7 +498,7 @@ public static void setStaticBoolean(boolean x, Field field) {
*/
public static void setStaticBoolean(boolean x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticBoolean(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -532,7 +532,7 @@ public static char getChar(Field field, Object obj) {
*/
public static char getChar(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getChar(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -566,7 +566,7 @@ public static void setChar(char x, Field field, Object obj) {
*/
public static void setChar(char x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setChar(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -620,7 +620,7 @@ public static char getStaticChar(Field field) {
*/
public static char getStaticChar(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticChar(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -652,7 +652,7 @@ public static void setStaticChar(char x, Field field) {
*/
public static void setStaticChar(char x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticChar(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -686,7 +686,7 @@ public static float getFloat(Field field, Object obj) {
*/
public static float getFloat(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getFloat(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -720,7 +720,7 @@ public static void setFloat(float x, Field field, Object obj) {
*/
public static void setFloat(float x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setFloat(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -774,7 +774,7 @@ public static float getStaticFloat(Field field) {
*/
public static float getStaticFloat(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticFloat(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -806,7 +806,7 @@ public static void setStaticFloat(float x, Field field) {
*/
public static void setStaticFloat(float x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticFloat(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -840,7 +840,7 @@ public static double getDouble(Field field, Object obj) {
*/
public static double getDouble(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getDouble(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -874,7 +874,7 @@ public static void setDouble(double x, Field field, Object obj) {
*/
public static void setDouble(double x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setDouble(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -928,7 +928,7 @@ public static double getStaticDouble(Field field) {
*/
public static double getStaticDouble(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticDouble(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -960,7 +960,7 @@ public static void setStaticDouble(double x, Field field) {
*/
public static void setStaticDouble(double x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticDouble(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -994,7 +994,7 @@ public static long getLong(Field field, Object obj) {
*/
public static long getLong(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getLong(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1028,7 +1028,7 @@ public static void setLong(long x, Field field, Object obj) {
*/
public static void setLong(long x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setLong(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1082,7 +1082,7 @@ public static long getStaticLong(Field field) {
*/
public static long getStaticLong(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticLong(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1114,7 +1114,7 @@ public static void setStaticLong(long x, Field field) {
*/
public static void setStaticLong(long x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticLong(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1148,7 +1148,7 @@ public static short getShort(Field field, Object obj) {
*/
public static short getShort(String fieldName, Object obj, Class clazz) {
try {
Field field = clazz.getDeclaredField(fieldName);
Field field = getAllDeclaredField(fieldName, clazz);
return getShort(field, obj);
}catch (NoSuchFieldException e) {
e.printStackTrace();
Expand Down Expand Up @@ -1182,7 +1182,7 @@ public static void setShort(short x, Field field, Object obj) {
*/
public static void setShort(short x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setShort(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1239,7 +1239,7 @@ public static short getStaticShort(Field field) {
*/
public static short getStaticShort(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticShort(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1272,7 +1272,7 @@ public static void setStaticShort(short x, Field field) {
*/
public static void setStaticShort(short x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticShort(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1306,7 +1306,7 @@ public static <E> E getObject(Field field, Object obj) {
*/
public static <E> E getObject(String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getObject(f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1340,7 +1340,7 @@ public static void setObject(Object x, Field field, Object obj) {
*/
public static void setObject(Object x, String fieldName, Object obj, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setObject(x, f, obj);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public static <E> E getStaticObject(Field field) {
*/
public static <E> E getStaticObject(String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
return getStaticObject(f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1426,7 +1426,7 @@ public static void setStaticObject(Object x, Field field) {
*/
public static void setStaticObject(Object x, String fieldName, Class clazz) {
try {
Field f = clazz.getDeclaredField(fieldName);
Field f = getAllDeclaredField(fieldName, clazz);
setStaticObject(x, f);
}catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -1479,7 +1479,7 @@ public static <E> E callConstructor(Class clazz, Object... params) {
public static <E> E callObjectMethod(String methodName, Object obj, Class clazz, Class[] classParams, Object[] params) {
Method m = null;
try {
m = clazz.getDeclaredMethod(methodName, classParams);
m = getAllDeclaredMethod(methodName, classParams, clazz);
m.setAccessible(true);
return (E) m.invoke(obj, params);
}catch (NoSuchMethodException e) {
Expand Down Expand Up @@ -2381,7 +2381,7 @@ public static Field getAllDeclaredField(String name, Class clazz) throws NoSuchF

}catch (NoSuchFieldException e) {
}
currentClass = clazz.getSuperclass();
currentClass = currentClass.getSuperclass();
}

throw new NoSuchFieldException(name);
Expand Down Expand Up @@ -2412,7 +2412,7 @@ public static Method getAllDeclaredMethod(String name, Class[] params, Class cla

}catch (NoSuchMethodException e) {
}
currentClass = clazz.getSuperclass();
currentClass = currentClass.getSuperclass();
}
throw new NoSuchMethodException(name);
}
Expand Down

0 comments on commit ba8afaa

Please sign in to comment.