Package org.ametys.runtime.model
Class ElementDefinition<T>
java.lang.Object
org.ametys.runtime.model.AbstractModelItem
org.ametys.runtime.model.ElementDefinition<T>
- Type Parameters:
T
- Type of the element value
- All Implemented Interfaces:
Comparable<ModelItem>
,ModelItem
,Labelable
,ModifiableLabelable
- Direct Known Subclasses:
AttributeDefinition
,ServiceParameter
,ViewParameter
The definition of a single model item (parameter, attribute)
-
Field Summary
Modifier and TypeFieldDescriptionprotected Logger
The definition loggerstatic final String
config type for default valuesFields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManager
Fields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR
-
Constructor Summary
ConstructorDescriptionDefault constructor.ElementDefinition
(String name, boolean isMultiple, ElementType<T> type) Constructor used to create simple models and itemsElementDefinition
(ElementDefinition<T> definitionToCopy) Constructor by copying an existingElementDefinition
. -
Method Summary
Modifier and TypeMethodDescriptionprotected T
_getDefaultValue
(String defaultValueType, Object parsedDefaultValue) Retrieves the default value from the parsed one, according to the type of the default valueRetrieves the parsed default values_toJSON
(DefinitionContext context) Converts the model item in a JSON mapRetrieves the custom enumerator's class nameRetrieves the custom validator's class name<X> X
Retrieves the default value, as an object corresponding to the definition's type and cardinality Retrievesnull
if no default value is defined for this definitionRetrieves the disable condition.Retrieves the enumerator.Retrieves the custom enumerator's configurationRetrieves the name of the plugin declaring this element.getType()
Retrieves the type.Retrieves the validator.Retrieves the custom validator's configuraitonRetrieves the widget to use for rendering.Get the widget's parametersboolean
Test if the element is multiple.static ElementDefinition
Creates anElementDefinition
void
setCustomEnumerator
(String customEnumerator) Set the custom enumerator's class namevoid
setCustomValidator
(String customValidator) Set the custom validator's class namevoid
setDefaultValue
(T defaultValue) Set a default value to the definition The default value is single, classic default valuevoid
setDisableConditions
(DisableConditions disableConditions) Sets the disable condition.void
setEnumerator
(Enumerator<T> enumerator) Set the enumerator.void
setEnumeratorConfiguration
(Configuration enumeratorConfiguration) Set the custom enumerator's configurationvoid
setMultiple
(boolean isMultiple) Set the element multiple status.void
setParsedDefaultValues
(List<Pair<String, Object>> parsedDefaultValues) Set the parsed default values.void
setPluginName
(String pluginName) Set the name of the plugin declaring this element.void
setType
(ModelItemType type) Set the type.void
setValidator
(Validator validator) Set the validator.void
setValidatorConfiguration
(Configuration validatorConfiguration) Set the custom validator's configurationvoid
Set the widget.void
setWidgetParameters
(Map<String, I18nizableText> params) Set the widget's parametersMethods inherited from class org.ametys.runtime.model.AbstractModelItem
_shouldJSONBeEmpty, addItemChecker, compareTo, equals, getDescription, getItemCheckers, getLabel, getModel, getName, getParent, getPath, hashCode, setDescription, setLabel, setModel, setName, setParent, setServiceManager, toJSON, toString
-
Field Details
-
CONFIG_DEFAULT_VALUE_TYPE
config type for default values- See Also:
-
_logger
The definition logger
-
-
Constructor Details
-
ElementDefinition
public ElementDefinition()Default constructor. -
ElementDefinition
Constructor used to create simple models and items- Parameters:
name
- the name of the definitionisMultiple
- the element multiple statustype
- the type of the definition
-
ElementDefinition
Constructor by copying an existingElementDefinition
.- Parameters:
definitionToCopy
- TheElementDefinition
to copy
-
-
Method Details
-
getPluginName
Retrieves the name of the plugin declaring this element.- Returns:
- the plugin name.
-
setPluginName
Set the name of the plugin declaring this element.- Parameters:
pluginName
- the plugin name.
-
getType
Description copied from interface:ModelItem
Retrieves the type.- Returns:
- the type.
-
setType
Description copied from interface:ModelItem
Set the type.- Parameters:
type
- the type.
-
getWidget
Retrieves the widget to use for rendering.- Returns:
- the widget or
null
if none is defined.
-
setWidget
Set the widget.- Parameters:
widget
- the widget.
-
getWidgetParameters
Get the widget's parameters- Returns:
- the widget's parameters
-
setWidgetParameters
Set the widget's parameters- Parameters:
params
- the parameters to set
-
getEnumerator
Retrieves the enumerator.- Returns:
- the enumerator or
null
if none is defined.
-
setEnumerator
Set the enumerator.- Parameters:
enumerator
- the enumerator.
-
getCustomEnumerator
Retrieves the custom enumerator's class name- Returns:
- the custom enumerator's class name
-
setCustomEnumerator
Set the custom enumerator's class name- Parameters:
customEnumerator
- the custom enumerator's class name
-
getEnumeratorConfiguration
Retrieves the custom enumerator's configuration- Returns:
- the custom enumerator's configuration
-
setEnumeratorConfiguration
Set the custom enumerator's configuration- Parameters:
enumeratorConfiguration
- the custom enumerator's configuration
-
getValidator
Retrieves the validator.- Returns:
- the validator or
null
if none is defined.
-
setValidator
Set the validator.- Parameters:
validator
- the validator.
-
getCustomValidator
Retrieves the custom validator's class name- Returns:
- the custom validator's class name
-
setCustomValidator
Set the custom validator's class name- Parameters:
customValidator
- the custom validator's class name
-
getValidatorConfiguration
Retrieves the custom validator's configuraiton- Returns:
- the custom validator's configuration
-
setValidatorConfiguration
Set the custom validator's configuration- Parameters:
validatorConfiguration
- the custom validator's configuration
-
getDefaultValue
Retrieves the default value, as an object corresponding to the definition's type and cardinality Retrievesnull
if no default value is defined for this definition- Type Parameters:
X
- The type of the default value- Returns:
- the default value.
-
_getDefaultValue
Retrieves the default value from the parsed one, according to the type of the default value- Parameters:
parsedDefaultValue
- the parsed default value (can be anI18nizableText
, a config parameter name, ... depending on the default value type)defaultValueType
- the type of the default value- Returns:
- the default value.
-
setParsedDefaultValues
Set the parsed default values. If the definition is not multiple, the list should contain only one element A parsed default value is described by its type and an object depending on the type- Parameters:
parsedDefaultValues
- the parsed default values.
-
setDefaultValue
Set a default value to the definition The default value is single, classic default value- Parameters:
defaultValue
- the default value to set
-
_getParsedDefaultValues
Retrieves the parsed default values- Returns:
- the parsed default values
-
isMultiple
Test if the element is multiple.- Returns:
true
if the metadata is multiple.
-
setMultiple
Set the element multiple status.- Parameters:
isMultiple
- the element multiple status.
-
getDisableConditions
Retrieves the disable condition.- Returns:
- the disable condition or
null
if none is defined.
-
setDisableConditions
Sets the disable condition.- Parameters:
disableConditions
- the disable condition.
-
_toJSON
Description copied from class:AbstractModelItem
Converts the model item in a JSON map- Overrides:
_toJSON
in classAbstractModelItem
- Parameters:
context
- the context of the definition- Returns:
- The model item as a JSON map
- Throws:
ProcessingException
- If an error occurs when converting the model item
-
of
public static ElementDefinition of(String name, boolean isMultiple, String typeId, String availableTypesExtensionPoint) throws UnknownTypeException, BadItemTypeException, ServiceException Creates anElementDefinition
- Parameters:
name
- the definition's nameisMultiple
- the definition's cardinalitytypeId
- the definition's type identifieravailableTypesExtensionPoint
- the role of the extension point containing all available types for thisElementDefinition
- Returns:
- the created
ElementDefinition
- Throws:
UnknownTypeException
- if the given type identifier is not available in the extension pointBadItemTypeException
- if the given type identifier can not be used for anElementDefinition
ServiceException
- if an error occurs while getting the extension point of available types
-