Package com.evolveum.midpoint.prism.impl
Class PrismObjectImpl<O extends Objectable>
- java.lang.Object
-
- com.evolveum.midpoint.prism.impl.ItemImpl<PrismContainerValue<C>,PrismContainerDefinition<C>>
-
- com.evolveum.midpoint.prism.impl.PrismContainerImpl<O>
-
- com.evolveum.midpoint.prism.impl.PrismObjectImpl<O>
-
- All Implemented Interfaces:
Item<PrismContainerValue<O>,PrismContainerDefinition<O>>
,Itemable
,ParentVisitable
,PathVisitable
,PrismContainer<O>
,PrismContainerable<O>
,PrismObject<O>
,Revivable
,Visitable
,DebugDumpable
,Serializable
public class PrismObjectImpl<O extends Objectable> extends PrismContainerImpl<O> implements PrismObject<O>
Common supertype for all identity objects. Defines basic properties that each object must have to live in our system (identifier, name). Objects consists of identifier and name (see definition below) and a set of properties represented as XML elements in the object's body. The attributes are represented as first-level XML elements (tags) of the object XML representation and may be also contained in other tags (e.g. extension, attributes). The QName (namespace and local name) of the element holding the property is considered to be a property name. This class is named PrismObject instead of Object to avoid confusion with java.lang.Object.- Author:
- Radovan Semancik Class invariant: has at most one value (potentially empty). When making this object immutable and there's no value, we create one; in order to prevent exceptions on later getValue calls.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.evolveum.midpoint.prism.impl.PrismContainerImpl
compileTimeClass
-
Fields inherited from class com.evolveum.midpoint.prism.impl.ItemImpl
defaultEquivalenceStrategy, definition, elementName, immutable, incomplete, parent, prismContext, values
-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Constructor Summary
Constructors Constructor Description PrismObjectImpl(QName name, PrismObjectDefinition<O> definition, PrismContext prismContext)
PrismObjectImpl(QName name, Class<O> compileTimeClass)
PrismObjectImpl(QName name, Class<O> compileTimeClass, PrismContext prismContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(PrismContainerValue newValue, boolean checkUniqueness)
Adds a given value, unless an equivalent one is already there (if checkUniqueness is true).<I extends Item>
voidaddExtensionItem(I item)
void
addReplaceExisting(Item<?,?> item)
protected void
appendDebugDumpSuffix(StringBuilder sb)
void
applyDefinition(PrismContainerDefinition<O> definition)
O
asObjectable()
static <T extends Objectable>
List<T>asObjectableList(List<PrismObjectImpl<T>> objects)
void
checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope)
PrismObject<O>
clone()
Literal clone.PrismObjectImpl<O>
cloneComplex(CloneStrategy strategy)
Complex clone with different cloning strategies.PrismObject<O>
cloneIfImmutable()
protected void
copyValues(CloneStrategy strategy, PrismObjectImpl<O> clone)
ObjectDelta<O>
createAddDelta()
ObjectDelta<O>
createDeleteDelta()
ObjectDelta<O>
createDelta(ChangeType changeType)
PrismContainer<?>
createExtension()
PrismObject<O>
createImmutableClone()
ObjectDelta<O>
createModifyDelta()
PrismObjectValue<O>
createNewValue()
PrismObjectDefinition<O>
deepCloneDefinition(boolean ultraDeep, Consumer<ItemDefinition> postCloneAction)
ObjectDelta<O>
diff(PrismObject<O> other)
ObjectDelta<O>
diff(PrismObject<O> other, ParameterizedEquivalenceStrategy strategy)
<I extends Item>
IfindExtensionItem(String elementLocalName)
<I extends Item>
IfindExtensionItem(QName elementName)
String
getBusinessDisplayName()
Return display name intended for business users of midPointprotected String
getDebugDumpClassName()
Return a human readable name of this class suitable for logs.PrismObjectDefinition<O>
getDefinition()
Returns applicable property container definition.PrismContainer<?>
getExtension()
PrismContainerValue<?>
getExtensionContainerValue()
PolyString
getName()
String
getOid()
Returns Object ID (OID).PrismContainer<?>
getOrCreateExtension()
PrismContainerValue<?>
getParent()
Returns the parent of this item (if exists).ItemPath
getPath()
Returns the path of this item (sequence of names from the "root" container or similar object to this item).protected Object
getPathComponent()
PrismObjectValue<O>
getValue()
Returns the value, if there is only one.String
getVersion()
Collection<? extends ItemDelta<?,?>>
narrowModifications(Collection<? extends ItemDelta<?,?>> modifications, boolean assumeMissingItems)
<IV extends PrismValue,ID extends ItemDefinition,I extends Item<IV,ID>>
voidremoveItem(ItemPath path, Class<I> itemType)
void
setImmutable(boolean immutable)
void
setOid(String oid)
void
setParent(PrismContainerValue<?> parentValue)
Sets the parent of this item.void
setValue(PrismContainerValue<O> value)
void
setVersion(String version)
String
toDebugName()
Returns short string representing identity of this object.String
toDebugType()
Returns short string identification of object type.String
toString()
-
Methods inherited from class com.evolveum.midpoint.prism.impl.PrismContainerImpl
accept, add, assertDefinitions, canRepresent, canRepresent, checkDefinition, containsEquivalentValue, containsItem, copyValues, createDelta, createDelta, createParentIfNeeded, debugDump, diff, diff, diffModifications, diffModifications, equivalent, find, findContainer, findContainer, findCreateItem, findCreateItem, findItem, findItem, findItem, findOrCreateContainer, findOrCreateItem, findOrCreateItem, findOrCreateProperty, findOrCreateReference, findPartial, findProperty, findReference, findValue, getCompileTimeClass, getPropertyRealValue, getRealValue, getRealValues, getValue, hasCompleteDefinition, isEmpty, mergeValue, mergeValues, mergeValues, propagateDeepCloneDefinition, remove, removeContainer, removeProperty, removeReference, setContainerRealValue, setDefinition, setPropertyRealValue, setPropertyRealValues, trim, trimDefinitionTree
-
Methods inherited from class com.evolveum.midpoint.prism.impl.ItemImpl
accept, acceptParentVisitor, add, add, add, addAll, addAll, applyDefinition, assertDefinitions, assertDefinitions, checkConsistence, checkConsistence, checkConsistence, checkConsistence, checkConsistence, checkImmutability, checkMutability, clear, contains, contains, contains, containsEquivalentValue, copyValues, diff, diff, equals, equals, equals, filterValues, findValue, fixupDelta, getAllValues, getAnyValue, getClonedValues, getDisplayName, getElementName, getEqualsHashCodeStrategy, getHelp, getHighestId, getPrismContext, getPrismContextLocal, getUserData, getUserData, getValues, hashCode, hashCode, hashCode, hasNoValues, hasRaw, isImmutable, isIncomplete, isOperational, isRaw, isSingleValue, merge, modifyUnfrozen, modifyUnfrozen, normalize, recomputeAllValues, remove, remove, remove, removeAll, replace, replaceAll, revive, setElementName, setIncomplete, setPrismContext, setUserData, size, valuesEqual
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDumpLazily, debugDumpLazily
-
Methods inherited from interface com.evolveum.midpoint.prism.Item
acceptParentVisitor, add, add, addAll, addAll, applyDefinition, assertDefinitions, assertDefinitions, checkConsistence, checkConsistence, checkConsistence, checkConsistence, checkConsistence, checkImmutability, clear, contains, contains, contains, containsEquivalentValue, containsEquivalentValue, diff, diff, equals, equals, filterValues, findValue, getAllValues, getAnyValue, getClonedValues, getDisplayName, getElementName, getHelp, getHighestId, getPrismContext, getPrismContextLocal, getUserData, getUserData, getValues, hasCompleteDefinition, hashCode, hashCode, hashCode, hasNoValues, hasRaw, isImmutable, isIncomplete, isOperational, isRaw, isSingleValue, merge, modifyUnfrozen, modifyUnfrozen, normalize, recomputeAllValues, remove, remove, removeAll, replace, replaceAll, revive, setElementName, setIncomplete, setPrismContext, setUserData, size, valuesEqual
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismContainer
accept, add, assertDefinitions, canRepresent, canRepresent, containsItem, createDelta, createDelta, debugDump, diff, diff, diffModifications, diffModifications, find, findContainer, findCreateItem, findCreateItem, findItem, findItem, findItem, findOrCreateContainer, findOrCreateItem, findOrCreateItem, findOrCreateProperty, findOrCreateReference, findPartial, findProperty, findReference, findValue, getCompileTimeClass, getPropertyRealValue, getRealValue, getRealValues, getValue, isEmpty, mergeValue, mergeValues, mergeValues, remove, removeContainer, removeProperty, removeReference, setContainerRealValue, setDefinition, setPropertyRealValue, setPropertyRealValues, trim, trimDefinitionTree
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismContainerable
getComplexTypeDefinition
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismObject
equals, equivalent
-
-
-
-
Constructor Detail
-
PrismObjectImpl
public PrismObjectImpl(QName name, Class<O> compileTimeClass, PrismContext prismContext)
-
PrismObjectImpl
public PrismObjectImpl(QName name, PrismObjectDefinition<O> definition, PrismContext prismContext)
-
-
Method Detail
-
createNewValue
public PrismObjectValue<O> createNewValue()
- Specified by:
createNewValue
in interfacePrismContainer<O extends Objectable>
- Specified by:
createNewValue
in interfacePrismObject<O extends Objectable>
- Overrides:
createNewValue
in classPrismContainerImpl<O extends Objectable>
-
getValue
@NotNull public PrismObjectValue<O> getValue()
Description copied from interface:Item
Returns the value, if there is only one. Throws exception if there are more values. If there is no value, this method either: - returns null (for properties) - throws an exception (for items that can hold multiple values) - creates an empty value (for containers and references). TODO think again whether getOrCreateValue would not be better- Specified by:
getValue
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
getValue
in interfacePrismContainer<O extends Objectable>
- Specified by:
getValue
in interfacePrismObject<O extends Objectable>
- Overrides:
getValue
in classPrismContainerImpl<O extends Objectable>
-
setValue
public void setValue(@NotNull PrismContainerValue<O> value) throws SchemaException
- Specified by:
setValue
in interfacePrismContainer<O extends Objectable>
- Specified by:
setValue
in interfacePrismObject<O extends Objectable>
- Overrides:
setValue
in classPrismContainerImpl<O extends Objectable>
- Throws:
SchemaException
-
add
public boolean add(@NotNull PrismContainerValue newValue, boolean checkUniqueness) throws SchemaException
Description copied from interface:Item
Adds a given value, unless an equivalent one is already there (if checkUniqueness is true).- Specified by:
add
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Overrides:
add
in classPrismContainerImpl<O extends Objectable>
- Returns:
- true if this item changed as a result of the call (i.e. if the value was really added) Note that even if checkUniqueness is false we check the cardinality of the item according to its definition, i.e. we do not allow single-valued item to contain more than one value.
- Throws:
SchemaException
-
getOid
public String getOid()
Returns Object ID (OID). May return null if the object does not have an OID.- Specified by:
getOid
in interfacePrismObject<O extends Objectable>
- Returns:
- Object ID (OID)
-
setOid
public void setOid(String oid)
- Specified by:
setOid
in interfacePrismObject<O extends Objectable>
-
getVersion
public String getVersion()
- Specified by:
getVersion
in interfacePrismObject<O extends Objectable>
-
setVersion
public void setVersion(String version)
- Specified by:
setVersion
in interfacePrismObject<O extends Objectable>
-
getDefinition
public PrismObjectDefinition<O> getDefinition()
Description copied from class:PrismContainerImpl
Returns applicable property container definition.May return null if no definition is applicable or the definition is not know.
- Specified by:
getDefinition
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
getDefinition
in interfaceItemable
- Specified by:
getDefinition
in interfacePrismContainer<O extends Objectable>
- Specified by:
getDefinition
in interfacePrismContainerable<O extends Objectable>
- Specified by:
getDefinition
in interfacePrismObject<O extends Objectable>
- Overrides:
getDefinition
in classPrismContainerImpl<O extends Objectable>
- Returns:
- applicable property container definition
-
asObjectable
@NotNull public O asObjectable()
- Specified by:
asObjectable
in interfacePrismObject<O extends Objectable>
-
getName
public PolyString getName()
- Specified by:
getName
in interfacePrismObject<O extends Objectable>
-
getExtension
public PrismContainer<?> getExtension()
- Specified by:
getExtension
in interfacePrismObject<O extends Objectable>
-
getOrCreateExtension
public PrismContainer<?> getOrCreateExtension() throws SchemaException
- Specified by:
getOrCreateExtension
in interfacePrismObject<O extends Objectable>
- Throws:
SchemaException
-
getExtensionContainerValue
public PrismContainerValue<?> getExtensionContainerValue()
- Specified by:
getExtensionContainerValue
in interfacePrismObject<O extends Objectable>
-
findExtensionItem
public <I extends Item> I findExtensionItem(String elementLocalName)
- Specified by:
findExtensionItem
in interfacePrismObject<O extends Objectable>
-
findExtensionItem
public <I extends Item> I findExtensionItem(@NotNull QName elementName)
- Specified by:
findExtensionItem
in interfacePrismObject<O extends Objectable>
-
addExtensionItem
public <I extends Item> void addExtensionItem(I item) throws SchemaException
- Specified by:
addExtensionItem
in interfacePrismObject<O extends Objectable>
- Throws:
SchemaException
-
createExtension
public PrismContainer<?> createExtension() throws SchemaException
- Specified by:
createExtension
in interfacePrismObject<O extends Objectable>
- Throws:
SchemaException
-
applyDefinition
public void applyDefinition(PrismContainerDefinition<O> definition) throws SchemaException
- Specified by:
applyDefinition
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
applyDefinition
in interfacePrismContainer<O extends Objectable>
- Specified by:
applyDefinition
in interfacePrismObject<O extends Objectable>
- Overrides:
applyDefinition
in classPrismContainerImpl<O extends Objectable>
- Throws:
SchemaException
-
removeItem
public <IV extends PrismValue,ID extends ItemDefinition,I extends Item<IV,ID>> void removeItem(ItemPath path, Class<I> itemType)
- Specified by:
removeItem
in interfacePrismContainer<O extends Objectable>
- Specified by:
removeItem
in interfacePrismObject<O extends Objectable>
- Overrides:
removeItem
in classPrismContainerImpl<O extends Objectable>
-
addReplaceExisting
public void addReplaceExisting(Item<?,?> item) throws SchemaException
- Specified by:
addReplaceExisting
in interfacePrismObject<O extends Objectable>
- Throws:
SchemaException
-
clone
public PrismObject<O> clone()
Description copied from interface:Item
Literal clone.- Specified by:
clone
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
clone
in interfacePrismContainer<O extends Objectable>
- Specified by:
clone
in interfacePrismObject<O extends Objectable>
- Overrides:
clone
in classPrismContainerImpl<O extends Objectable>
-
cloneComplex
public PrismObjectImpl<O> cloneComplex(CloneStrategy strategy)
Description copied from interface:Item
Complex clone with different cloning strategies.- Specified by:
cloneComplex
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
cloneComplex
in interfacePrismContainer<O extends Objectable>
- Specified by:
cloneComplex
in interfacePrismObject<O extends Objectable>
- Overrides:
cloneComplex
in classPrismContainerImpl<O extends Objectable>
- See Also:
CloneStrategy
-
copyValues
protected void copyValues(CloneStrategy strategy, PrismObjectImpl<O> clone)
-
deepCloneDefinition
public PrismObjectDefinition<O> deepCloneDefinition(boolean ultraDeep, Consumer<ItemDefinition> postCloneAction)
- Specified by:
deepCloneDefinition
in interfacePrismContainer<O extends Objectable>
- Specified by:
deepCloneDefinition
in interfacePrismObject<O extends Objectable>
- Overrides:
deepCloneDefinition
in classPrismContainerImpl<O extends Objectable>
-
diff
@NotNull public ObjectDelta<O> diff(PrismObject<O> other)
- Specified by:
diff
in interfacePrismObject<O extends Objectable>
-
diff
@NotNull public ObjectDelta<O> diff(PrismObject<O> other, ParameterizedEquivalenceStrategy strategy)
- Specified by:
diff
in interfacePrismObject<O extends Objectable>
-
narrowModifications
public Collection<? extends ItemDelta<?,?>> narrowModifications(Collection<? extends ItemDelta<?,?>> modifications, boolean assumeMissingItems)
- Specified by:
narrowModifications
in interfacePrismObject<O extends Objectable>
-
createDelta
public ObjectDelta<O> createDelta(ChangeType changeType)
- Specified by:
createDelta
in interfacePrismObject<O extends Objectable>
-
createAddDelta
public ObjectDelta<O> createAddDelta()
- Specified by:
createAddDelta
in interfacePrismObject<O extends Objectable>
-
createModifyDelta
public ObjectDelta<O> createModifyDelta()
- Specified by:
createModifyDelta
in interfacePrismObject<O extends Objectable>
-
createDeleteDelta
public ObjectDelta<O> createDeleteDelta()
- Specified by:
createDeleteDelta
in interfacePrismObject<O extends Objectable>
-
setParent
public void setParent(PrismContainerValue<?> parentValue)
Description copied from interface:Item
Sets the parent of this item.- Specified by:
setParent
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
setParent
in interfacePrismObject<O extends Objectable>
- Overrides:
setParent
in classItemImpl<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Parameters:
parentValue
- The new parent
-
getParent
public PrismContainerValue<?> getParent()
Description copied from interface:Item
Returns the parent of this item (if exists). Currently this has to be a PrismContainerValue.- Specified by:
getParent
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
getParent
in interfacePrismObject<O extends Objectable>
- Overrides:
getParent
in classItemImpl<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Returns:
- The parent if exists
-
getPath
@NotNull public ItemPath getPath()
Description copied from interface:Item
Returns the path of this item (sequence of names from the "root" container or similar object to this item). Note that if the containing object is a delta (usually a container delta), then the path- Specified by:
getPath
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
getPath
in interfaceItemable
- Specified by:
getPath
in interfacePrismObject<O extends Objectable>
- Overrides:
getPath
in classItemImpl<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Returns:
- the path
-
getPathComponent
protected Object getPathComponent()
- Overrides:
getPathComponent
in classItemImpl<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
-
toString
public String toString()
- Specified by:
toString
in interfacePrismContainer<O extends Objectable>
- Specified by:
toString
in interfacePrismObject<O extends Objectable>
- Overrides:
toString
in classPrismContainerImpl<O extends Objectable>
-
toDebugName
public String toDebugName()
Returns short string representing identity of this object. It should container object type, OID and name. It should be presented in a form suitable for log and diagnostic messages (understandable for system administrator).- Specified by:
toDebugName
in interfacePrismObject<O extends Objectable>
-
toDebugType
public String toDebugType()
Returns short string identification of object type. It should be in a form suitable for log messages. There is no requirement for the type name to be unique, but it rather has to be compact. E.g. short element names are preferred to long QNames or URIs.- Specified by:
toDebugType
in interfacePrismObject<O extends Objectable>
-
getDebugDumpClassName
protected String getDebugDumpClassName()
Return a human readable name of this class suitable for logs.- Overrides:
getDebugDumpClassName
in classPrismContainerImpl<O extends Objectable>
-
appendDebugDumpSuffix
protected void appendDebugDumpSuffix(StringBuilder sb)
- Overrides:
appendDebugDumpSuffix
in classItemImpl<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
-
getBusinessDisplayName
public String getBusinessDisplayName()
Return display name intended for business users of midPoint- Specified by:
getBusinessDisplayName
in interfacePrismObject<O extends Objectable>
-
checkConsistenceInternal
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope)
- Specified by:
checkConsistenceInternal
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
checkConsistenceInternal
in interfacePrismContainer<O extends Objectable>
- Specified by:
checkConsistenceInternal
in interfacePrismObject<O extends Objectable>
- Overrides:
checkConsistenceInternal
in classPrismContainerImpl<O extends Objectable>
-
setImmutable
public void setImmutable(boolean immutable)
- Specified by:
setImmutable
in interfaceItem<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
- Specified by:
setImmutable
in interfacePrismObject<O extends Objectable>
- Overrides:
setImmutable
in classItemImpl<PrismContainerValue<O extends Objectable>,PrismContainerDefinition<O extends Objectable>>
-
cloneIfImmutable
public PrismObject<O> cloneIfImmutable()
- Specified by:
cloneIfImmutable
in interfacePrismObject<O extends Objectable>
-
createImmutableClone
public PrismObject<O> createImmutableClone()
- Specified by:
createImmutableClone
in interfacePrismObject<O extends Objectable>
-
asObjectableList
@NotNull public static <T extends Objectable> List<T> asObjectableList(@NotNull List<PrismObjectImpl<T>> objects)
-
-