Class InstanceIdentityStore<V>
java.lang.Object
org.hibernate.internal.util.collections.AbstractPagedArray<Object>
org.hibernate.internal.util.collections.InstanceIdentityStore<V>
- Type Parameters:
V
- the type of values contained in this store
Utility collection that takes advantage of
InstanceIdentity
's identifier to store objects.
The store is based on AbstractPagedArray
and it stores element using their instance-id
as index.
Instance ids are considered to start from 1, and if two instances are found to have the
same identifier a will be thrown
.
Both keys and values are stored in this array, requiring very few allocations to keep track of the pair. The downside to this is we cannot easily access the key, especially if asking for a specific type, since that would cause type-pollution issues at the call site that would degrade performance.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.hibernate.internal.util.collections.AbstractPagedArray
AbstractPagedArray.Page<E>, AbstractPagedArray.PagedArrayIterator<T>
-
Field Summary
Fields inherited from class org.hibernate.internal.util.collections.AbstractPagedArray
elementPages
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable V
Returns the value to which the specified instance id is mapped, ornull
if this store contains no mapping for the instance id.void
Associates the specified value with the specified key in this store (optional operation).void
Removes the mapping for an instance id from this store if it is present (optional operation).Methods inherited from class org.hibernate.internal.util.collections.AbstractPagedArray
clear, get, getOrCreateEntryPage, getPage, set, toPageIndex, toPageOffset
-
Constructor Details
-
InstanceIdentityStore
public InstanceIdentityStore()
-
-
Method Details
-
get
Returns the value to which the specified instance id is mapped, ornull
if this store contains no mapping for the instance id.- Parameters:
instanceId
- the instance id whose associated value is to be returnedkey
- key instance to double-check instance equality- Returns:
- the value to which the specified instance id is mapped,
or
null
if this map contains no mapping for the instance id - Implementation Note:
- This method accesses the backing array with the provided instance id, but performs an instance
equality check (
==
) with the provided key to ensure it corresponds to the mapped one
-
put
Associates the specified value with the specified key in this store (optional operation). If the store previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
-
remove
Removes the mapping for an instance id from this store if it is present (optional operation).- Parameters:
instanceId
- the instance id whose associated value is to be returnedkey
- key instance to double-check instance equality- Implementation Note:
- This method accesses the backing array with the provided instance id, but performs an instance
equality check (
==
) with the provided key to ensure it corresponds to the mapped one
-