public class TLcdDataTypeBuilder extends Object
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.
TLcdDataModelBuilder
Modifier and Type | Class and Description |
---|---|
static interface |
TLcdDataTypeBuilder.TypeAnnotationFactory<T extends ILcdAnnotation>
This factory interface offers a convenient way to annotate a type while it is being
built.
|
Modifier and Type | Method and Description |
---|---|
TLcdDataTypeBuilder |
abstractType(boolean aIsAbstract)
Determines if the type to be built will be abstract or not.
|
TLcdDataPropertyBuilder |
addProperty(String aName,
String aType)
Adds a property with the given name and type to the type that is being built.
|
TLcdDataPropertyBuilder |
addProperty(String aName,
TLcdDataType aType)
Adds a property with the given name and type to the type that is being built.
|
TLcdDataPropertyBuilder |
addProperty(String aName,
TLcdDataTypeBuilder aTypeBuilder)
Adds a property with the given name and type to the type that is being built.
|
TLcdDataTypeBuilder |
annotate(ILcdAnnotation aAnnotation)
Adds an annotation to the type that is being built.
|
TLcdDataTypeBuilder |
annotateFromFactory(TLcdDataTypeBuilder.TypeAnnotationFactory<?> aAnnotationFactory)
Annotates the type that is being built.
|
TLcdDataTypeBuilder |
dataObjectFactory(ILcdDataObjectFactory aFactory)
Sets the object factory to use for this type.
|
TLcdDataModelBuilder |
getDataModelBuilder()
Returns the data model builder for the data model that contains the type that
is being built by this type builder.
|
TLcdDataPropertyBuilder |
getDataPropertyBuilder(String aPropertyName)
Returns the property builder for the given property name.
|
List<TLcdDataPropertyBuilder> |
getDataPropertyBuilders()
Returns a list containing all the property builders of this data type builder.
|
String |
getName()
Returns the name of the type that is being built.
|
TLcdDataTypeBuilder |
instanceClass(Class<?> aInstanceClass)
Sets the instance class for this type.
|
TLcdDataTypeBuilder |
possibleValues(Object... aObjects)
Marks the type as an enumeration and provides it with all possible values.
|
TLcdDataTypeBuilder |
possibleValues(Set<?> aValues)
Marks the type as an enumeration and provides it with all possible values.
|
TLcdDataTypeBuilder |
primitive(boolean aIsPrimitive)
Defines whether or not the type that is being built will be a primitive type.
|
TLcdDataTypeBuilder |
superType(String aName)
Sets the super type of this type to the given type.
|
TLcdDataTypeBuilder |
superType(TLcdDataType aSuperType)
Sets the super type of this type to the given type.
|
TLcdDataTypeBuilder |
superType(TLcdDataTypeBuilder aTypeBuilder)
Sets the super type of this type to the given type.
|
String |
toString() |
public TLcdDataTypeBuilder superType(TLcdDataType aSuperType)
aSuperType
- the type to use as super typepublic TLcdDataTypeBuilder superType(String aName)
TLcdCoreDataTypes.DATA_OBJECT_TYPE
,
for a primitive type is TLcdCoreDataTypes.OBJECT_TYPE
.aName
- the name of a type in this builder's data model to use as super typepublic TLcdDataTypeBuilder superType(TLcdDataTypeBuilder aTypeBuilder)
TLcdCoreDataTypes.DATA_OBJECT_TYPE
,
for a primitive type is TLcdCoreDataTypes.OBJECT_TYPE
.aTypeBuilder
- a type builder of which the type is to be used as super typepublic TLcdDataTypeBuilder primitive(boolean aIsPrimitive)
aIsPrimitive
- boolean that specifies if the type to be built will be primitive or notpublic TLcdDataTypeBuilder instanceClass(Class<?> aInstanceClass)
ILcdDataObject
, for primitive types java.lang.Object
.aInstanceClass
- the Java class that is to be used as instance class for the type that is being builtpublic String getName()
public TLcdDataTypeBuilder abstractType(boolean aIsAbstract)
aIsAbstract
- boolean that specifies if the data type is to abstractpublic TLcdDataTypeBuilder possibleValues(Object... aObjects)
java.lang.Enum
.
The type will automatically be made primitive.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 the
TLcdDataProperty.isNullable()
flag.public TLcdDataTypeBuilder possibleValues(Set<?> aValues)
java.lang.Enum
.
The type will automatically be made primitive.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 the
TLcdDataProperty.isNullable()
flag.public TLcdDataPropertyBuilder addProperty(String aName, TLcdDataType aType)
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 and the '_' character.
aName
- the name of the property that is to be addedaType
- the type for the property that is to be addedpublic TLcdDataPropertyBuilder addProperty(String aName, String aType)
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 and the '_' character.
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 addedpublic List<TLcdDataPropertyBuilder> getDataPropertyBuilders()
UnsupportedOperationException
- when the returned list is modifiedpublic TLcdDataPropertyBuilder getDataPropertyBuilder(String aPropertyName)
null
.aPropertyName
- the property namenull
public TLcdDataPropertyBuilder addProperty(String aName, TLcdDataTypeBuilder aTypeBuilder)
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 and the '_' character.
aName
- the name of the property that is to be addedaTypeBuilder
- a type builder for the type of the property that is to be addedpublic TLcdDataModelBuilder getDataModelBuilder()
public TLcdDataTypeBuilder dataObjectFactory(ILcdDataObjectFactory aFactory)
aFactory
- the object factory to use for this typepublic TLcdDataTypeBuilder annotate(ILcdAnnotation aAnnotation)
TLcdDataType.getAnnotation(Class)
.aAnnotation
- the annotation to addpublic 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
using TLcdDataType.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.
aAnnotationFactory
- a factory that is able to create the value of the annotation