@Override public String getDescription(final T property) { Class<?> type = property.getClass(); try { return getFieldValue(property, propertyDescriptionFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining description for Property with id " + getId(property)); } return null; }
@Override public String getCaption(final T property) { Class<?> type = property.getClass(); try { return getFieldValue(property, propertyCaptionFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining caption for Property with id " + getId(property)); } return null; }
@Override public boolean isReadOnly(final T property) { Class<?> type = property.getClass(); try { return getFieldValue(property, propertyReadOnlyFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining read only flag for Property with id " + getId(property)); } return false; }
@Override public boolean isOptional(final T property) { Class<?> type = property.getClass(); try { return getFieldValue(property, propertyOptionalFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining optional flag for Property with id " + getId(property)); } return true; }
@Override public V getValue(final T property) { Class<?> type = property.getClass(); try { return getFieldValue(property, propertyValueFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining value for Property with id " + getId(property)); } return null; }
@Override public PropertyType getType(final T property) { Class<?> type = property.getClass(); PropertyType pType = null; try { pType = getFieldValue(property, propertyTypeFieldNames.get(type)); if (null == pType) { pType = propertyTypes.get(type); } } catch (IllegalAccessException e) { LOG.error("Error obtaining type for Property with id " + getId(property)); } return pType; }
@Override public void setValue(final T property, final V value) { Class<?> type = property.getClass(); String fieldName = propertyValueFieldNames.get(type); Field field = null; try { field = getField(property, fieldName); } catch (IllegalAccessException e) { LOG.error("Error setting value for Property with id " + getId(property) + ". Field [" + fieldName + "] not found for type [" + type.getName() + "]"); } if (null != field) { try { field.setAccessible(true); field.set(property, value); } catch (Exception e) { LOG.error("Error setting value for Property with id [" + getId(property) + "] " + "and value [" + (value != null ? value.toString() : "null") + "]"); } } }
@Override @SuppressWarnings("unchecked") public Map<V, String> getAllowedValues(final T property) { Class<?> type = property.getClass(); String field = propertyAllowedValuesFieldNames.get(type); Iterable<?> allowedValues = null; try { allowedValues = getFieldValue(property, field); } catch (IllegalAccessException e) { LOG.error("Error obtaining allowed values for Property with id " + getId(property)); } if (null != allowedValues && allowedValues.iterator().hasNext()) { Map<V, String> result = new LinkedHashMap<V, String>(); for (Object v : allowedValues) { V allowedValue = (V) v; result.put(allowedValue, allowedValue.toString()); } return result; } return null; }