@Override public PRESENTATION convertToPresentation(T value, ValueContext context) { MODEL model = other.convertToPresentation(value, context); return Converter.this.convertToPresentation(model, context); } };
@Override public FIELDVALUE convertToPresentation(FIELDVALUE value, ValueContext context) { if (delegate == null) { return value; } else { return delegate.convertToPresentation(value, context); } }
private FIELDVALUE convertDataToFieldType(BEAN bean) { TARGET target = getter.apply(bean); ValueContext valueContext = createValueContext(); return converterValidatorChain.convertToPresentation(target, valueContext); }
/** * Formats an object according to a converter suitable for a given type. * * @param object * Object to format. * @param type * Type of the object. * @return String representation of the object, as returned by the * registered converter. */ public <T> String format(T object, Class<? extends T> type) { if (object == null) { return null; } else { Converter<String, Object> converter = findConverterFor( object.getClass()); return converter.convertToPresentation(object, new ValueContext()); } }
/** * Serializes the given value to valid design attribute representation * * @param sourceType * the type of the value * @param value * the value to be serialized * @return the given value as design attribute representation */ private static String toAttributeValue(Class<?> sourceType, Object value) { if (value == null) { // TODO: Handle corner case where sourceType is String and default // value is not null. How to represent null value in attributes? return ""; } @SuppressWarnings("unchecked") Converter<String, Object> converter = getFormatter() .findConverterFor(sourceType); if (converter != null) { return converter.convertToPresentation(value, new ValueContext()); } else { return value.toString(); } }
@Override public Set<PRESENTATION> convertToPresentation(Set<MODEL> value, ValueContext context) { if (CollectionUtils.isEmpty(value)) { return Collections.emptySet(); } return (Set<PRESENTATION>) value.stream().map(v -> delegate.convertToPresentation(v, context)).collect(Collectors.toSet()); }
/** * Convert the model value type to presentation value type. * @param value Value to convert * @return Converted value */ private T convertToPresentation(V value) { return converter.convertToPresentation(value, _valueContext()); }
protected S toSelection(ITEM item) { return requireItemConverter().convertToPresentation(item, new ValueContext(this, this, findLocale())); }