public class CustomConversions extends Object
List
of converters and some additional logic
around them. The converters are pretty much builds up two sets of types which Mongo basic types #MONGO_TYPES
can be converted into and from. These types will be considered simple ones (which means they neither need deeper
inspection nor nested conversion. Thus the CustomConversions
also act as factory for SimpleTypeHolder
.Constructor and Description |
---|
CustomConversions(List<?> converters)
Creates a new
CustomConversions instance registering the given converters. |
Modifier and Type | Method and Description |
---|---|
Class<?> |
getCustomWriteTarget(Class<?> sourceType)
Returns the target type to convert to in case we have a custom conversion registered to convert the given source
type into a Mongo native one.
|
Class<?> |
getCustomWriteTarget(Class<?> sourceType,
Class<?> requestedTargetType)
Returns the target type we can readTargetWriteLocl an inject of the given source type to.
|
SimpleTypeHolder |
getSimpleTypeHolder()
Returns the underlying
SimpleTypeHolder . |
boolean |
hasCustomReadTarget(Class<?> sourceType,
Class<?> requestedTargetType)
Returns whether we have a custom conversion registered to readTargetReadLock the given source into the given target
type.
|
boolean |
hasCustomWriteTarget(Class<?> sourceType)
Returns whether we have a custom conversion registered to readTargetWriteLocl into a Mongo native type.
|
boolean |
hasCustomWriteTarget(Class<?> sourceType,
Class<?> requestedTargetType)
Returns whether we have a custom conversion registered to readTargetWriteLocl an object of the given source type
into an object of the given Mongo native target type.
|
boolean |
isSimpleType(Class<?> type)
Returns whether the given type is considered to be simple.
|
void |
registerConvertersIn(GenericConversionService conversionService)
Populates the given
GenericConversionService with the convertes registered. |
public CustomConversions(List<?> converters)
CustomConversions
instance registering the given converters.converters
- public SimpleTypeHolder getSimpleTypeHolder()
SimpleTypeHolder
.public boolean isSimpleType(Class<?> type)
Converter
registered for a particular type.type
- SimpleTypeHolder.isSimpleType(Class)
public void registerConvertersIn(GenericConversionService conversionService)
GenericConversionService
with the convertes registered.conversionService
- public Class<?> getCustomWriteTarget(Class<?> sourceType)
sourceType
- must not be nullpublic Class<?> getCustomWriteTarget(Class<?> sourceType, Class<?> requestedTargetType)
expectedTargetType
is null we will simply
return the first target type matching or null if no conversion can be found.sourceType
- must not be nullrequestedTargetType
- public boolean hasCustomWriteTarget(Class<?> sourceType)
sourceType
- must not be nullpublic boolean hasCustomWriteTarget(Class<?> sourceType, Class<?> requestedTargetType)
sourceType
- must not be null.requestedTargetType
- public boolean hasCustomReadTarget(Class<?> sourceType, Class<?> requestedTargetType)
sourceType
- must not be nullrequestedTargetType
- must not be nullCopyright © 2011-2015–2015 Pivotal Software, Inc.. All rights reserved.