*
* @param columnName Column name
* @return Value from field
+ * @throws IllegalArgumentException Some implementations may throw this.
*/
@Override
- public Object getValueFromColumn (final String columnName) {
+ public Object getValueFromColumn (final String columnName) throws IllegalArgumentException {
throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0}", columnName)); //NOI18N
}
}
/**
- * Returns boolean field value from given method call
+ * Returns boolean field value from given method name by invoking it
*
* @param instance The instance to call
* @param targetClass Target class to look in
}
/**
- * Returns any field value from given method call
+ * Returns any field value from given method name by invoking it
*
* @param instance The instance to call
* @param targetClass Target class to look in
}
/**
- * Creates an iterator from given instance and class name. The class name
- * is required in getValueFromColumn() to make a proper call.
+ * Creates an iterator from given instance and class name.
*
* @param instance Instance to run getter calls on
* @param className Class name to iterate over
this.getLogger().trace(MessageFormat.format("instance={0},className={1} - CALLED!", instance, className));
// Get all attributes from given instance
- Field[] fields = instance.getClass().getDeclaredFields();
+ Field[] fields = this.getClassFromTarget(instance, className).getDeclaredFields();
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("Found {0} fields.", fields.length));
// A list is fine
List<Object> list = new ArrayList<>(fields.length);
// Walk through all
for (final Field field : fields) {
+ // Debug log
+ this.getLogger().debug(MessageFormat.format("field={0}", field.getName()));
+
+ // Does the field start with "$"?
+ if (field.getName().startsWith("$")) {
+ // Skip it silently
+ continue;
+ }
+
// Get value from it
Object value = this.getValueFromColumn(field.getName());
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("value={0}", value));
+
// Add it to list
- assert(list.add(value)) : MessageFormat.format("value {0} has not been added", value);
+ boolean added = list.add(value);
+
+ // Debug log
+ this.getLogger().debug("added=" + added);
}
// Debug message
* @return Value from field
*/
@Override
- public Object getValueFromColumn (final String columnName) {
+ public Object getValueFromColumn (final String columnName) throws IllegalArgumentException {
// Trace message
this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName));
+ // A '$' means not our field
+ if (columnName.startsWith("$")) {
+ // Don't handle these
+ throw new IllegalArgumentException("columnsName contains $");
+ }
+
// Determine if the given column is boolean
if (this.isBooleanField(this, "BaseContact", columnName)) {
+ // Debug message
+ this.getLogger().debug("Column " + columnName + " represents a boolean field.");
+
// Yes, then call other method
- return this.getBooleanField(this, "BaseContact", columnName);
+ return this.getBooleanField(this, "BaseContact", this.convertColumnNameToGetterMethod(columnName, true));
}
// Convert column name to field name