Package io.permazen.schema
Class CollectionSchemaField
java.lang.Object
io.permazen.util.AbstractXMLStreaming
io.permazen.schema.SchemaItem
io.permazen.schema.SchemaField
io.permazen.schema.ComplexSchemaField
io.permazen.schema.CollectionSchemaField
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ListSchemaField
,SetSchemaField
A collection field in one version of a
SchemaObjectType
.-
Field Summary
Fields inherited from class io.permazen.schema.SchemaItem
NAME_PATTERN
Fields inherited from class io.permazen.util.AbstractXMLStreaming
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Deep-clone this instance.protected Diffs
Get this collection field's element sub-field.abstract ItemType
Get theItemType
corresponding to this instance.Get theSchemaObjectType
of which this field is a member.final SchemaId
Generate a uniqueSchemaId
corresponding to the type and encoding structure of this schema item.final NavigableMap<String,
SimpleSchemaField> Get the sub-fields of this field.final boolean
isLockedDown
(boolean includingStorageIds) Determine whether this instance is locked down.void
setElementField
(SimpleSchemaField elementField) Set this collection field's element sub-field.final void
setObjectType
(SchemaObjectType objectType) Set theSchemaObjectType
of which this field is a member.final <T extends SchemaItem>
voidvisitSchemaItems
(Class<T> nodeType, Consumer<? super T> visitor) Visit this schema item and all of its descendents matching the given type with the given visitor.Methods inherited from class io.permazen.schema.ComplexSchemaField
equals, hashCode, visitSchemaItems
Methods inherited from class io.permazen.schema.SchemaField
toString, visit
Methods inherited from class io.permazen.schema.SchemaItem
differencesFrom, getName, getStorageId, setName, setStorageId
Methods inherited from class io.permazen.util.AbstractXMLStreaming
expect, expectClose, getAttr, getAttr, getBooleanAttr, getBooleanAttr, getIntAttr, getIntAttr, getLongAttr, newInvalidAttributeException, newInvalidInputException, newInvalidInputException, next, skip, writeAttr, writeCData, writeCharacters, writeElement, writeEmptyElement, writeStartElement
-
Constructor Details
-
CollectionSchemaField
public CollectionSchemaField()
-
-
Method Details
-
getElementField
Get this collection field's element sub-field.- Returns:
- element sub-field
-
setElementField
Set this collection field's element sub-field.- Parameters:
elementField
- element sub-field- Throws:
UnsupportedOperationException
- if this instance is locked down
-
getSubFields
Description copied from class:ComplexSchemaField
Get the sub-fields of this field.- Specified by:
getSubFields
in classComplexSchemaField
- Returns:
- list of sub-fields, which will be unmodifiable if this instance is locked down
-
differencesFrom
-
clone
Deep-clone this instance.The returned instance will not be locked down even if this one is.
- Overrides:
clone
in classComplexSchemaField
-
getObjectType
Get theSchemaObjectType
of which this field is a member.- Returns:
- containing object type
-
setObjectType
Set theSchemaObjectType
of which this field is a member.Note: this field is considered derived information, and will be set automatically when a referrring
SchemaObjectType
is locked down.- Parameters:
objectType
- containing object type- Throws:
UnsupportedOperationException
- if this instance is locked down
-
visitSchemaItems
public final <T extends SchemaItem> void visitSchemaItems(Class<T> nodeType, Consumer<? super T> visitor) Visit this schema item and all of its descendents matching the given type with the given visitor.The traversal is depth first, post-order.
- Parameters:
nodeType
- node type to includevisitor
- visitor for schema items- Throws:
IllegalArgumentException
- if either parameter is null
-
isLockedDown
public final boolean isLockedDown(boolean includingStorageIds) Determine whether this instance is locked down.- Parameters:
includingStorageIds
- false to test all but storage ID's, true to require storage ID's to be locked down as well- Returns:
- true if instance is locked down, otherwise false
-
getSchemaId
Generate a uniqueSchemaId
corresponding to the type and encoding structure of this schema item.The
SchemaId
does not depend on the storage ID.This instance must be locked down except for storage ID's. Repeated invocations of this method will be very fast, just returning the cached previous result.
- Returns:
- schema ID
- Throws:
IllegalStateException
- if this instance is not locked down- See Also:
-
getItemType
Get theItemType
corresponding to this instance.- Returns:
- schema item type
-