/** * Retrieves the notification support based on the given value. * <p> * If no support is found, an exception is thrown. * * @param <T> value type * @param newValue the value; can't be null * @return the notification support */ public static <T> NotificationSupport<T> findNotificationSupportFor(final T newValue) { @SuppressWarnings("unchecked") Class<T> typeClass = (Class<T>) newValue.getClass(); NotificationSupport<T> support = (NotificationSupport<T>) findTypeSupportFor(NotificationSupport.class, typeClass); if (support == null) { String name = typeClass.getSimpleName(); if (name == null || name.trim().isEmpty()) { name = typeClass.getName(); } throw new RuntimeException("Final value can't be of type " + name + "."); } return support; }