/** * Return an converter that does not modify model or component values. */ public static <T> Converter<T, T> identityConverter(final Class<T> type) { final IdentityConverter<T> idOneWay = new IdentityConverter<>(type); return TwoWayConverter.createConverter(idOneWay, idOneWay); }
public static <M, W> Converter<M, W> createConverter(final OneWayConverter<M, W> modelToWidget, final OneWayConverter<W, M> widgetToModel) { if (!((modelToWidget.getDomainType().equals(widgetToModel.getTargetType()) || (modelToWidget.getDomainType().isInterface() ^ widgetToModel.getTargetType().isInterface())) && (modelToWidget.getTargetType().equals(widgetToModel.getDomainType()) || (modelToWidget.getTargetType().isInterface() ^ widgetToModel.getDomainType().isInterface())))) { throw new IllegalArgumentException("The first converter converts " + modelToWidget.getDomainType().getName() + " to " + modelToWidget.getTargetType().getName() + " but the second converts from " + widgetToModel.getDomainType().getName() + " to " + widgetToModel.getTargetType().getName()); } return new TwoWayConverter<M, W>(modelToWidget, widgetToModel); }
public static <M, W> Converter<M, W> createConverter(final OneWayConverter<M, W> modelToWidget, final OneWayConverter<W, M> widgetToModel) { if (!((modelToWidget.getDomainType().equals(widgetToModel.getTargetType()) || (modelToWidget.getDomainType().isInterface() ^ widgetToModel.getTargetType().isInterface())) && (modelToWidget.getTargetType().equals(widgetToModel.getDomainType()) || (modelToWidget.getTargetType().isInterface() ^ widgetToModel.getDomainType().isInterface())))) { throw new IllegalArgumentException("The first converter converts " + modelToWidget.getDomainType().getName() + " to " + modelToWidget.getTargetType().getName() + " but the second converts from " + widgetToModel.getDomainType().getName() + " to " + widgetToModel.getTargetType().getName()); } return new TwoWayConverter<M, W>(modelToWidget, widgetToModel); }
/** * Return an converter that does not modify model or component values. */ public static <T> Converter<T, T> identityConverter(final Class<T> type) { final IdentityConverter<T> idOneWay = new IdentityConverter<>(type); return TwoWayConverter.createConverter(idOneWay, idOneWay); }
/** * Return an converter that does not modify model or component values. */ public static <T> Converter<T, T> identityConverter(final Class<T> type) { final IdentityConverter<T> idOneWay = new IdentityConverter<>(type); return TwoWayConverter.createConverter(idOneWay, idOneWay); }
private static <M, C> Converter<M, C> maybeCreateBuiltinConverter(final Class<M> modelValueType, final Class<C> widgetValueType) { Assert.notNull(modelValueType); Assert.notNull(widgetValueType); final OneWayConverter<M, C> modelToWidget = getOneWayConverter(modelValueType, widgetValueType); final OneWayConverter<C, M> widgetToModel = getOneWayConverter(widgetValueType, modelValueType); if (modelToWidget == null || widgetToModel == null) { return null; } else { return TwoWayConverter.createConverter(modelToWidget, widgetToModel); } }
private static <M, C> Converter<M, C> maybeCreateBuiltinConverter(final Class<M> modelValueType, final Class<C> widgetValueType) { Assert.notNull(modelValueType); Assert.notNull(widgetValueType); final OneWayConverter<M, C> modelToWidget = getOneWayConverter(modelValueType, widgetValueType); final OneWayConverter<C, M> widgetToModel = getOneWayConverter(widgetValueType, modelValueType); if (modelToWidget == null || widgetToModel == null) { return null; } else { return TwoWayConverter.createConverter(modelToWidget, widgetToModel); } }
private static <M, C> Converter<M, C> maybeCreateBuiltinConverter(final Class<M> modelValueType, final Class<C> widgetValueType) { Assert.notNull(modelValueType); Assert.notNull(widgetValueType); final OneWayConverter<M, C> modelToWidget = getOneWayConverter(modelValueType, widgetValueType); final OneWayConverter<C, M> widgetToModel = getOneWayConverter(widgetValueType, modelValueType); if (modelToWidget == null || widgetToModel == null) { return null; } else { return TwoWayConverter.createConverter(modelToWidget, widgetToModel); } }