Module io.github.sugarcubes.cloner
Package io.github.sugarcubes.cloner.spi
Interface InstanceAllocatorFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Instance allocator factory interface.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanTells whether allocators of this factory call a constructor of the type.<T> Optional<InstanceAllocator<T>>newAllocator(Class<T> type) Prepares an allocator for the type.
-
Method Details
-
newAllocator
Prepares an allocator for the type. Whether the factory supports the type is decided here, so the allocator fails only because of the environment or the object itself.- Type Parameters:
T- object type- Parameters:
type- type- Returns:
- allocator, or empty if the factory cannot create instances of the type
-
invokesConstructor
default boolean invokesConstructor()Tells whether allocators of this factory call a constructor of the type. Constructors may have side effects which a clone should not repeat.- Returns:
trueif allocators call constructors,falseif they only allocate objects
-