* <code><a.prefix>.<class.name> = ${event.reqid}</code>
* </pre>
*
- * If it doesn't find a property for the class, then it looks for a property for
- * that class' super class or interfaces. Extractors are compiled and cached.
+ * <p>For any given field name (e.g., "reqid"), it first looks for a public "getXxx()"
+ * method to extract the specified field. If that fails, then it looks for a public field
+ * by the given name. If that also fails, and the object is a <i>Map</i> subclass, then it
+ * simply uses the "get(field-name)" method to extract the data from the map.
*/
public class ClassExtractors {
}
try {
- return clazz.getDeclaredField(name);
+ return clazz.getField(name);
} catch (NoSuchFieldException expected) {
// no field by this name - try super class & interfaces
logger.debug("no field {} in {}", name, clazz.getName(), expected);
+ return null;
} catch (SecurityException e) {
throw new ExtractorException("inaccessible field " + clazz + "." + name, e);
}
-
-
- Field field;
-
- // see if the superclass has an extractor
- if ((field = getClassField(clazz.getSuperclass(), name)) != null) {
- return field;
- }
-
- // not necessary to check the interfaces
-
- return field;
}
}
}
* This will not be used because getIntValue() will override it.
*/
@SuppressWarnings("unused")
- private int intValue = INT_VALUE2;
+ public final int intValue = INT_VALUE2;
/**
* Used to verify retrieval via a field name.
*/
@SuppressWarnings("unused")
- private String strValue = VALUE;
+ public final String strValue = VALUE;
/**
* Used to verify retrieval within maps.
*/
@SuppressWarnings("unused")
- private Map<String, Object> mapValue = null;
+ public Map<String, Object> mapValue = null;
/**
* {@code True} if {@link #getVoidValue()} was invoked, {@code false}
* Used to verify multi-component retrieval.
*/
private static class Container {
- private Simple simpleValue = new Simple();
+ public Simple simpleValue = new Simple();
@SuppressWarnings("unused")
public Simple getData() {
private static class Super implements WithString {
@SuppressWarnings("unused")
- private int intValue = INT_VALUE;
+ public final int intValue = INT_VALUE;
@Override
public String getStrValue() {
private static class Sub extends Super {
@SuppressWarnings("unused")
- private Simple simple = new Simple();
+ public final Simple simple = new Simple();
/**
* Used to verify multi-component retrieval.
*/
- private Container cont = new Container();
+ public final Container cont = new Container();
}
}