public abstract class BeanValueType<ValueType>
extends java.lang.Object BeanFactories (that is, the return types of getters, and the parameter types of setters). The primary interface is through the static methods. In some cases, generated subclasses are required in order to work around GWT's limited reflection capabilities. Those classes are automatically generated by the by the BeanFactory generator when necessary. If you want to use BeanValueType outside of BeanFactory, then you'll need to use the BeanValueType.MetaFactory interface to register types.
| Modifier and Type | Class and Description |
|---|---|
static class | BeanValueType.Convertability An enum used to indicate how well a BeanValueType can handle a conversion. |
static interface | BeanValueType.MetaFactory Interface used to trigger the generation and registration of reflection metadata for argument types. |
| Modifier | Constructor and Description |
|---|---|
protected | BeanValueType() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.IllegalArgumentException | conversionException(java.lang.Object value) |
static BeanValueType.Convertability | convertabilityFrom(java.lang.Class<?> klass, java.lang.Object value) How well could convertFrom convert the value to the klass? |
BeanValueType.Convertability | convertabilityFrom(java.lang.Object value) |
protected BeanValueType.Convertability | convertabilityToString() |
static BeanValueType.Convertability | convertabilityToString(java.lang.Class<?> klass) |
static java.lang.Object | convertFrom(java.lang.Class<?> klass, java.lang.Object value) Convert the value into an object of the class. |
ValueType | convertFrom(java.lang.Object value) |
static com.google.gwt.core.client.JavaScriptObject | convertMapToJavascriptObject(java.util.Map valueMap) |
static java.lang.Object | convertToJava(com.google.gwt.core.client.JavaScriptObject obj) Performs basic conversion from a JavaScriptObject to an equivalent Java value, without taking into account any particularly desired Java types. |
static com.google.gwt.core.client.JavaScriptObject | convertToJavaScriptArray(java.lang.Object[] array) |
static com.google.gwt.core.client.JavaScriptObject | convertToJavaScriptObject(java.lang.Object value) Converts the value to a JavaScriptObject. |
static java.lang.String | convertToString(java.lang.Object value) Converts the value to a string. |
protected java.lang.String | doConvertToString(ValueType value) |
static BeanValueType<?> | getBeanValueType(java.lang.Class<?> valueType) |
protected abstract java.lang.Class<?> | getValueType() |
static boolean | isA(com.google.gwt.core.client.JavaScriptObject value, java.lang.String scClassName) Is the SmartClient object an instance (or subclass) of the SmartClient class? |
static boolean | isAssignableFrom(java.lang.Class<?> possibleSuperclass, java.lang.Class<?> possibleSubclass) Can objects of the possible sub-class be assigned to the possible super-class? |
static boolean | isAssignableFrom(java.lang.Class<?> klass, java.lang.Object value) Can the value be assigned to the class? Or, to put it another way, would value instanceof Klass return true (if we had the class literal to work with)? |
protected abstract boolean | isAssignableFrom(java.lang.Object value) |
protected ValueType | nullValue() |
static void | registerBasicValueTypes() Registers BeanValueTypes for boolean, double, float, long, Boolean, Double, Float, Long, Number, and String. |
protected static void | registerBeanValueType(BeanValueType beanValueType) |
static com.google.gwt.core.client.JavaScriptObject | wrapInJavascriptArray(java.lang.Object value) Converts the value to a JavaScriptObject, and wraps it in a JavaScript array. |
public static BeanValueType<?> getBeanValueType(java.lang.Class<?> valueType)
protected static void registerBeanValueType(BeanValueType beanValueType)
public static void registerBasicValueTypes()
BeanValueTypes for boolean, double, float, long, Boolean, Double, Float, Long, Number, and String. This is not automatic in order to allow for more dead-code elimination if not being used.
If you need BeanValueTypes for other types, you can register them via the BeanValueType.MetaFactory interface.
public static boolean isAssignableFrom(java.lang.Class<?> klass,
java.lang.Object value) value instanceof Klass return true (if we had the class literal to work with)?klass - The Class to be assigned to.value - The value to be assignedjava.lang.IllegalArgumentException - If the Class represents an interface, and no BeanValueType subclass has been generated to handle it.public static boolean isAssignableFrom(java.lang.Class<?> possibleSuperclass,
java.lang.Class<?> possibleSubclass) Like Class.assignableFrom().
possibleSuperclass - The possible super-class, or lhs of the assignmentpossibleSubclass - The possible sub-class, or rhs of the assignmentjava.lang.IllegalArgumentException - If one of the classes is an interface and the other is not. In that case, you need to use isAssignableFrom(Class<?>, Object) with the value to be assigned.public static boolean isA(com.google.gwt.core.client.JavaScriptObject value,
java.lang.String scClassName) value - The SmartClient objectscClassName - The SmartClient class name (e.g. "ListGrid")public static java.lang.Object convertToJava(com.google.gwt.core.client.JavaScriptObject obj)
This is similar to JSOHelper.convertToJava, but has several differences which are needed for BeanFactory to work properly. Note that this method may return a JavaScriptObject -- either the value itself, or possibly a new JavaScriptObject constructed from a config block. In those cases, it may be that convertFrom() can still do some further conversion on the return value, since it can take into account opportunities for conversion that are specific to the desired type. In other words, this is a generic conversion function.
object - A javascript valueObject (which may still be a JavaScriptObject).public static BeanValueType.Convertability convertabilityFrom(java.lang.Class<?> klass, java.lang.Object value)
convertFrom convert the value to the klass? This is used to choose the best setter amongst multiple setters, if there are multiple setters available.
klass - The desired class to convert to.value - The value to be converted.java.lang.IllegalArgumentException - If there is no BeanValueType subclass for the klasspublic static java.lang.Object convertFrom(java.lang.Class<?> klass,
java.lang.Object value) Note that not all conversions are actually supported ... you can check with convertabilityFrom(). The target classes which are supported are generally the classes which are used as value types in properties of BeanFactories that have been generated. The values supported depend on the target class.
klass - The class that you want to convert to.value - The value that you want to convert.java.lang.IllegalArgumentException - If there is no BeanValueType subclass for the klass, or if the BeanValueType is unable to convert the value.public static BeanValueType.Convertability convertabilityToString(java.lang.Class<?> klass)
public static java.lang.String convertToString(java.lang.Object value)
Of course, you can always call Object.toString(). However, a BeanValueType subclass might implement a different strategy.
value - The value to convert.public static com.google.gwt.core.client.JavaScriptObject wrapInJavascriptArray(java.lang.Object value)
String, or a primitive numeric type, causing type errors no matter how the return value is declared here.value - Value to convertpublic static com.google.gwt.core.client.JavaScriptObject convertToJavaScriptArray(java.lang.Object[] array)
public static com.google.gwt.core.client.JavaScriptObject convertMapToJavascriptObject(java.util.Map valueMap)
public static com.google.gwt.core.client.JavaScriptObject convertToJavaScriptObject(java.lang.Object value)
value - Value to convertprotected abstract java.lang.Class<?> getValueType()
protected abstract boolean isAssignableFrom(java.lang.Object value)
protected ValueType nullValue()
protected BeanValueType.Convertability convertabilityToString()
protected java.lang.String doConvertToString(ValueType value)
public BeanValueType.Convertability convertabilityFrom(java.lang.Object value)
public ValueType convertFrom(java.lang.Object value)
protected java.lang.IllegalArgumentException conversionException(java.lang.Object value)