Class ModelViewer
java.lang.Object
de.aristaflow.adept2.model.common.viewer.ModelViewer
Allows the creation of typed views on attribute maps.
Constraints for the view:
TODO unset attributes: return default values? "not-existing-value" like e.g. INTEGER_MIN_VALUE? => define values!
TODO exception handling: external handler, default handlers... above -> default values?
TODO annotation for the interface, e.g. a description etc.
- Author:
- Kevin Goeser
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe set of types which are allowed to beSystemDataConsumer.Set of types, which are allowed as return values and parameters.static final Class<?>[]Array of types, which are allowed as return values and parameters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> VCreate a new, empty view for performing changes.static <V> VcreateView(Map<String, String> attributes, Class<V> view) Creates a new view on the given data, implementing the given interface.protected static <V> VCreates a translating view, returning the values for the given locale.static <V> VCreates a new view on the given data, implementing the given interface.
-
Field Details
-
allowedTypesArray
Array of types, which are allowed as return values and parameters. -
allowedTypes
Set of types, which are allowed as return values and parameters. -
allowedConsumerTypes
The set of types which are allowed to beSystemDataConsumer.
-
-
Constructor Details
-
ModelViewer
public ModelViewer()
-
-
Method Details
-
createView
Creates a new view on the given data, implementing the given interface.The interface needs to match the constraints provided in the class description of
ModelViewer.- Type Parameters:
V- The type of the view.- Parameters:
attributes- The data for the view.view- The view interface.- Returns:
- A view of type
viewon the attributes. The returned object must only be accessed via the designated view interface!
-
createView
Creates a new view on the given data, implementing the given interface.The interface needs to match the constraints provided in the class description of
ModelViewer.- Type Parameters:
V- The type of the view.- Parameters:
attributes- The data for the view.view- The view interface.locale- The locale for a translated view.- Returns:
- A view of type
viewon the attributes. The returned object must only be accessed via the designated view interface!
-
createNew
Create a new, empty view for performing changes. This is useful for creating views of nested views, ie. where the view object itself is set into another view.
When connecting the created view to the parent view (calling the appropriate set-method), only a copy of the new view will be added to the parent. If you need the very same nested object, retrieve it from the parent right after connecting it and replace the created view with the retrieved one.- Type Parameters:
V-- Parameters:
view-- Returns:
- A new view with an empty attribute map.
-
createView
protected static <V> V createView(Map<String, String> attributes, Class<V> view, String prefix, Locale locale) Creates a translating view, returning the values for the given locale.- Type Parameters:
V-- Parameters:
attributes-view-prefix- Prefix, if not "", it must end with a '.'.locale-- Returns:
-