Package org.fulib.fx.duplicate
Class Duplicators
java.lang.Object
org.fulib.fx.duplicate.Duplicators
A registry for
Duplicators.
This class is used to register Duplicators for specific classes.
Call duplicate(Object) to duplicate an object.
Use register(Class, Duplicator) to register a Duplicator for a specific class.
You can also override existing Duplicators or extend them to create new ones if you need to add additional properties.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tduplicate(T object) Duplicates the given object using the registeredDuplicator.static <T> voidregister(Class<T> clazz, Duplicator<T> duplicator) Registers aDuplicatorfor the given class.
-
Constructor Details
-
Duplicators
public Duplicators()
-
-
Method Details
-
register
Registers aDuplicatorfor the given class.- Type Parameters:
T- The type of the class- Parameters:
clazz- The class to register theDuplicatorforduplicator- TheDuplicatorto register
-
duplicate
public static <T> T duplicate(T object) Duplicates the given object using the registeredDuplicator.- Type Parameters:
T- The type of the object- Parameters:
object- The object to duplicate- Returns:
- The duplicated object
- Throws:
IllegalArgumentException- If noDuplicatoris registered for the given object
-