/** * Returns the Method object that is the proxySetter for the field name * * @param c the Class * @param fieldName the name of the relevant field * @return the proxySetter, or null if it is not present or the field is not found */ public static Method getProxySetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getProxySetter(); } return null; }
/** * Returns the value of a public or protected Field of an Object given the field name * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the Field * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldValue(Object o, String fieldName) throws IllegalAccessException { try { return getGetter(o.getClass(), fieldName).invoke(o, new Object[] {}); } catch (Exception e) { String type = ""; try { type = " (a " + getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType() .getName() + ")"; } catch (Exception e3) { type = " (available fields are " + getFieldInfos(o.getClass()).keySet() + ")"; } IllegalAccessException e2 = new IllegalAccessException("Couldn't get field \"" + Util.decomposeClass(o.getClass()) + "." + fieldName + "\"" + type); e2.initCause(e); throw e2; } }
/** * Returns the Method object that is the proxySetter for the field name * * @param c the Class * @param fieldName the name of the relevant field * @return the proxySetter, or null if it is not present or the field is not found */ public static Method getProxySetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getProxySetter(); } return null; }
/** * Returns the value of a public or protected Field of an Object given the field name * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the Field * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldValue(Object o, String fieldName) throws IllegalAccessException { try { return getGetter(o.getClass(), fieldName).invoke(o, new Object[] {}); } catch (Exception e) { String type = ""; try { type = " (a " + getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType() .getName() + ")"; } catch (Exception e3) { type = " (available fields are " + getFieldInfos(o.getClass()).keySet() + ")"; } IllegalAccessException e2 = new IllegalAccessException("Couldn't get field \"" + Util.decomposeClass(o.getClass()) + "." + fieldName + "\"" + type); e2.initCause(e); throw e2; } }
/** * Returns the Method object that is the setter for the field name * * @param c the Class * @param fieldName the name of the relevant field * @return the setter, or null if the field is not found */ public static Method getSetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getSetter(); } return null; }
/** * Returns the Method object that is the adder for the field name * * @param c the Class * @param fieldName the name of the relevant collection * @return the adder, or null if it is not present or if the field is not found */ public static Method getAdder(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getAdder(); } return null; }
/** * Returns the Method object that is the proxyGetter for the field name * * @param c the Class * @param fieldName the name of the relevant field * @return the proxyGetter, or null if it is not present or the field is not found */ public static Method getProxyGetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getProxyGetter(); } return null; }
/** * Returns the type of a field given the field name. * * @param c the Class * @param fieldName the name of the relevant field * @return the class of the field, or null if the field is not found */ public static Class<?> getFieldType(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getType(); } return null; }
/** * Returns the Method object that is the proxyGetter for the field name * * @param c the Class * @param fieldName the name of the relevant field * @return the proxyGetter, or null if it is not present or the field is not found */ public static Method getProxyGetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getProxyGetter(); } return null; }
/** * Returns the Method object that is the getter for the field name. * * @param c the Class * @param fieldName the name of the relevant field * @return the Getter, or null if the field is not found */ public static Method getGetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getGetter(); } return null; }
/** * Returns the type of a field given the field name. * * @param c the Class * @param fieldName the name of the relevant field * @return the class of the field, or null if the field is not found */ public static Class<?> getFieldType(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getType(); } return null; }
/** * Returns the Method object that is the getter for the field name. * * @param c the Class * @param fieldName the name of the relevant field * @return the Getter, or null if the field is not found */ public static Method getGetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getGetter(); } return null; }
/** * Returns the Method object that is the setter for the field name * * @param c the Class * @param fieldName the name of the relevant field * @return the setter, or null if the field is not found */ public static Method getSetter(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getSetter(); } return null; }
/** * Returns the Method object that is the adder for the field name * * @param c the Class * @param fieldName the name of the relevant collection * @return the adder, or null if it is not present or if the field is not found */ public static Method getAdder(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { return info.getAdder(); } return null; }
/** * Returns the element type of a collection given the field name. * * @param c the Class * @param fieldName the name of the relevant collection * @return the class of the field, or null if the field is not found * @throws IllegalArgumentException if the field is not a collection */ public static Class<? extends FastPathObject> getElementType(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { try { return info.getElementType(); } catch (NullPointerException e) { IllegalArgumentException e2 = new IllegalArgumentException("Field " + Util.getFriendlyName(c) + "." + fieldName + " is not a collection"); e2.initCause(e); throw e2; } } return null; }
/** * Returns the element type of a collection given the field name. * * @param c the Class * @param fieldName the name of the relevant collection * @return the class of the field, or null if the field is not found * @throws IllegalArgumentException if the field is not a collection */ public static Class<? extends FastPathObject> getElementType(Class<?> c, String fieldName) { FieldInfo info = getFieldInfo(c, fieldName); if (info != null) { try { return info.getElementType(); } catch (NullPointerException e) { IllegalArgumentException e2 = new IllegalArgumentException("Field " + Util.getFriendlyName(c) + "." + fieldName + " is not a collection"); e2.initCause(e); throw e2; } } return null; }
/** * Adds an element to a public or protected collection of an Object given the field name. * * @param o the Object * @param fieldName the name of the relevant collection * @param element the element to add to the collection */ public static void addCollectionElement(Object o, String fieldName, Object element) { try { getAdder(o.getClass(), fieldName).invoke(o, element); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getElementType().getName(); } catch (Exception e3) { IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " - not an accessible collection"); e2.initCause(e); throw e2; } IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " (a " + type + ") with \"" + element + "\" (a " + element.getClass().getName() + ")"); e2.initCause(e); throw e2; } }
/** * Adds an element to a public or protected collection of an Object given the field name. * * @param o the Object * @param fieldName the name of the relevant collection * @param element the element to add to the collection */ public static void addCollectionElement(Object o, String fieldName, Object element) { try { getAdder(o.getClass(), fieldName).invoke(o, element); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getElementType().getName(); } catch (Exception e3) { IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " - not an accessible collection"); e2.initCause(e); throw e2; } IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " (a " + type + ") with \"" + element + "\" (a " + element.getClass().getName() + ")"); e2.initCause(e); throw e2; } }
/** * Returns the value of a public or protected Field of an Object given by the field name without * dereferencing any ProxyReference objects. * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the field, without dereferencing ProxyReferences * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldProxy(Object o, String fieldName) throws IllegalAccessException { try { Method proxyGetter = getProxyGetter(o.getClass(), fieldName); if (proxyGetter == null) { proxyGetter = getGetter(o.getClass(), fieldName); } return proxyGetter.invoke(o, new Object[] {}); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType().getName(); } catch (Exception e3) { // ignore } IllegalAccessException e2 = new IllegalAccessException("Couldn't proxyGet field \"" + o.getClass().getName() + "." + fieldName + "\"" + (type == null ? "" : " (a " + type + ")")); e2.initCause(e); throw e2; } }
/** * Returns the value of a public or protected Field of an Object given by the field name without * dereferencing any ProxyReference objects. * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the field, without dereferencing ProxyReferences * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldProxy(Object o, String fieldName) throws IllegalAccessException { try { Method proxyGetter = getProxyGetter(o.getClass(), fieldName); if (proxyGetter == null) { proxyGetter = getGetter(o.getClass(), fieldName); } return proxyGetter.invoke(o, new Object[] {}); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType().getName(); } catch (Exception e3) { // ignore } IllegalAccessException e2 = new IllegalAccessException("Couldn't proxyGet field \"" + o.getClass().getName() + "." + fieldName + "\"" + (type == null ? "" : " (a " + type + ")")); e2.initCause(e); throw e2; } }