protected DataBinder<T> getBinderForModel(T model) { return DataBinder.forModel(model); }
@Override public BindableProxy getProxyForModel(Object model) { if (model instanceof BindableProxy) { return (BindableProxy) model; } return (BindableProxy) DataBinder.forModel(model).getModel(); }
@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, V> void setProxiedValue(final T pojo, final String fieldName, final V value) { if (null != pojo && null != fieldName) { HasProperties hasProperties = (HasProperties) DataBinder.forModel(pojo).getModel(); hasProperties.set(fieldName, value); } }
@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; }
@SuppressWarnings("unchecked") public static <T> T clone(final T pojo) { if (null != pojo) { final BindableProxy proxy = (BindableProxy) DataBinder.forModel(pojo).getModel(); return (T) proxy.deepUnwrap(); } return null; }
@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; } }
binder = DataBinder.forModel(proxy.get(bindableProperty));
binder = DataBinder.forModel(proxy.get(bindableProperty));
nestedBinder = DataBinder.forModel(value);
nestedBinder = DataBinder.forModel(value);