Class TLcdDataTypeBuilder
Builder that allows the creation of a TLcdDataType
. The type is created when
the data model of this type is created.
Instances of this class can be created via the TLcdDataModelBuilder
in which the type is to be defined.
References to other types (for instance to indicate the super type or the type
of a property) can be done using a TLcdDataType
instance,
a string denoting the name of a type in the data model that is being built,
or another type builder.
- Since:
- 10.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
This factory interface offers a convenient way to annotate a type while it is being built. -
Method Summary
Modifier and TypeMethodDescriptionabstractType
(boolean aIsAbstract) Determines if the type to be built will be abstract or not.addProperty
(String aName, TLcdDataType aType) Adds a property with the given name and type to the type that is being built.addProperty
(String aName, TLcdDataTypeBuilder aTypeBuilder) Adds a property with the given name and type to the type that is being built.addProperty
(String aName, String aType) Adds a property with the given name and type to the type that is being built.annotate
(ILcdAnnotation aAnnotation) Adds an annotation to the type that is being built.annotateFromFactory
(TLcdDataTypeBuilder.TypeAnnotationFactory<?> aAnnotationFactory) Annotates the type that is being built.dataObjectFactory
(ILcdDataObjectFactory aFactory) Sets the object factory to use for this type.Returns the data model builder for the data model that contains the type that is being built by this type builder.getDataPropertyBuilder
(String aPropertyName) Returns the property builder for the given property name.Returns a list containing all the property builders of this data type builder.getName()
Returns the name of the type that is being built.instanceClass
(Class<?> aInstanceClass) Sets the instance class for this type.possibleValues
(Object... aObjects) Marks the type as an enumeration and provides it with all possible values.possibleValues
(Set<?> aValues) Marks the type as an enumeration and provides it with all possible values.primitive
(boolean aIsPrimitive) Defines whether or not the type that is being built will be a primitive type.superType
(TLcdDataType aSuperType) Sets the super type of this type to the given type.superType
(TLcdDataTypeBuilder aTypeBuilder) Sets the super type of this type to the given type.Sets the super type of this type to the given type.toString()
-
Method Details
-
superType
Sets the super type of this type to the given type.- Parameters:
aSuperType
- the type to use as super type- Returns:
- this
-
superType
Sets the super type of this type to the given type. The default super type for a data object type isTLcdCoreDataTypes.DATA_OBJECT_TYPE
, for a primitive type isTLcdCoreDataTypes.OBJECT_TYPE
.- Parameters:
aName
- the name of a type in this builder's data model to use as super type- Returns:
- this
-
superType
Sets the super type of this type to the given type. The default super type for a data object type isTLcdCoreDataTypes.DATA_OBJECT_TYPE
, for a primitive type isTLcdCoreDataTypes.OBJECT_TYPE
.- Parameters:
aTypeBuilder
- a type builder of which the type is to be used as super type- Returns:
- this
-
primitive
Defines whether or not the type that is being built will be a primitive type. The default value for this property is false.- Parameters:
aIsPrimitive
- boolean that specifies if the type to be built will be primitive or not- Returns:
- this
-
instanceClass
Sets the instance class for this type. The default instance class for data object types isILcdDataObject
, for primitive typesjava.lang.Object
.- Parameters:
aInstanceClass
- the Java class that is to be used as instance class for the type that is being built- Returns:
- this
-
getName
Returns the name of the type that is being built.- Returns:
- the name of the type that is being built
-
toString
-
abstractType
Determines if the type to be built will be abstract or not. By default a type is not abstract.- Parameters:
aIsAbstract
- boolean that specifies if the data type is to abstract- Returns:
- this
-
possibleValues
Marks the type as an enumeration and provides it with all possible values. This happens automatically in case the instance class is ajava.lang.Enum
. The type will automatically be made primitive.- Parameters:
aObjects
- list of all values this enumeration can take.null
should never be considered as a possible value; if a property may be null, this should be indicated through theTLcdDataProperty.isNullable()
flag.- Returns:
- this
-
possibleValues
Marks the type as an enumeration and provides it with all possible values. This happens automatically in case the instance class is ajava.lang.Enum
. The type will automatically be made primitive.- Parameters:
aValues
- set of all values this enumeration can take.null
should never be considered as a possible value; if a property may be null, this should be indicated through theTLcdDataProperty.isNullable()
flag.- Returns:
- this
-
addProperty
Adds a property with the given name and type to the type that is being built. The returned property builder is single valued, contained and nullable.
The name of the property can only contain letters, digits, periods ('.'), dashes ('-'), and underscores ('_').
- Parameters:
aName
- the name of the property that is to be addedaType
- the type for the property that is to be added- Returns:
- a property builder that can be used to further modify the property that is to be added
-
addProperty
Adds a property with the given name and type to the type that is being built. The returned property builder is single valued, contained and nullable.
The name of the property can only contain letters, digits, periods ('.'), dashes ('-'), and underscores ('_').
- Parameters:
aName
- the name of the property that is to be addedaType
- the name of a type in this builder's data model for the property that is to be added- Returns:
- a property builder that can be used to further modify the property that is to be added
-
getDataPropertyBuilders
Returns a list containing all the property builders of this data type builder.- Returns:
- a list containing all property builders of this data type
- Throws:
UnsupportedOperationException
- when the returned list is modified
-
getDataPropertyBuilder
Returns the property builder for the given property name. If a property for the given name does not exist this method will returnnull
.- Parameters:
aPropertyName
- the property name- Returns:
- a property builder or
null
-
addProperty
Adds a property with the given name and type to the type that is being built. The returned property builder is single valued, contained and nullable.
The name of the property can only contain letters, digits, periods ('.'), dashes ('-'), and underscores ('_').
- Parameters:
aName
- the name of the property that is to be addedaTypeBuilder
- a type builder for the type of the property that is to be added- Returns:
- a property builder that can be used to further modify the property that is to be added
-
getDataModelBuilder
Returns the data model builder for the data model that contains the type that is being built by this type builder.- Returns:
- the associated data model builder
-
dataObjectFactory
Sets the object factory to use for this type.- Parameters:
aFactory
- the object factory to use for this type- Returns:
- this
-
annotate
Adds an annotation to the type that is being built. The annotation can be retrieved on the type usingTLcdDataType.getAnnotation(Class)
.- Parameters:
aAnnotation
- the annotation to add- Returns:
- this
-
annotateFromFactory
public TLcdDataTypeBuilder annotateFromFactory(TLcdDataTypeBuilder.TypeAnnotationFactory<?> aAnnotationFactory) Annotates the type that is being built. The actual annotation is the return value of
TLcdDataTypeBuilder.TypeAnnotationFactory.createAnnotation(TLcdDataType)
. Once the type is created, the annotation can be retrieved usingTLcdDataType.getAnnotation(Class)
.The use of the factory makes it possible to refer to the type from inside the annotation. The actual annotation value will be created at the end of the initialization of the type.
- Parameters:
aAnnotationFactory
- a factory that is able to create the value of the annotation- Returns:
- this
-