public final class WidgetBuilderUtils extends Object
Some of the logic behind WidgetBuilder decisions can be a little involved, so we refactor it here.
Not located under org.metawidget.widgetbuilder.impl
because GWT cannot compile this
class.
Modifier and Type | Method and Description |
---|---|
static Class<?> |
getActualClassOrType(Map<String,String> attributes,
Class<?> defaultClass)
Looks up the TYPE attribute, but first checks the ACTUAL_CLASS attribute.
|
static Class<?> |
getActualClassOrType(Map<String,String> attributes,
Class<?> defaultClass,
ClassLoader classLoader) |
static String |
getComponentType(Map<String,String> attributes)
Looks up the type of the components in an Array or Collection.
|
static boolean |
isReadOnly(Map<String,String> attributes)
Returns whether the attributes have READ_ONLY or NO_SETTER set to TRUE.
|
static boolean |
needsEmptyLookupItem(Map<String,String> attributes)
Returns true if the lookup is nullable, not required, or has a forced empty choice.
|
public static boolean isReadOnly(Map<String,String> attributes)
The latter case relies on complex attributes being rendered by nested Metawidgets: the nested Metawidgets will not have setReadOnly set on them, which gets us the desired result. Namely, primitive types without a setter are rendered as read-only, complex types without a setter are rendered as writeable (because their nested primitives are writeable).
Furthermore, what is considered 'primitive' is up to the platform. Some platforms may consider, say, an Address as 'primitive', using a dedicated Address widget. Other platforms may consider an Address as complex, using a nested Metawidget.
public static Class<?> getActualClassOrType(Map<String,String> attributes, Class<?> defaultClass)
defaultClass
- class to default to if both ACTUAL_CLASS and TYPE are nullpublic static Class<?> getActualClassOrType(Map<String,String> attributes, Class<?> defaultClass, ClassLoader classLoader)
public static String getComponentType(Map<String,String> attributes)
Copyright © 2015. All Rights Reserved.