Package org.keycloak.models.map.common
Class DeepCloner.Builder
- java.lang.Object
-
- org.keycloak.models.map.common.DeepCloner.Builder
-
- Enclosing class:
- DeepCloner
public static class DeepCloner.Builder extends Object
Builder for theDeepClonerhelper class.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeepClonerbuild()Returns aDeepClonerinitialized with the respective constructors and cloners.<V> DeepCloner.Buildercloner(Class<? extends V> clazz, DeepCloner.Cloner<?> cloner)Adds a method that copies (as in a deep copy) an object properties from one object to another<V> DeepCloner.Buildercloner(Class<? extends V> clazz, DeepCloner.Cloner<?> clonerWithId, DeepCloner.Cloner<?> clonerWithoutId)Adds a method that copies (as in a deep copy) an object properties from one object to another<V> DeepCloner.Builderconstructor(Class<V> clazz, Function<DeepCloner,? extends V> constructor)Adds a method, often a constructor, that instantiates a record of typeV.<V> DeepCloner.BuilderdelegateCreator(Class<V> clazz, DeepCloner.DelegateCreator<V> delegateCreator)Adds a method, often a constructor, that instantiates a delegate of typeV.<V> DeepCloner.BuilderdelegateCreator(Class<V> clazz, DeepCloner.EntityFieldDelegateCreator<V> delegateCreator)Adds a method that instantiates an per-field delegate of typeV.<V> DeepCloner.BuildergenericCloner(DeepCloner.Cloner<V> genericCloner)Adds a method that copies (as in a deep copy) an object properties to another object for any class that is not covered by a specific cloner set via#cloner(Class, BiFunction)method.
-
-
-
Method Detail
-
build
public DeepCloner build()
Returns aDeepClonerinitialized with the respective constructors and cloners.- Returns:
-
constructor
public <V> DeepCloner.Builder constructor(Class<V> clazz, Function<DeepCloner,? extends V> constructor)
Adds a method, often a constructor, that instantiates a record of typeV.- Type Parameters:
V- Class or interface that would be instantiated by the given methods- Parameters:
clazz- Class or interface that would be instantiated by the given methodsconstructor- Function that creates a new instance of classV. Ifnull, such a single-parameter constructor is not available.- Returns:
- This builder.
-
delegateCreator
public <V> DeepCloner.Builder delegateCreator(Class<V> clazz, DeepCloner.EntityFieldDelegateCreator<V> delegateCreator)
Adds a method that instantiates an per-field delegate of typeV.- Type Parameters:
V- Class or interface that would be instantiated by the given methods- Parameters:
clazz- Class or interface that would be instantiated by the given methodsdelegateCreator- Function that creates a new instance of classV. Ifnull, such a single-parameter constructor is not available.- Returns:
- This builder.
-
delegateCreator
public <V> DeepCloner.Builder delegateCreator(Class<V> clazz, DeepCloner.DelegateCreator<V> delegateCreator)
Adds a method, often a constructor, that instantiates a delegate of typeV.- Type Parameters:
V- Class or interface that would be instantiated by the given methods- Parameters:
clazz- Class or interface that would be instantiated by the given methodsdelegateCreator- Function that creates a new instance of classV. Ifnull, such a single-parameter constructor is not available.- Returns:
- This builder.
-
cloner
public <V> DeepCloner.Builder cloner(Class<? extends V> clazz, DeepCloner.Cloner<?> cloner)
Adds a method that copies (as in a deep copy) an object properties from one object to another- Type Parameters:
V- Class or interface whose instance would be copied over to another instance by the given cloner- Parameters:
clazz- Class or interface whose instance would be copied over to another instance by the given clonercloner- A method for cloning with the following signature:V deepClone(V from, V to)which copies properties of an objectfromonto the objectto. This function usually returnsto- Returns:
- This builder.
-
cloner
public <V> DeepCloner.Builder cloner(Class<? extends V> clazz, DeepCloner.Cloner<?> clonerWithId, DeepCloner.Cloner<?> clonerWithoutId)
Adds a method that copies (as in a deep copy) an object properties from one object to another- Type Parameters:
V- Class or interface whose instance would be copied over to another instance by the given cloner- Parameters:
clazz- Class or interface whose instance would be copied over to another instance by the given clonerclonerWithId- A method for cloning with the following signature:V deepClone(V from, V to)which copies properties of an objectfromonto the objectto. This function usually returnsto- Returns:
- This builder.
-
genericCloner
public <V> DeepCloner.Builder genericCloner(DeepCloner.Cloner<V> genericCloner)
Adds a method that copies (as in a deep copy) an object properties to another object for any class that is not covered by a specific cloner set via#cloner(Class, BiFunction)method.- Type Parameters:
V- Class or interface whose instance would be copied over to another instance by the given cloner- Parameters:
genericCloner- A method for cloning which copies properties of an object onto another object. This function usually returnsto- Returns:
- This builder.
-
-