Package org.refcodes.net
Interface Unmarshalable<SRC>
-
- Type Parameters:
SRC
- The context which may influence the object being created by this factory.
- All Known Subinterfaces:
MediaTypeFactory
- All Known Implementing Classes:
FormMediaTypeFactory
,JsonMediaTypeFactory
,TextMediaTypeFactory
,XmlMediaTypeFactory
,YamlMediaTypeFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Unmarshalable<SRC>
TheUnmarshalable
defines the functionality which must be provided in order to represent a factory for object creation of an object being of a requested type (in contrast to theTypeFactory
and theLookupFactory
) from an instance of a provided type. Many alternative implementations of aUnmarshalable
may may exist which construct the instances their way. Having factories that generic as we define it here, we are able to decouple our business logic from any specific framework: Your business logic must not know anything about how the instances are generated. It mainly just needs to know how to use theUnmarshalable
. It is up to the application "end point", i.e. a command line tool with a main-method or a web-application to finally decide which factory to use.Depending on the implementation used or configuration provided, the
Unmarshalable
may return singletons or dedicated separate instances when queried for instances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.Object
toUnmarshaled(SRC aContext, java.lang.Class<?>... aTypes)
This method creates / retrieves an instance of one of the given types from the provided instance.<T> T
toUnmarshaled(SRC aContext, java.lang.Class<T> aType)
This method creates / retrieves an instance of the given type from the provided instance.default <T> T
toUnmarshaled(SRC aContext, java.lang.Class<T> aType, java.util.Map<java.lang.String,java.lang.String> aProperties)
This method creates / retrieves all instances of the given type.default java.lang.Object
toUnmarshaled(SRC aContext, java.util.Map<java.lang.String,java.lang.String> aProperties, java.lang.Class<?>... aTypes)
This method creates / retrieves an instance of one of the given types from the provided instance.
-
-
-
Method Detail
-
toUnmarshaled
<T> T toUnmarshaled(SRC aContext, java.lang.Class<T> aType) throws org.refcodes.exception.UnmarshalException
This method creates / retrieves an instance of the given type from the provided instance.- Type Parameters:
T
- The type which is to be fabricated by the factory method.- Parameters:
aContext
- The context which may influence the object being created by this factory.aType
- The type identifying the instance to be created / retrieved.- Returns:
- An instance of the required type for the given type and context.
- Throws:
org.refcodes.exception.UnmarshalException
- Thrown when unmarshaling / deserializing an object fails.
-
toUnmarshaled
default java.lang.Object toUnmarshaled(SRC aContext, java.lang.Class<?>... aTypes) throws org.refcodes.exception.UnmarshalException
This method creates / retrieves an instance of one of the given types from the provided instance. The returned instance's type is to be tested e.g. via "instanceof".- Parameters:
aContext
- The context which may influence the object being created by this factory.aTypes
- The types identifying the instance to be created / retrieved.- Returns:
- An instance of the type for which unmarshaling the context succeeded. You have to verify yourself which type you actually retrieved e.g. via "instanceof".
- Throws:
org.refcodes.exception.UnmarshalException
- Thrown when unmarshaling / deserializing for all provided types failed.
-
toUnmarshaled
default java.lang.Object toUnmarshaled(SRC aContext, java.util.Map<java.lang.String,java.lang.String> aProperties, java.lang.Class<?>... aTypes) throws org.refcodes.exception.UnmarshalException
This method creates / retrieves an instance of one of the given types from the provided instance. The returned instance's type is to be tested e.g. via "instanceof".- Parameters:
aContext
- The context which may influence the object being created by this factory.aProperties
- The dynamic properties which are used to configure the desired bean.aTypes
- The types identifying the instance to be created / retrieved.- Returns:
- An instance of the type for which unmarshaling the context succeeded. You have to verify yourself which type you actually retrieved e.g. via "instanceof".
- Throws:
org.refcodes.exception.UnmarshalException
- Thrown when unmarshaling / deserializing for all provided types failed.
-
toUnmarshaled
default <T> T toUnmarshaled(SRC aContext, java.lang.Class<T> aType, java.util.Map<java.lang.String,java.lang.String> aProperties) throws org.refcodes.exception.UnmarshalException
This method creates / retrieves all instances of the given type.- Type Parameters:
T
- The type which is to be fabricated by the factory method.- Parameters:
aContext
- The context which may influence the object being created by this factory.aType
- The type identifying the instances to be created / retrieved.aProperties
- The dynamic properties which are used to configure the desired bean.- Returns:
- An instance of the required type for the given type and context.
- Throws:
org.refcodes.exception.UnmarshalException
- Thrown when unmarshaling / deserializing an object fails.
-
-