Package com.evolveum.midpoint.prism.util
Class CloneUtil
java.lang.Object
com.evolveum.midpoint.prism.util.CloneUtil
- Author:
- semancik
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
clone
(T orig) static <T extends Cloneable>
TcloneCloneable
(T cloneable) static <T> List<T>
cloneCollectionMembers
(Collection<T> collection) static <T> List<T>
cloneCollectionMembersWithoutIds
(Collection<T> collection) static <C extends Containerable>
CcloneIfImmutable
(C value) static <T> void
cloneMembersToCollection
(Collection<T> target, Collection<T> source) toImmutable
(CF input) Provides an immutable version of the input: - If the input is immutable, returns it as isstatic <C extends Containerable>
CtoImmutableContainerable
(C input) Provides an immutable version of the input: - If the input is immutable, returns it as isstatic <C extends Containerable>
List<C>toImmutableContainerablesList
(@Nullable Collection<C> inputCollection) Returns a (mutable) list of input items after being processed bytoImmutableContainerable(Containerable)
method.
-
Constructor Details
-
CloneUtil
public CloneUtil()
-
-
Method Details
-
clone
@Contract("null -> null; !null -> !null") public static <T> T clone(T orig) -
cloneCloneable
@Contract("null -> null; !null -> !null") public static <T extends Cloneable> T cloneCloneable(T cloneable) -
cloneCollectionMembers
@Contract("!null -> !null; null -> null") public static <T> List<T> cloneCollectionMembers(Collection<T> collection) - Returns:
- List that can be freely used.
-
cloneMembersToCollection
-
cloneCollectionMembersWithoutIds
@Experimental @Contract("!null -> !null; null -> null") public static <T> List<T> cloneCollectionMembersWithoutIds(Collection<T> collection) - Returns:
- List that contains its members clones. For members that are Containerable the IDs are cleared.
FIXME: BEWARE - UNFINISHED
- does not clear IDs if members are PCVs; does it only for Containerables
- should be named maybe "copyForReuse" and use complexClone with the strategy of REUSE for all prism data
See
Containerable.cloneWithoutId()
and its TODOs.
-
cloneIfImmutable
@Contract("null -> null; !null -> !null") @Nullable public static <C extends Containerable> C cloneIfImmutable(@Nullable C value) -
toImmutable
@Contract("null -> null; !null -> !null") public static <CF extends Cloneable & Freezable> CF toImmutable(@Nullable CF input) Provides an immutable version of the input: - If the input is immutable, returns it as is. - If the input is mutable, creates an immutable clone. -
toImmutableContainerable
@Contract("null -> null; !null -> !null") public static <C extends Containerable> C toImmutableContainerable(@Nullable C input) Provides an immutable version of the input: - If the input is immutable, returns it as is. - If the input is mutable, creates an immutable clone. This method is needed (in addition totoImmutable(Cloneable)
) becauseContainerable
is notFreezable
. -
toImmutableContainerablesList
@Contract("null -> null; !null -> !null") public static <C extends Containerable> List<C> toImmutableContainerablesList(@Nullable @Nullable Collection<C> inputCollection) Returns a (mutable) list of input items after being processed bytoImmutableContainerable(Containerable)
method.
-