Class CopyUtils
- Author:
- md5sha256
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voiddeepCopy(Collection<T> source, UnaryOperator<T> cloningFunction, Collection<T> sink) Perform a deep copy of all the elements from a givenCollectionto another.static <T,C extends Collection<T>>
CdeepCopy(Collection<T> source, UnaryOperator<T> cloningFunction, IntFunction<C> sinkSupplier) Perform a deep copy of all the elements from a givenCollectionto another.static <K,V> void deepCopy(Map<K, V> source, UnaryOperator<V> cloningFunction) Perform a deep-clone transformation on all values in a givenMapstatic <K,V, M extends Map<K, V>>
MdeepCopy(Map<K, V> source, UnaryOperator<V> cloningFunction, Supplier<M> sinkSupplier) Perform a deep copy of all the elements from a givenMapto another.static <K,V> void deepCopy(Map<K, V> source, UnaryOperator<V> cloningFunction, Map<K, V> sink) Perform a deep copy of all the elements from a givenMapto another.static <T> T[]deepCopy(T[] source, UnaryOperator<T> cloningFunction, IntFunction<T[]> sinkSupplier) Perform a deep copy of all the elements from a given array to another.static <T> voiddeepCopy(T[] source, UnaryOperator<T> cloningFunction, T[] sink) Perform a deep copy of all the elements from a given array to another.
-
Method Details
-
deepCopy
public static <T> void deepCopy(@Nonnull Collection<T> source, @Nonnull UnaryOperator<T> cloningFunction, @Nonnull Collection<T> sink) Perform a deep copy of all the elements from a givenCollectionto another.If the source collection contains
nullelements, the cloning function should be able to handle null input. Additionally, the sink should also accept any values contained by the source collection, null or not.- Type Parameters:
T- The type of elements in the collections- Parameters:
source- The source of the elementscloningFunction- The function which clones the elementssink- The collection in which to copy to the cloned elements to
-
deepCopy
@Nonnull public static <T,C extends Collection<T>> C deepCopy(@Nonnull Collection<T> source, @Nonnull UnaryOperator<T> cloningFunction, @Nonnull IntFunction<C> sinkSupplier) Perform a deep copy of all the elements from a givenCollectionto another.If the source collection contains
nullelements, the cloning function should be able to handle null input. Additionally, the sink supplied by the sink supplier should also accept any values contained by the source collection, null or not.- Type Parameters:
T- The type of elements in the collectionsC- The type of the returned collection- Parameters:
source- The source of the elementscloningFunction- The function which clones the elementssinkSupplier- The supplier which consumes the size of the source collection and supplies the collection to copy cloned elements to
-
deepCopy
public static <K,V> void deepCopy(@Nonnull Map<K, V> source, @Nonnull UnaryOperator<V> cloningFunction, @Nonnull Map<K, V> sink) Perform a deep copy of all the elements from a givenMapto another.If the source map contains
nullvalues, the cloning function should be able to handle null input. Additionally, the sink should also accept any keys and values contained by the source Map, null or not.- Type Parameters:
K- The type of keys in the mapsV- The type of values in the maps- Parameters:
source- The source of the elementscloningFunction- The function which clones the elementssink- The map in which to copy to the cloned elements to
-
deepCopy
@Nonnull public static <K,V, M deepCopyM extends Map<K, V>> (@Nonnull Map<K, V> source, @Nonnull UnaryOperator<V> cloningFunction, @Nonnull Supplier<M> sinkSupplier) Perform a deep copy of all the elements from a givenMapto another.If the source map contains
nullvalues, the cloning function should be able to handle null input. Additionally, the sink should also accept any keys and values contained by the source Map, null or not.- Type Parameters:
K- The type of keys in the mapsV- The type of values in the mapsM- The type of the returned map- Parameters:
source- The source of the elementscloningFunction- The function which clones the elementssinkSupplier- The supplier which consumes the size of the source map and supplies the map to copy cloned elements to
-
deepCopy
public static <K,V> void deepCopy(@Nonnull Map<K, V> source, @Nonnull UnaryOperator<V> cloningFunction) Perform a deep-clone transformation on all values in a givenMapIf the source map contains
nullvalues, the cloning function should be able to handle null input.- Type Parameters:
K- The type of keys in the mapV- The type of values in the map- Parameters:
source- The source of the elementscloningFunction- The function which clones the elements
-
deepCopy
public static <T> void deepCopy(@Nonnull T[] source, @Nonnull UnaryOperator<T> cloningFunction, @Nonnull T[] sink) Perform a deep copy of all the elements from a given array to another.If the source array contains
nullelements, the cloning function should be able to handle null input.- Type Parameters:
T- The type of elements in the arrays- Parameters:
source- The source of the elementscloningFunction- The function which clones the elementssink- The array in which to copy to the cloned elements to
-
deepCopy
@Nonnull public static <T> T[] deepCopy(@Nonnull T[] source, @Nonnull UnaryOperator<T> cloningFunction, @Nonnull IntFunction<T[]> sinkSupplier) Perform a deep copy of all the elements from a given array to another.If the source array contains
nullelements, the cloning function should be able to handle null input.- Type Parameters:
T- The type of elements in the arrays- Parameters:
source- The source of the elementscloningFunction- The function which clones the elementssinkSupplier- The supplier which consumes the length of the source array and supplies the array to copy the cloned elements to
-