@Override public String getValue(HasProperties hasProperties) { Object value = hasProperties.get(property); if (value != null) { return value.toString(); } return ""; } };
@SuppressWarnings("unchecked") public static <T, R> R merge(final T source, final R target) { if (null != source) { final HasProperties hasProperties = (HasProperties) DataBinder.forModel(source).getModel(); if (null != hasProperties) { final Map<String, PropertyType> propertyTypeMap = hasProperties.getBeanProperties(); if (null != propertyTypeMap && !propertyTypeMap.isEmpty()) { final HasProperties targetProperties = (HasProperties) DataBinder.forModel(target).getModel(); for (final Map.Entry<String, PropertyType> entry : propertyTypeMap.entrySet()) { final String pId = entry.getKey(); try { targetProperties.set(pId, hasProperties.get(pId)); } catch (NonExistingPropertyException exception) { // Just skip it, Go to next property. LOGGER.log(Level.INFO, "BindableAdapterUtils#merge - Skipping merge property [" + pId + "]"); } } return (R) target; } } } return null; } }
@Override public Boolean getValue(HasProperties object) { Object value = object.get(property); if (value == null) { return Boolean.FALSE; } return Boolean.TRUE.equals(value); } };
@SuppressWarnings("unchecked") public static <T, R> Set<R> getProxiedSet(final T pojo, final Collection<String> fieldNames) { Set<R> result = new LinkedHashSet<>(); if (null != pojo && null != fieldNames && !fieldNames.isEmpty()) { for (String fieldName : fieldNames) { HasProperties hasProperties = (HasProperties) DataBinder.forModel(pojo).getModel(); result.add((R) hasProperties.get(fieldName)); } } return result; }
@SuppressWarnings("unchecked") public static <T, R> R getProxiedValue(final T pojo, final String fieldName) { R result = null; if (null != pojo && null != fieldName) { HasProperties hasProperties = (HasProperties) DataBinder.forModel(pojo).getModel(); result = (R) hasProperties.get(fieldName); } return result; }