/** * Return the value of the given field in the given object. */ public static long getLong(Object target, Field field) { if (target == null || field == null) return 0L; makeAccessible(field, field.getModifiers()); try { return field.getLong(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Return the value of the given field in the given object. */ public static Object get(Object target, Field field) { if (target == null || field == null) return null; makeAccessible(field, field.getModifiers()); try { return field.get(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, long value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setLong(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "long"})); } }
/** * Return the return value of the given getter in the given object. */ public static Object get(Object target, Method getter) { if (target == null || getter == null) return null; makeAccessible(getter, getter.getModifiers()); try { return getter.invoke(target, (Object[]) null); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-method", target, getter)); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, boolean value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setBoolean(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "boolean"})); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, int value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setInt(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "int"})); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, long value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setLong(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "long"})); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, long value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setLong(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "long"})); } }
/** * Return the value of the given field in the given object. */ public static short getShort(Object target, Field field) { if (target == null || field == null) return (short) 0; makeAccessible(field, field.getModifiers()); try { return field.getShort(target); } catch (Throwable t) { throw wrapReflectionException(t); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, float value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setFloat(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "float"})); } }
/** * Return the value of the given field in the given object. */ public static float getFloat(Object target, Field field) { if (target == null || field == null) return 0F; makeAccessible(field, field.getModifiers()); try { return field.getFloat(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Return the value of the given field in the given object. */ public static short getShort(Object target, Field field) { if (target == null || field == null) return (short) 0; makeAccessible(field, field.getModifiers()); try { return field.getShort(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, byte value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setByte(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "byte"})); } }
/** * Return the value of the given field in the given object. */ public static char getChar(Object target, Field field) { if (target == null || field == null) return (char) 0; makeAccessible(field, field.getModifiers()); try { return field.getChar(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Return the value of the given field in the given object. */ public static double getDouble(Object target, Field field) { if (target == null || field == null) return 0D; makeAccessible(field, field.getModifiers()); try { return field.getDouble(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, byte value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setByte(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "byte"})); } }
/** * Return the value of the given field in the given object. */ public static double getDouble(Object target, Field field) { if (target == null || field == null) return 0D; makeAccessible(field, field.getModifiers()); try { return field.getDouble(target); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("get-field", target, field)); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, byte value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setByte(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "byte"})); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, char value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setChar(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "char"})); } }
/** * Set the value of the given field in the given object. */ public static void set(Object target, Field field, char value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setChar(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[]{target, field, value, "char"})); } }