Class IndexDef
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.core.FoundationObject
com.northconcepts.datapipeline.foundations.schema.SchemaObject
com.northconcepts.datapipeline.foundations.schema.SchemaPart
com.northconcepts.datapipeline.foundations.schema.IndexDef
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,SchemaProblemsSupplier,JavaCodeGenerator,Serializable,Cloneable
public class IndexDef
extends SchemaPart
implements Cloneable, SchemaProblemsSupplier, JavaCodeGenerator
The metadata model for an entity's index.
- See Also:
-
Field Summary
Fields inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
internalId, internalName, log, TIMESTAMP_FORMATFields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddIndexField(IndexFieldDef indexField) Appends the index field and makes this index its parent.addIndexFields(String... indexFieldNames) Appends an ascending index field for each of the named entity fields; a null or empty array is ignored.clone()booleancontainsField(String name) Returns true if this index contains anIndexFieldDefwith the specifiedname.booleanfromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXmlElement(Element indexDefElement) voidAppends Java source code representing this object to the given builder.Returns the entity containing this index or null if it has not been added to one.Returns the qualified name that includes the name of this index and theEntityDefabove it separated by period.getIndexField(String name) Returns theIndexFieldDefthat matches the specified name.intReturns the number of index fields in this index.Returns the names of all index fields in this index.Returns the index fields or null if none were added.getIndexFields(boolean create) Returns the index fields, creating the list if it is null andcreateis true.getName()Returns the fully qualified name that includes the name of this index and all names in its hierarchy separated by period.The schema of the parent entity containing this field.getSchemaDef(boolean throwException) Returns the schema of the entity containing this index; if either is missing, throws aDataExceptionwhenthrowExceptionis true and returns null otherwise.Returns the schema part containing this one or null if there is none.Returns the name identifying this part, such as an entity's name or an index field's field name.Returns the kind of part this is, such asSchemaPartType.ENTITY.voidgetSchemaProblems(List<SchemaProblem> problems, boolean includeChildren) Adds this element's problems to the list, plus those of its children whenincludeChildrenis true; the default adds none.inthashCode()intindexOfField(String indexFieldName) Returns the zero-based position of theIndexDefwith the specified name or -1 if it is not found.intindexOfField(String indexFieldName, boolean throwExceptionOnFailure) Returns the zero-based position of theIndexFieldDefwith the specified name or -1 if it is not found andthrowExceptionOnFailureis false, otherwise aDataExceptionis thrown.booleanReturns true if this index has exactly the entity's primary key fields, in key order and all ascending.booleanisUnique()voidmoveField(int oldIndex, int newIndex) Moves the index field at theoldIndexto thenewIndex, shifting any existing elements at or afternewIndexto the right.voidMoves the index field with the given name to thenewIndex, shifting any existing elements at or afternewIndexto the right.voidmoveFieldAfter(String fieldName, String afterFieldName) Moves the index field with the givenfieldNameafter to the index field with the specifiedafterFieldName, shifting any existing elements afterafterFieldNameto the right.voidmoveFieldBefore(String fieldName, String beforeFieldName) Moves the index field with the givenfieldNamebefore to the index field with the specifiedbeforeFieldName, shifting elements at or afterbeforeFieldNameto the right.setDescription(String description) protected IndexDefsetEntityDef(EntityDef entityDef) Sets the parent entity; called byEntityDefwhen this index is added to it.setIndexFields(List<IndexFieldDef> indexFields) Replaces the index fields with the given list (not copied) and makes this index their parent.setUnique(boolean unique) toJson()toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.toXmlElement(Document document) Returns an element, created withdocument, describing this object; the default implementation throws aDataException.Methods inherited from class com.northconcepts.datapipeline.foundations.schema.SchemaPart
getSchemaName, getSchemaPartContainerName, getSchemaPartContainerTypeMethods inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
addExceptionProperties, assertValid, assertValid, exception, exception, exception, getInternalId, getInternalName, resetInternalIdMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionPropertiesMethods inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
fromJson, fromJson, toJson, toJsonMethods inherited from interface com.northconcepts.datapipeline.foundations.schema.SchemaProblemsSupplier
getSchemaProblems, getSchemaProblems
-
Constructor Details
-
IndexDef
public IndexDef() -
IndexDef
Creates an index on the named entity fields, each in ascending order.
-
-
Method Details
-
getSchemaProblems
Description copied from interface:SchemaProblemsSupplierAdds this element's problems to the list, plus those of its children whenincludeChildrenis true; the default adds none.- Specified by:
getSchemaProblemsin interfaceSchemaProblemsSupplier
-
clone
- Overrides:
clonein classFoundationObject
-
generateJavaCode
Description copied from interface:JavaCodeGeneratorAppends Java source code representing this object to the given builder.- Specified by:
generateJavaCodein interfaceJavaCodeGenerator
-
getSchemaDef
Returns the schema of the entity containing this index; if either is missing, throws aDataExceptionwhenthrowExceptionis true and returns null otherwise. -
getSchemaDef
The schema of the parent entity containing this field.- Specified by:
getSchemaDefin classSchemaPart
-
getSchemaPartContainer
Description copied from class:SchemaPartReturns the schema part containing this one or null if there is none.- Specified by:
getSchemaPartContainerin classSchemaPart
-
getSchemaPartType
Description copied from class:SchemaPartReturns the kind of part this is, such asSchemaPartType.ENTITY.- Specified by:
getSchemaPartTypein classSchemaPart
-
getSchemaPartName
Description copied from class:SchemaPartReturns the name identifying this part, such as an entity's name or an index field's field name.- Specified by:
getSchemaPartNamein classSchemaPart
-
getEntityDef
Returns the entity containing this index or null if it has not been added to one. -
setEntityDef
Sets the parent entity; called byEntityDefwhen this index is added to it. -
getName
-
setName
-
getQualifiedName
Returns the fully qualified name that includes the name of this index and all names in its hierarchy separated by period. -
getEntityQualifiedName
Returns the qualified name that includes the name of this index and theEntityDefabove it separated by period. -
getDescription
-
setDescription
-
isUnique
public boolean isUnique() -
setUnique
-
isPrimaryKeyIndex
public boolean isPrimaryKeyIndex()Returns true if this index has exactly the entity's primary key fields, in key order and all ascending. -
containsField
Returns true if this index contains anIndexFieldDefwith the specifiedname. -
getIndexFieldCount
public int getIndexFieldCount()Returns the number of index fields in this index. -
getIndexFieldNames
Returns the names of all index fields in this index. -
getIndexFields
Returns the index fields, creating the list if it is null andcreateis true. -
getIndexField
Returns theIndexFieldDefthat matches the specified name. -
getIndexFields
Returns the index fields or null if none were added. -
setIndexFields
Replaces the index fields with the given list (not copied) and makes this index their parent. -
addIndexField
Appends the index field and makes this index its parent. -
addIndexFields
Appends an ascending index field for each of the named entity fields; a null or empty array is ignored. -
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException.- Specified by:
toXmlElementin interfaceXmlSerializable
-
fromXmlElement
- Specified by:
fromXmlElementin interfaceXmlSerializable
-
toJson
- Specified by:
toJsonin interfaceJsonSerializable- Specified by:
toJsonin interfaceRecordSerializable
-
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classBean
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classBean- Parameters:
source-- Returns:
- this instance.
-
hashCode
public int hashCode() -
equals
-
indexOfField
Returns the zero-based position of theIndexDefwith the specified name or -1 if it is not found. -
indexOfField
Returns the zero-based position of theIndexFieldDefwith the specified name or -1 if it is not found andthrowExceptionOnFailureis false, otherwise aDataExceptionis thrown. -
moveField
public void moveField(int oldIndex, int newIndex) Moves the index field at theoldIndexto thenewIndex, shifting any existing elements at or afternewIndexto the right. -
moveField
Moves the index field with the given name to thenewIndex, shifting any existing elements at or afternewIndexto the right. -
moveFieldBefore
Moves the index field with the givenfieldNamebefore to the index field with the specifiedbeforeFieldName, shifting elements at or afterbeforeFieldNameto the right. -
moveFieldAfter
Moves the index field with the givenfieldNameafter to the index field with the specifiedafterFieldName, shifting any existing elements afterafterFieldNameto the right.
-