/** * Constructs a QueryCollectionReference representing the specified field of an object * * @param qcObj the InterMineObject * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a collection or does not exist */ public QueryCollectionReference(InterMineObject qcObj, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qcObj.getClass(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qcObj.getClass()); } if (!Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " in " + qcObj.getClass() + " is not a collection type"); } this.qcObj = qcObj; this.fieldName = fieldName; this.type = field.getReturnType(); }
/** * Constructs a QueryCollectionReference representing the specified field of an object * * @param qcObj the InterMineObject * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a collection or does not exist */ public QueryCollectionReference(InterMineObject qcObj, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qcObj.getClass(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qcObj.getClass()); } if (!Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " in " + qcObj.getClass() + " is not a collection type"); } this.qcObj = qcObj; this.fieldName = fieldName; this.type = field.getReturnType(); }
/** * Constructs a QueryForeignKey representing the specified field of a QueryClass * * @param qc the QueryClass * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a reference, or does not exist */ public QueryForeignKey(QueryClass qc, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qc.getType()); } if (Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is a collection type"); } if (!InterMineObject.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is not a separate database " + "object"); } this.qc = qc; this.fieldName = fieldName; }
/** * Constructs a QueryObjectReference representing the specified field of a QueryClass * * @param qc the QueryClass * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a reference, or does not exist */ public QueryObjectReference(QueryClass qc, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qc.getType()); } if (Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is a collection type"); } if (!InterMineObject.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is not a separate database " + "object"); } this.qc = qc; this.fieldName = fieldName; this.type = field.getReturnType(); }
/** * Constructs a QueryObjectReference representing the specified field of a QueryClass * * @param qc the QueryClass * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a reference, or does not exist */ public QueryObjectReference(QueryClass qc, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qc.getType()); } if (Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is a collection type"); } if (!InterMineObject.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is not a separate database " + "object"); } this.qc = qc; this.fieldName = fieldName; this.type = field.getReturnType(); }
/** * Constructs a QueryForeignKey representing the specified field of a QueryClass * * @param qc the QueryClass * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a reference, or does not exist */ public QueryForeignKey(QueryClass qc, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qc.getType()); } if (Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is a collection type"); } if (!InterMineObject.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " is not a separate database " + "object"); } this.qc = qc; this.fieldName = fieldName; }
/** * Constructs a QueryCollectionReference representing the specified field of a QueryClassBag * * @param qcb the QueryClassBag * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a collection or does not exist */ public QueryCollectionReference(QueryClassBag qcb, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qcb.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qcb.getType()); } if (!java.util.Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " in " + qcb.getType() + " is not a collection type"); } this.qcb = qcb; this.fieldName = fieldName; this.type = field.getReturnType(); }
throw new NullPointerException("QueryClass parameter is null"); Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in "
/** * Constructs a QueryCollectionReference representing the specified field of a QueryClass * * @param qc the QueryClass * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a collection or does not exist */ public QueryCollectionReference(QueryClass qc, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qc.getType()); } if (!java.util.Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " in " + qc.getType() + " is not a collection type"); } this.qc = qc; this.fieldName = fieldName; this.type = field.getReturnType(); }
/** * Constructs a QueryCollectionReference representing the specified field of a QueryClass * * @param qc the QueryClass * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a collection or does not exist */ public QueryCollectionReference(QueryClass qc, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qc.getType()); } if (!java.util.Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " in " + qc.getType() + " is not a collection type"); } this.qc = qc; this.fieldName = fieldName; this.type = field.getReturnType(); }
/** * Constructs a QueryCollectionReference representing the specified field of a QueryClassBag * * @param qcb the QueryClassBag * @param fieldName the name of the relevant field * @throws NullPointerException if the field name is null * @throws IllegalArgumentException if the field is not a collection or does not exist */ public QueryCollectionReference(QueryClassBag qcb, String fieldName) { if (fieldName == null) { throw new NullPointerException("Field name parameter is null"); } Method field = TypeUtil.getGetter(qcb.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in " + qcb.getType()); } if (!java.util.Collection.class.isAssignableFrom(field.getReturnType())) { throw new IllegalArgumentException("Field " + fieldName + " in " + qcb.getType() + " is not a collection type"); } this.qcb = qcb; this.fieldName = fieldName; this.type = field.getReturnType(); }
throw new NullPointerException("Subquery parameter is null"); Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in "
throw new NullPointerException("QueryClass parameter is null"); Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field " + fieldName + " not found in "
throw new NullPointerException("Subquery parameter is null"); Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in "
type = Class.class; } else { Method field = TypeUtil.getGetter(qc.getType(), fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in "
/** * 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; } }
/** * 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 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; } }
public void testGetGetter() throws Exception { assertEquals(Company.class.getMethod("getName", new Class[] {}), TypeUtil.getGetter(Company.class, "name")); }