/** * Returns a proxy for a newly created model instance of the provided type. Changes to the proxy's * state will result in updates on the component given the corresponding property was bound. * * @param bindableType * the bindable type * @return proxy that can be used in place of the model instance. */ @SuppressWarnings("unchecked") public static <T> T getBindableProxy(Class<T> bindableType) { final BindableProxyProvider proxyProvider = getBindableProxyProvider(bindableType); final BindableProxy<?> proxy = proxyProvider.getBindableProxy(); if (proxy == null) { throw new RuntimeException("No proxy instance provided for bindable type: " + bindableType.getName()); } return (T) proxy; }
/** * Returns a proxy for a newly created model instance of the provided type. Changes to the proxy's * state will result in updates on the component given the corresponding property was bound. * * @param bindableType * the bindable type * @return proxy that can be used in place of the model instance. */ @SuppressWarnings("unchecked") public static <T> T getBindableProxy(Class<T> bindableType) { final BindableProxyProvider proxyProvider = getBindableProxyProvider(bindableType); final BindableProxy<?> proxy = proxyProvider.getBindableProxy(); if (proxy == null) { throw new RuntimeException("No proxy instance provided for bindable type: " + bindableType.getName()); } return (T) proxy; }
/** * Returns a new proxy for the provided model instance. Changes to the proxy's state will result * in updates on the widget given the corresponding property was bound. * * @param <T> * the bindable type * @param model * The model instance to proxy, must not be null. * @return proxy that can be used in place of the model instance. */ @SuppressWarnings("unchecked") public static <T> T getBindableProxy(T model) { Assert.notNull(model); if (model instanceof BindableProxy) return model; BindableProxy<?> proxy = proxies.get(model); if (proxy == null) { final Class<? extends Object> modelClass = (model instanceof List ? List.class : model.getClass()); final BindableProxyProvider proxyProvider = getBindableProxyProvider(modelClass); proxy = proxyProvider.getBindableProxy(model); if (proxy == null) { throw new RuntimeException("No proxy instance provided for bindable type: " + modelClass.getName()); } proxies.put(model, proxy); } return (T) proxy; }
/** * Returns a new proxy for the provided model instance. Changes to the proxy's state will result * in updates on the widget given the corresponding property was bound. * * @param <T> * the bindable type * @param model * The model instance to proxy, must not be null. * @return proxy that can be used in place of the model instance. */ @SuppressWarnings("unchecked") public static <T> T getBindableProxy(T model) { Assert.notNull(model); if (model instanceof BindableProxy) return model; BindableProxy<?> proxy = proxies.get(model); if (proxy == null) { final Class<? extends Object> modelClass = (model instanceof List ? List.class : model.getClass()); final BindableProxyProvider proxyProvider = getBindableProxyProvider(modelClass); proxy = proxyProvider.getBindableProxy(model); if (proxy == null) { throw new RuntimeException("No proxy instance provided for bindable type: " + modelClass.getName()); } proxies.put(model, proxy); } return (T) proxy; }