Package com.thingworx.metadata
Class FieldDefinition
java.lang.Object
com.thingworx.types.NamedObject
com.thingworx.metadata.FieldDefinition
- All Implemented Interfaces:
IDiffableObject,IAspectContainer,INamedObject,Serializable,Cloneable
- Direct Known Subclasses:
PropertyDefinition
@ThingworxExtensionApiClass(since={6,6},
canInstantiate=true)
public class FieldDefinition
extends NamedObject
implements IAspectContainer, Cloneable
A definition for a data field. Fields are used primarily as the storage mechanism in DataShapeDefinition, analogous to
PropertyDefinition in Things, ThingTemplates, and ThingShapes. Fields are also used in services for
defining the input parameters and the result.
Field definitions can be organized according to ordinality and assigned special behavioral properties called "aspects". An aspect is a
key-value pair where the value conforms to one of the primitives in the BaseTypes enumeration. The aspects that can be assigned
to a field definition are defined in the Aspects class.
- See Also:
-
Field Summary
Fields inherited from class com.thingworx.types.NamedObject
NAME_COMPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new unnamed field definition with the default base type of STRING.FieldDefinition(String name, BaseTypes baseType) Constructs a new field definition with the specified name and base type.FieldDefinition(String name, BaseTypes baseType, AspectCollection aspects) Constructs a new field definition with the specified name, base type, and aspects.FieldDefinition(String name, String description) Constructs a new field definition with the specified name and description.FieldDefinition(String name, String description, BaseTypes baseType) Constructs a new field definition with the specified name, description, and base type.FieldDefinition(String name, String description, BaseTypes baseType, AspectCollection aspects) Constructs a new field definition with the specified name, description, base type, and aspects. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaspectsMatch(AspectCollection aspects) Determines whether or not the aspects assigned to this field are equivalent to the aspects in the provided collection.clone()Creates a deep clone of this field definition.Returns the collection of aspects belonging to this field.Returns the base type assigned to this field definition.Returns the data shape name assigned to theASPECT_DATASHAPEaspect, if the base type for this field is set toINFOTABLE.Returns the default value assigned to this field, if one has been defined according to theASPECT_DEFAULTVALUEaspect.Returns the ordinal value assigned to this field.booleanDetermines if, when the base type of this field is anINFOTABLE, a data shape has been assigned.booleanDetermines if this field has a default value according to theASPECT_DEFAULTVALUEaspect.booleanDetermines if, when the base type of this field is anINFOTABLE, the contents of the info table will be derived from a content crawler entry.booleanDetermines if, when the base type of this field is anINFOTABLE, the contents of the info table will be derived from a data table entry.booleanDetermines if this field has theASPECT_ISPRIMARYKEYaspect set totrue.Determines if this field has theASPECT_ISPRIVATEaspect set totrue.booleanDetermines if, the service parameter is marked as a query parameterDetermines if this field has theASPECT_ISREQUIREDaspect set totrue.booleanDetermines if, when the base type of this field is anINFOTABLE, the contents of the info table will be derived from a stream entry.voidsetAspects(AspectCollection value) Replaces all aspects on this field with the aspects in the specified collection.voidsetBaseType(BaseTypes baseType) Assigns the specified base type to this field.voidsetOrdinal(Integer ordinal) Sets the ordinal value for this field.Methods inherited from class com.thingworx.types.NamedObject
getDescription, getName, setDescription, setName, toValueCollection
-
Constructor Details
-
FieldDefinition
Constructs a new unnamed field definition with the default base type of STRING. -
FieldDefinition
Constructs a new field definition with the specified name and description. The base type will be set to the default of STRING.- Parameters:
name- the namedescription- the description
-
FieldDefinition
@ThingworxExtensionApiMethod(since={6,6}) public FieldDefinition(String name, String description, BaseTypes baseType) Constructs a new field definition with the specified name, description, and base type. If the supplied base type is null, the default of STRING will be used.- Parameters:
name- the namedescription- the descriptionbaseType- the base type
-
FieldDefinition
@ThingworxExtensionApiMethod(since={7,1}) public FieldDefinition(String name, BaseTypes baseType, AspectCollection aspects) Constructs a new field definition with the specified name, base type, and aspects. If the supplied base type is null, the default of STRING will be used.- Parameters:
name- the namebaseType- the base typeaspects- a collection of aspects belonging to this field
-
FieldDefinition
@ThingworxExtensionApiMethod(since={7,1}) public FieldDefinition(String name, String description, BaseTypes baseType, AspectCollection aspects) Constructs a new field definition with the specified name, description, base type, and aspects. If the supplied base type is null, the default of STRING will be used.- Parameters:
name- the namedescription- the descriptionbaseType- the base typeaspects- a collection of aspects belonging to this field
-
FieldDefinition
Constructs a new field definition with the specified name and base type. If the supplied base type is null, the default of STRING will be used.- Parameters:
name- the namebaseType- the base type
-
-
Method Details
-
getBaseType
Returns the base type assigned to this field definition.- Returns:
- this field definition's base type
-
setBaseType
Assigns the specified base type to this field. Any persisted data that refers to this field may not be accessible if the base type is changed to an incompatible type. If the supplied value is null, this will perform a no-op.- Parameters:
baseType- the base type to assign to this field
-
getOrdinal
Returns the ordinal value assigned to this field.- Returns:
- the ordinal value
-
setOrdinal
Sets the ordinal value for this field. If the supplied value is null, this will perform a no-op.- Parameters:
ordinal- the new ordinal value
-
isPrivate
Determines if this field has theASPECT_ISPRIVATEaspect set totrue.- Returns:
trueif this field has the aspect and it is set totrue,falseotherwise
-
isRequired
Determines if this field has theASPECT_ISREQUIREDaspect set totrue.- Returns:
trueif this field has the aspect and it is set totrue,falseotherwise
-
isPrimaryKey
Determines if this field has theASPECT_ISPRIMARYKEYaspect set totrue.- Returns:
trueif this field has the aspect and it is set totrue,falseotherwise
-
getDefaultValue
Returns the default value assigned to this field, if one has been defined according to theASPECT_DEFAULTVALUEaspect.- Returns:
- the default value of this field, or
nullif none has been defined
-
hasDefaultValue
Determines if this field has a default value according to theASPECT_DEFAULTVALUEaspect.- Returns:
trueif this field has a default value
-
setAspects
Replaces all aspects on this field with the aspects in the specified collection.- Parameters:
value- the aspects that will be assigned to this field
-
getAspects
Returns the collection of aspects belonging to this field.- Returns:
- this field's collection of aspects
-
aspectsMatch
Determines whether or not the aspects assigned to this field are equivalent to the aspects in the provided collection.- Parameters:
aspects- a collection of aspects to compare against- Returns:
trueif the aspects are equivalent
-
clone
Creates a deep clone of this field definition. -
hasDataShape
Determines if, when the base type of this field is anINFOTABLE, a data shape has been assigned.- Returns:
trueif the base type is set toINFOTABLEand a value is set to theASPECT_DATASHAPEaspect
-
isStreamEntry
Determines if, when the base type of this field is anINFOTABLE, the contents of the info table will be derived from a stream entry.- Returns:
trueif the base type is set toINFOTABLEand theASPECT_ISSTREAMENTRYaspect is set totrue
-
isDataTableEntry
Determines if, when the base type of this field is anINFOTABLE, the contents of the info table will be derived from a data table entry.- Returns:
trueif the base type is set toINFOTABLEand theASPECT_ISDATATABLEENTRYaspect is set totrue
-
isQueryParameter
Determines if, the service parameter is marked as a query parameter- Returns:
trueASPECT_ISQUERYPARAMETERaspect is set totrue
-
isContentCrawlerEntry
Determines if, when the base type of this field is anINFOTABLE, the contents of the info table will be derived from a content crawler entry.- Returns:
trueif the base type is set toINFOTABLEand theASPECT_ISCONTENTCRAWLERENTRYaspect is set totrue
-
getDataShapeName
Returns the data shape name assigned to theASPECT_DATASHAPEaspect, if the base type for this field is set toINFOTABLE.- Returns:
- the data shape name assigned to this field if the base type is set to
INFOTABLE, ornullif no data shape name has been assigned or the base type is notINFOTABLE
-