Package org.instancio.internal.spi
Interface InternalContainerFactoryProvider
An SPI that allows populating data structures using a method.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescription<S,
T> Function<S, T> getMappingFunction
(Class<T> targetType, List<Class<?>> typeArguments) Returns a function that converts a source object of typeS
to the target typeT
.boolean
isContainer
(Class<?> type) Returnstrue
if the giventype
represents a container.
-
Method Details
-
getMappingFunction
Returns a function that converts a source object of typeS
to the target typeT
.The
typeArguments
is provided for containers that require the type of element to be specified at construction time, for exampleEnumMap(Class)
.- Type Parameters:
S
- source typeT
- target type- Parameters:
targetType
- the type to be createdtypeArguments
- type arguments of the source object, or an empty list if the source object is not a parameterised type- Returns:
- conversion function, or
null
if not defined
-
isContainer
Returnstrue
if the giventype
represents a container. A container is a data structure that is populated using a method, for exampleCollection.add()
orOptional.of()
If a class is marked as a container, Instancio will not inspect its fields since the object will not be populated via fields.Container generators should return a
InternalContainerHint
that specifies how the data structure should be populated.- Parameters:
type
- to check- Returns:
true
if the type is a container,false
otherwise- See Also:
-