Interface Item<V extends PrismValue,D extends ItemDefinition>
-
- All Superinterfaces:
DebugDumpable,Freezable,Itemable,ParentVisitable,PathVisitable,PrismContextSensitive,Revivable,Serializable,Visitable
- All Known Subinterfaces:
PrismContainer<C>,PrismObject<O>,PrismProperty<T>,PrismReference,ResourceAttribute<T>,ResourceAttributeContainer
- All Known Implementing Classes:
com.evolveum.midpoint.prism.impl.ItemImpl,com.evolveum.midpoint.prism.impl.PrismContainerImpl,com.evolveum.midpoint.prism.impl.PrismPropertyImpl,ResourceAttributeContainerImpl,ResourceAttributeImpl
public interface Item<V extends PrismValue,D extends ItemDefinition> extends Itemable, DebugDumpable, Visitable, PathVisitable, ParentVisitable, Serializable, Revivable, Freezable, PrismContextSensitive
Item is a common abstraction of Property, Reference and Container.This is supposed to be a superclass for all items. Items are things that can appear in containers, which generally means only a property, reference and container itself. Therefore this is in fact superclass for those three definitions.
- Author:
- Radovan Semancik
-
-
Field Summary
-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidacceptParentVisitor(@NotNull Visitor visitor)Accepts a visitor that visits each item/value on the way to the structure root.default booleanadd(V newValue)Adds a given value, unless an equivalent one is already there.booleanadd(V newValue, boolean checkUniqueness)Adds a given value, unless an equivalent one is already there (if checkUniqueness is true).booleanadd(V newValue, @NotNull EquivalenceStrategy equivalenceStrategy)Adds a given value, unless an equivalent one is already there.booleanaddAll(Collection<V> newValues)Adds given values, with the same semantics as repeated add(..) calls.booleanaddAll(Collection<V> newValues, boolean checkUniqueness, EquivalenceStrategy strategy)Adds given values, with the same semantics as repeated add(..) calls.booleanaddAll(Collection<V> newValues, EquivalenceStrategy strategy)Adds given values, with the same semantics as repeated add(..) calls.voidapplyDefinition(D definition)voidapplyDefinition(D definition, boolean force)voidassertDefinitions()voidassertDefinitions(boolean tolerateRawValues, String sourceDescription)voidassertDefinitions(String sourceDescription)voidcheckConsistence()voidcheckConsistence(boolean requireDefinitions, boolean prohibitRaw)voidcheckConsistence(boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope)voidcheckConsistence(boolean requireDefinitions, ConsistencyCheckScope scope)voidcheckConsistence(ConsistencyCheckScope scope)voidcheckConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope)voidclear()Removes all values from the item.Itemclone()Literal clone.static <T extends Item<?,?>>
Collection<T>cloneCollection(Collection<T> items)ItemcloneComplex(CloneStrategy strategy)Complex clone with different cloning strategies.booleancontains(V value)booleancontains(V value, @NotNull EquivalenceStrategy strategy)booleancontains(V value, @Nullable EquivalenceStrategy strategy, @Nullable Comparator<V> comparator)booleancontainsEquivalentValue(V value)booleancontainsEquivalentValue(V value, @Nullable Comparator<V> comparator)ItemDelta<V,D>createDelta()Creates specific subclass of ItemDelta appropriate for type of item that this definition represents (e.g.ItemDelta<V,D>createDelta(ItemPath path)ItemcreateImmutableClone()default ItemDelta<V,D>diff(Item<V,D> other)Computes a difference (delta) with the specified item using IGNORE_METADATA_CONSIDER_DIFFERENT_IDS equivalence strategy.ItemDelta<V,D>diff(Item<V,D> other, @NotNull ParameterizedEquivalenceStrategy strategy)Computes a difference (delta) with the specified item using given equivalence strategy.booleanequals(Object obj)Compares this item to the specified object under NOT_LITERAL strategy (if no other is pre-set).booleanequals(Object obj, @NotNull EquivalenceStrategy equivalenceStrategy)Compares this item to the specified object under given strategy.booleanequals(Object obj, @NotNull ParameterizedEquivalenceStrategy equivalenceStrategy)Compares this item to the specified object under given strategy.voidfilterValues(Function<V,Boolean> function)Objectfind(ItemPath path)Returns object (Item or PrismValue) pointed to by the given path.<IV extends PrismValue,ID extends ItemDefinition>
PartiallyResolvedItem<IV,ID>findPartial(ItemPath path)VfindValue(V value, @NotNull EquivalenceStrategy strategy)static @NotNull Collection<PrismValue>getAllValues(Item<?,?> item, ItemPath path)@NotNull Collection<PrismValue>getAllValues(ItemPath path)default VgetAnyValue()Returns any of the values.default VgetAnyValue(@NotNull ValueSelector<V> selector)Returns a value matching given selector (or null if none exists).Collection<V>getClonedValues()DgetDefinition()Returns applicable definition.default StringgetDisplayName()Returns a display name for the item.ItemNamegetElementName()Returns the name of the item.default StringgetHelp()Returns help message defined for the item.LonggetHighestId()@Nullable PrismContainerValue<?>getParent()Returns the parent of this item (if exists).@NotNull ItemPathgetPath()Returns the path of this item (sequence of names from the "root" container or similar object to this item).PrismContextgetPrismContextLocal()@Nullable ObjectgetRealValue()Returns the "real value" (content) of this item: - value contained in PrismPropertyValue - Referencable in PrismReferenceValue - Containerable in PrismContainerValue - Objectable in PrismObjectValue Note that the real value can contain operational items.<X> XgetRealValue(Class<X> type)Type override, also for compatibility.@NotNull Collection<?>getRealValues()Returns (potentially empty) collection of "real values".<X> X[]getRealValuesArray(Class<X> type)Type override, also for compatibility.default @NotNull Collection<Object>getRealValuesOrRawTypes(PrismContext prismContext)@NotNull Map<String,Object>getUserData()Returns the "user data", a map that allows attaching arbitrary named data to this item.<T> TgetUserData(String key)Returns the user data for the given key (name).VgetValue()Returns the value, if there is only one.@NotNull List<V>getValues()Returns the values for this item.static <V extends PrismValue>
@NotNull Collection<V>getValues(Item<V,?> item)default booleanhasCompleteDefinition()Returns true if this item and all contained items have proper definition.inthashCode()Computes hash code to be used under NOT_LITERAL equivalence strategy.inthashCode(@NotNull EquivalenceStrategy equivalenceStrategy)Computes hash code to be used under given equivalence strategy.inthashCode(@NotNull ParameterizedEquivalenceStrategy equivalenceStrategy)Computes hash code to be used under given equivalence strategy.default booleanhasNoValues()static booleanhasNoValues(Item<?,?> item)booleanhasRaw()Returns true is at least one of the values is raw.default booleanisEmpty()booleanisIncomplete()Flag that indicates incomplete item.default booleanisOperational()Returns true if this item is metadata item that should be ignored for metadata-insensitive comparisons and hashCode functions.booleanisRaw()Returns true is all the values are raw.booleanisSingleValue()Returns true if the item contains 0 or 1 values and (by definition) is not multivalued.voidmerge(Item<V,D> otherItem)Merge all the values of other item to this item.voidnormalize()voidrecomputeAllValues()Re-apply PolyString (and possible other) normalizations to the object.booleanremove(V value)Removes given value from the item.booleanremove(V value, @NotNull EquivalenceStrategy strategy)Removes values equivalent to given value from the item; under specified equivalence strategy OR when values represent the same value via "representsSameValue(.., lax=false)" method.booleanremoveAll(Collection<V> values)Removes all given values from the item.voidreplace(V newValue)Replaces all values of the item by given value.voidreplaceAll(Collection<V> newValues, EquivalenceStrategy strategy)Replaces all values of the item by given values.static <T extends Item>
Collection<T>resetParentCollection(Collection<T> items)Sets all parents to null.voidrevive(PrismContext prismContext)voidsetDefinition(D definition)Sets applicable item definition.voidsetElementName(QName elementName)Sets the name of the item.voidsetIncomplete(boolean incomplete)Flags the item as incomplete.voidsetParent(@Nullable PrismContainerValue<?> parentValue)Sets the parent of this item.voidsetPrismContext(PrismContext prismContext)voidsetUserData(String key, Object value)Sets the user data for the given key (name).intsize()Returns the number of values for this item.booleanvaluesEqual(Collection<V> matchValues, @Nullable Comparator<V> comparator)-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDump, debugDumpLazily, debugDumpLazily
-
Methods inherited from interface com.evolveum.midpoint.prism.Freezable
checkImmutable, checkMutable, freeze, isImmutable
-
Methods inherited from interface com.evolveum.midpoint.prism.PathVisitable
accept
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismContextSensitive
getPrismContext
-
-
-
-
Method Detail
-
getDefinition
D getDefinition()
Returns applicable definition.May return null if no definition is applicable or the definition is not known.
- Specified by:
getDefinitionin interfaceItemable- Returns:
- applicable definition
-
hasCompleteDefinition
default boolean hasCompleteDefinition()
Returns true if this item and all contained items have proper definition.
-
getElementName
ItemName getElementName()
Returns the name of the item.The name is a QName. It uniquely defines an item.
The name may be null, but such an item will not work.
The name is the QName of XML element in the XML representation.
- Specified by:
getElementNamein interfaceItemable- Returns:
- item name TODO consider making element name obligatory
-
setElementName
void setElementName(QName elementName)
Sets the name of the item.The name is a QName. It uniquely defines an item.
The name may be null, but such an item will not work.
The name is the QName of XML element in the XML representation.
- Parameters:
elementName- the name to set TODO consider removing this method
-
setDefinition
void setDefinition(@Nullable D definition)Sets applicable item definition.- Parameters:
definition- the definition to set TODO consider removing this method
-
getDisplayName
default String getDisplayName()
Returns a display name for the item.Returns null if the display name cannot be determined.
The display name is fetched from the definition. If no definition (schema) is available, the display name will not be returned.
- Returns:
- display name for the item
-
getHelp
default String getHelp()
Returns help message defined for the item.Returns null if the help message cannot be determined.
The help message is fetched from the definition. If no definition (schema) is available, the help message will not be returned.
- Returns:
- help message for the item
-
isIncomplete
boolean isIncomplete()
Flag that indicates incomplete item. If set to true then the values in this item are not complete. If this flag is true then it can be assumed that the object that this item represents has at least one value. This is a method how to indicate that the item really has some values, but are not here. This may be used for variety of purposes. It may indicate that the account has a password, but the password value is not revealed. This may indicate that a user has a photo, but the photo was not requested and therefore is not returned. This may be used to indicate that only part of the attribute values were returned from the search. And so on.
-
setIncomplete
void setIncomplete(boolean incomplete)
Flags the item as incomplete.- Parameters:
incomplete- The new value- See Also:
FIXME: Should be package-visible to implementation
-
getParent
@Nullable @Nullable PrismContainerValue<?> getParent()
Returns the parent of this item (if exists). Currently this has to be a PrismContainerValue.- Returns:
- The parent if exists
-
setParent
void setParent(@Nullable @Nullable PrismContainerValue<?> parentValue)Sets the parent of this item.- Parameters:
parentValue- The new parent
-
getPath
@NotNull @NotNull ItemPath getPath()
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
-
getUserData
@NotNull @NotNull Map<String,Object> getUserData()
Returns the "user data", a map that allows attaching arbitrary named data to this item.- Returns:
- the user data map
-
getUserData
<T> T getUserData(String key)
Returns the user data for the given key (name).
-
setUserData
void setUserData(String key, Object value)
Sets the user data for the given key (name).
-
getValues
@NotNull @NotNull List<V> getValues()
Returns the values for this item. Although the ordering of this values is not important, and each value should be present at most once, we currently return them as a list instead of a set. TODO reconsider this
-
size
int size()
Returns the number of values for this item.
-
getAnyValue
default V getAnyValue()
Returns any of the values. Usually called when we are quite confident that there is only a single value; or we don't care which of the values we get. Does not create values if there are none.
-
getValue
V getValue()
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
-
getAnyValue
default V getAnyValue(@NotNull @NotNull ValueSelector<V> selector)
Returns a value matching given selector (or null if none exists).
-
getRealValue
@Nullable @Nullable Object getRealValue()
Returns the "real value" (content) of this item: - value contained in PrismPropertyValue - Referencable in PrismReferenceValue - Containerable in PrismContainerValue - Objectable in PrismObjectValue Note that the real value can contain operational items. It can also contain container IDs (although they are not considered to be part of the real value). It does not contain information about item element name nor other metadata like origin, definition, etc. (Although e.g. Containerable can be converted back into PrismContainerValue that can be used to retrieve this information.)
-
getRealValue
<X> X getRealValue(Class<X> type)
Type override, also for compatibility.
-
getRealValuesArray
<X> X[] getRealValuesArray(Class<X> type)
Type override, also for compatibility.
-
getRealValues
@NotNull @NotNull Collection<?> getRealValues()
Returns (potentially empty) collection of "real values".
-
getRealValuesOrRawTypes
@Experimental @NotNull default @NotNull Collection<Object> getRealValuesOrRawTypes(PrismContext prismContext)
-
isSingleValue
boolean isSingleValue()
Returns true if the item contains 0 or 1 values and (by definition) is not multivalued.
-
add
boolean add(@NotNull V newValue, boolean checkUniqueness) throws SchemaExceptionAdds a given value, unless an equivalent one is already there (if checkUniqueness is true).- 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
-
add
default boolean add(@NotNull V newValue) throws SchemaExceptionAdds a given value, unless an equivalent one is already there. It is the same as calling add with checkUniqueness=true.- Returns:
- true if this item changed as a result of the call (i.e. if the value was really added)
- Throws:
SchemaException
-
add
boolean add(@NotNull V newValue, @NotNull @NotNull EquivalenceStrategy equivalenceStrategy) throws SchemaExceptionAdds a given value, unless an equivalent one is already there. It is the same as calling add with checkUniqueness=true. Uses given strategy for equivalence testing.- Returns:
- true if this item changed as a result of the call (i.e. if the value was really added)
- Throws:
SchemaException
-
addAll
boolean addAll(Collection<V> newValues) throws SchemaException
Adds given values, with the same semantics as repeated add(..) calls.- Returns:
- true if this item changed as a result of the call (i.e. if at least one value was really added)
- Throws:
SchemaException
-
addAll
boolean addAll(Collection<V> newValues, EquivalenceStrategy strategy) throws SchemaException
Adds given values, with the same semantics as repeated add(..) calls. For equality testing uses given strategy.- Returns:
- true if this item changed as a result of the call (i.e. if at least one value was really added)
- Throws:
SchemaException
-
addAll
boolean addAll(Collection<V> newValues, boolean checkUniqueness, EquivalenceStrategy strategy) throws SchemaException
Adds given values, with the same semantics as repeated add(..) calls. For equality testing uses given strategy.- Returns:
- true if this item changed as a result of the call (i.e. if at least one value was really added)
- Throws:
SchemaException
-
remove
boolean remove(V value)
Removes given value from the item. "Given value" currently means any value that is considered equivalent via REAL_VALUE equivalence strategy or a value that is considered "the same" via "representsSameValue(.., lax=false)" method.- Returns:
- true if this item changed as a result of the call (i.e. if at least one value was really removed) Note that there can be more than one values removed.
-
remove
boolean remove(V value, @NotNull @NotNull EquivalenceStrategy strategy)
Removes values equivalent to given value from the item; under specified equivalence strategy OR when values represent the same value via "representsSameValue(.., lax=false)" method.- Returns:
- true if this item changed as a result of the call (i.e. if at least one value was really removed)
-
removeAll
boolean removeAll(Collection<V> values)
Removes all given values from the item. It is basically a shortcut for repeated remove(value) call.- Returns:
- true if this item changed as a result of the call (i.e. if at least one value was really removed)
-
clear
void clear()
Removes all values from the item.
-
replaceAll
void replaceAll(Collection<V> newValues, EquivalenceStrategy strategy) throws SchemaException
Replaces all values of the item by given values.- Throws:
SchemaException
-
replace
void replace(V newValue) throws SchemaException
Replaces all values of the item by given value.- Throws:
SchemaException
-
equals
boolean equals(Object obj)
Compares this item to the specified object under NOT_LITERAL strategy (if no other is pre-set).
-
equals
boolean equals(Object obj, @NotNull @NotNull EquivalenceStrategy equivalenceStrategy)
Compares this item to the specified object under given strategy.
-
equals
boolean equals(Object obj, @NotNull @NotNull ParameterizedEquivalenceStrategy equivalenceStrategy)
Compares this item to the specified object under given strategy.
-
hashCode
int hashCode()
Computes hash code to be used under NOT_LITERAL equivalence strategy.
-
hashCode
int hashCode(@NotNull @NotNull EquivalenceStrategy equivalenceStrategy)Computes hash code to be used under given equivalence strategy.
-
hashCode
int hashCode(@NotNull @NotNull ParameterizedEquivalenceStrategy equivalenceStrategy)Computes hash code to be used under given equivalence strategy.
-
contains
boolean contains(V value)
- Returns:
- true if the item contains a given value (by default using NOT_LITERAL strategy) Note that the "sameness" (ID-only value matching) is NOT considered here.
-
contains
boolean contains(V value, @NotNull @NotNull EquivalenceStrategy strategy)
- Returns:
- true if the item contains a given value under specified equivalence strategy Note that the "sameness" (ID-only value matching) is NOT considered here.
-
contains
boolean contains(V value, @Nullable @Nullable EquivalenceStrategy strategy, @Nullable @Nullable Comparator<V> comparator)
- Returns:
- true if the item contains a given value using comparator (if not null) or under specified equivalence strategy (if comparator is null). Note that the "sameness" (ID-only value matching) is NOT considered here.
-
containsEquivalentValue
boolean containsEquivalentValue(V value)
- Returns:
- true if the item contains an equivalent value (the same as
containsEquivalentValue(PrismValue, Comparator)with comparator being null)
-
containsEquivalentValue
boolean containsEquivalentValue(V value, @Nullable @Nullable Comparator<V> comparator)
- Returns:
- true if the item contains an equivalent value Item value is considered to be equivalent to the given value if: 1) given value is ID-only container value and item value has the same ID, or 2) comparator is not null and it gives "equals" (0) result when comparing these values, or 3) comparator is null and values match under IGNORE_METADATA_CONSIDER_DIFFERENT_IDS strategy
-
findValue
V findValue(V value, @NotNull @NotNull EquivalenceStrategy strategy)
- Returns:
- a value of this item that is equivalent to the given one under given equivalence strategy (or null if no such value exists)
-
valuesEqual
boolean valuesEqual(Collection<V> matchValues, @Nullable @Nullable Comparator<V> comparator)
- Returns:
- true if the values of this item match the "matchValues" collection, under given comparator. If comparator is null the default equals(..) comparison is used.
-
diff
default ItemDelta<V,D> diff(Item<V,D> other)
Computes a difference (delta) with the specified item using IGNORE_METADATA_CONSIDER_DIFFERENT_IDS equivalence strategy. Compares item values only -- does NOT dive into lower levels.
-
diff
ItemDelta<V,D> diff(Item<V,D> other, @NotNull @NotNull ParameterizedEquivalenceStrategy strategy)
Computes a difference (delta) with the specified item using given equivalence strategy. Note this method cannot accept general EquivalenceStrategy here; it needs the parameterized strategy. Compares item values only -- does NOT dive into lower levels.
-
getClonedValues
Collection<V> getClonedValues()
-
normalize
void normalize()
-
merge
void merge(Item<V,D> otherItem) throws SchemaException
Merge all the values of other item to this item.- Throws:
SchemaException
-
findPartial
<IV extends PrismValue,ID extends ItemDefinition> PartiallyResolvedItem<IV,ID> findPartial(ItemPath path)
-
createDelta
ItemDelta<V,D> createDelta()
Creates specific subclass of ItemDelta appropriate for type of item that this definition represents (e.g. PropertyDelta, ContainerDelta, ...)
-
acceptParentVisitor
void acceptParentVisitor(@NotNull @NotNull Visitor visitor)Accepts a visitor that visits each item/value on the way to the structure root.- Specified by:
acceptParentVisitorin interfaceParentVisitable
-
recomputeAllValues
void recomputeAllValues()
Re-apply PolyString (and possible other) normalizations to the object.
-
applyDefinition
void applyDefinition(D definition) throws SchemaException
- Throws:
SchemaException
-
applyDefinition
void applyDefinition(D definition, boolean force) throws SchemaException
- Throws:
SchemaException
-
revive
void revive(PrismContext prismContext) throws SchemaException
- Specified by:
revivein interfaceRevivable- Throws:
SchemaException
-
clone
Item clone()
Literal clone.
-
createImmutableClone
Item createImmutableClone()
-
cloneComplex
Item cloneComplex(CloneStrategy strategy)
Complex clone with different cloning strategies.- See Also:
CloneStrategy
-
cloneCollection
static <T extends Item<?,?>> Collection<T> cloneCollection(Collection<T> items)
-
resetParentCollection
static <T extends Item> Collection<T> resetParentCollection(Collection<T> items)
Sets all parents to null. This is good if the items are to be "transplanted" into a different Containerable.
-
checkConsistence
void checkConsistence(boolean requireDefinitions, ConsistencyCheckScope scope)
-
checkConsistence
void checkConsistence(boolean requireDefinitions, boolean prohibitRaw)
-
checkConsistence
void checkConsistence(boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope)
-
checkConsistence
void checkConsistence()
-
checkConsistence
void checkConsistence(ConsistencyCheckScope scope)
-
checkConsistenceInternal
void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope)
-
assertDefinitions
void assertDefinitions() throws SchemaException- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(String sourceDescription) throws SchemaException
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(boolean tolerateRawValues, String sourceDescription) throws SchemaException- Throws:
SchemaException
-
isRaw
boolean isRaw()
Returns true is all the values are raw.
-
hasRaw
boolean hasRaw()
Returns true is at least one of the values is raw.
-
isEmpty
default boolean isEmpty()
-
hasNoValues
default boolean hasNoValues()
-
hasNoValues
static boolean hasNoValues(Item<?,?> item)
-
isOperational
default boolean isOperational()
Returns true if this item is metadata item that should be ignored for metadata-insensitive comparisons and hashCode functions.
-
getValues
@NotNull static <V extends PrismValue> @NotNull Collection<V> getValues(Item<V,?> item)
-
getAllValues
@NotNull @NotNull Collection<PrismValue> getAllValues(ItemPath path)
-
getAllValues
@NotNull static @NotNull Collection<PrismValue> getAllValues(Item<?,?> item, ItemPath path)
-
getPrismContextLocal
PrismContext getPrismContextLocal()
-
setPrismContext
void setPrismContext(PrismContext prismContext)
-
getHighestId
Long getHighestId()
-
-