public abstract class FieldDef extends SchemaPart implements Cloneable, SchemaProblemsSupplier
internalId, internalName, log, TIMESTAMP_FORMAT
SERIALIZED_CLASS_NAME, TYPE
XML_SERIALIZED_CLASS_NAME
Constructor and Description |
---|
FieldDef() |
FieldDef(String name,
FieldType type) |
Modifier and Type | Method and Description |
---|---|
FieldDef |
assertValid() |
FieldDef |
clone() |
boolean |
equals(Object obj) |
FieldDef |
fromJson(String jsonString) |
FieldDef |
fromRecord(Record source)
Loads this instance's state from a record and returns
this (for fluid API call chaining). |
FieldDef |
fromXmlElement(Element fieldDefElement) |
protected void |
generateConstructor(JavaCodeBuilder code,
CodeWriter writer) |
void |
generateJavaCode(JavaCodeBuilder code) |
ValueMatch<?> |
getAllowedValues()
The optional set of values this field allows.
|
Attributes |
getAttributes()
User-defined key-value pairs to attached arbitrary metadata to this field.
|
Expression |
getDefaultValueExpression()
The calculated value to set in the data if the field is null or missing.
|
String |
getDefaultValueExpressionAsString()
The calculated value to set in the data if the field is null or missing.
|
String |
getDescription()
The human-readable summary of this field.
|
String |
getDisplayName()
The user-friendly name for this field.
|
String |
getDisplayNameOrName()
The user-friendly name for this field if one is set or the
getName() value otherwise. |
EntityDef |
getEntityDef()
The parent entity containing this field.
|
String |
getEntityQualifiedName()
Returns the qualified name that includes the name of this field and the
EntityDef above it separated by period. |
String |
getExample()
A human-readable example of values supported by this field.
|
int |
getIndexInEntityDef()
Returns the zero-based index of this field in
EntityDef . |
Integer |
getMaximumElements()
The maximum numbers of array elements allowed by this array field.
|
Integer |
getMinimumElements()
The minimum numbers of array elements allowed by this array field.
|
String |
getName()
The human-readable text identifier for this field.
|
String |
getNameForErrorMessage()
The fully-qualified name for use in error and validation messages using
getDisplayNameOrName() for each name segment. |
Integer |
getPosition()
The zero-based location of this field in the data (if applicable).
|
Integer |
getPrimaryKeyPosition() |
PrimaryKeyType |
getPrimaryKeyType() |
String |
getQualifiedName()
Returns the fully qualified name that includes the name of this field definition and all names in its hierarchy separated by period.
|
SchemaDef |
getSchemaDef()
The schema of the parent entity containing this field.
|
SchemaDef |
getSchemaDef(boolean throwException) |
SchemaPart |
getSchemaPartContainer() |
String |
getSchemaPartName() |
SchemaPartType |
getSchemaPartType() |
void |
getSchemaProblems(List<SchemaProblem> problems,
boolean includeChildren) |
Tags |
getTags()
The set of labels used to organize, filter, and classify this field.
|
FieldType |
getType()
The data type of this field.
|
int |
hashCode() |
boolean |
isArray()
Indicates if either
getMinimumElements() or getMaximumElements() are not null. |
boolean |
isLimitToAllowedValues()
Indicates if values not it
getAllowedValues() are allowed. |
boolean |
isPrimaryKey()
Returns
true if primaryKeyPosition is not null. |
boolean |
isRequired()
Indicates if this field can be null or missing.
|
boolean |
isStrictArrays()
Indicates if arrays should be strictly handled as arrays (default/true) or if an array with one value can be treated and a non-array and vice-versa (false).
|
Object |
mapValue(Object sourceValue) |
protected Object |
mapValueImpl(Object value) |
static FieldDef |
newInstanceFromRecord(Record fieldDefRecord) |
static FieldDef |
newInstanceFromType(String type) |
static FieldDef |
newInstanceFromXml(Element fieldDefElement) |
FieldDef |
setAllowedValues(ValueMatch<?> allowedValues) |
FieldDef |
setArray(boolean array)
Forces this field to be an array by setting the
getMinimumElements() to zero (0) if both getMinimumElements() and getMaximumElements() are null, otherwise, does nothing. |
FieldDef |
setAttributes(Attributes attributes) |
FieldDef |
setDefaultValueExpression(Expression defaultValueExpression)
The calculated value to set in the data if the field is null or missing.
|
FieldDef |
setDescription(String description) |
FieldDef |
setDisplayName(String displayName) |
protected FieldDef |
setEntityDef(EntityDef entityDef) |
FieldDef |
setExample(String example) |
FieldDef |
setLimitToAllowedValues(boolean limitToAllowedValues) |
FieldDef |
setMaximumElements(Integer maximumElements) |
FieldDef |
setMinimumElements(Integer minimumElements) |
FieldDef |
setName(String name) |
FieldDef |
setPosition(Integer position) |
FieldDef |
setPrimaryKeyPosition(Integer primaryKeyPosition) |
FieldDef |
setPrimaryKeyType(PrimaryKeyType primaryKeyType) |
FieldDef |
setRequired(boolean required) |
FieldDef |
setStrictArrays(boolean strictArrays) |
FieldDef |
setTags(Tags tags) |
FieldDef |
setType(FieldType type) |
String |
toJson() |
Record |
toRecord() |
Element |
toXmlElement(Document document) |
protected void |
validateAllowedValues(Object value,
ValidationResult result) |
ValidationResult |
validateField(Field field) |
ValidationResult |
validateField(Field field,
ValidationResult result) |
ValidationResult |
validateField(Record record) |
ValidationResult |
validateField(Record record,
ValidationResult result) |
ValidationResult |
validateValue(Object value) |
ValidationResult |
validateValue(Object value,
ValidationResult result) |
protected abstract void |
validateValueImpl(Object value,
ValidationResult result) |
getSchemaName, getSchemaPartContainerName, getSchemaPartContainerType
addExceptionProperties, assertValid, exception, exception, exception, getInternalId, getInternalName, resetInternalId
finalize, getClass, notify, notifyAll, wait, wait, wait
getSchemaProblems, getSchemaProblems
fromArrayValue, fromArrayValue, fromArrayValue, fromJson, newInstanceFromRecord, toArrayValue, toJson, toJson, toRecord
newInstanceFromJson
forEachGrandChildElement, fromXml, fromXml, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getChildElement, getChildElements, newInstanceFromXml, newInstanceFromXml, setAttribute, toXml, toXml, toXml, toXml, toXml, writeXml, writeXml
addExceptionProperties, contributeExceptionProperties, contributeExceptionProperties
public void getSchemaProblems(List<SchemaProblem> problems, boolean includeChildren)
getSchemaProblems
in interface SchemaProblemsSupplier
public FieldDef clone()
clone
in class FoundationObject
public ValidationResult validateField(Record record)
public ValidationResult validateField(Record record, ValidationResult result)
public final ValidationResult validateField(Field field)
public final ValidationResult validateField(Field field, ValidationResult result)
public FieldDef assertValid()
assertValid
in class FoundationObject
public final ValidationResult validateValue(Object value)
public final ValidationResult validateValue(Object value, ValidationResult result)
protected void validateAllowedValues(Object value, ValidationResult result)
protected abstract void validateValueImpl(Object value, ValidationResult result) throws Throwable
Throwable
protected void generateConstructor(JavaCodeBuilder code, CodeWriter writer)
public void generateJavaCode(JavaCodeBuilder code)
generateJavaCode
in interface JavaCodeGenerator
public EntityDef getEntityDef()
public SchemaDef getSchemaDef(boolean throwException)
public SchemaDef getSchemaDef()
getSchemaDef
in class SchemaPart
public SchemaPart getSchemaPartContainer()
getSchemaPartContainer
in class SchemaPart
public SchemaPartType getSchemaPartType()
getSchemaPartType
in class SchemaPart
public String getSchemaPartName()
getSchemaPartName
in class SchemaPart
public String getName()
public String getQualifiedName()
public String getEntityQualifiedName()
EntityDef
above it separated by period.public String getDisplayName()
public String getDisplayNameOrName()
getName()
value otherwise.public String getNameForErrorMessage()
getDisplayNameOrName()
for each name segment.public String getDescription()
public FieldType getType()
public boolean isRequired()
public FieldDef setRequired(boolean required)
public Integer getMinimumElements()
getMaximumElements()
property are not null.
Negative values will be set to zero (0).public Integer getMaximumElements()
getMinimumElements()
property are not null.
Negative values will be set to the max integer (2147483647). Zero (0) is allowed, it means the array must always be empty.public boolean isArray()
getMinimumElements()
or getMaximumElements()
are not null.public FieldDef setArray(boolean array)
getMinimumElements()
to zero (0) if both getMinimumElements()
and getMaximumElements()
are null, otherwise, does nothing.public boolean isStrictArrays()
public FieldDef setStrictArrays(boolean strictArrays)
public boolean isLimitToAllowedValues()
getAllowedValues()
are allowed.public FieldDef setLimitToAllowedValues(boolean limitToAllowedValues)
public ValueMatch<?> getAllowedValues()
isLimitToAllowedValues()
property indicates if other values can be set.public FieldDef setAllowedValues(ValueMatch<?> allowedValues)
public Integer getPosition()
public Expression getDefaultValueExpression()
public String getDefaultValueExpressionAsString()
public FieldDef setDefaultValueExpression(Expression defaultValueExpression)
public String getExample()
public Attributes getAttributes()
public FieldDef setAttributes(Attributes attributes)
public Tags getTags()
public Integer getPrimaryKeyPosition()
public boolean isPrimaryKey()
true
if primaryKeyPosition
is not null.public PrimaryKeyType getPrimaryKeyType()
public FieldDef setPrimaryKeyType(PrimaryKeyType primaryKeyType)
public int getIndexInEntityDef()
EntityDef
.public String toJson()
toJson
in interface JsonSerializable
toJson
in interface RecordSerializable
public Record toRecord()
toRecord
in interface RecordSerializable
toRecord
in class Bean
public FieldDef fromRecord(Record source)
RecordSerializable
this
(for fluid API call chaining).
For fluid API call chaining, the overridden method should change the declared return type to its class.fromRecord
in interface RecordSerializable
fromRecord
in class Bean
public FieldDef fromJson(String jsonString)
fromJson
in interface JsonSerializable
fromJson
in interface RecordSerializable
public Element toXmlElement(Document document)
toXmlElement
in interface XmlSerializable
public FieldDef fromXmlElement(Element fieldDefElement)
fromXmlElement
in interface XmlSerializable
public static FieldDef newInstanceFromRecord(Record fieldDefRecord)
newInstanceFromRecord
in interface RecordSerializable
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.