Spring Data Couchbase

org.springframework.data.couchbase.core.convert
Class CustomConversions

java.lang.Object
  extended by org.springframework.data.couchbase.core.convert.CustomConversions

public class CustomConversions
extends Object

Value object to capture custom conversion.

Types that can be mapped directly onto JSON are considered simple ones, because they neither need deeper inspection nor nested conversion.

Author:
Michael Nitschinger, Oliver Gierke

Constructor Summary
CustomConversions(List<?> converters)
          Create a new instance with a given list of conversers.
 
Method Summary
 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 Couchbase native one.
 Class<?> getCustomWriteTarget(Class<?> sourceType, Class<?> requestedTargetType)
          Returns the target type we can write an object of the given source type to.
 SimpleTypeHolder getSimpleTypeHolder()
          Returns the simple type holder.
 boolean hasCustomReadTarget(Class<?> sourceType, Class<?> requestedTargetType)
          Returns whether we have a custom conversion registered to read the given source into the given target type.
 boolean hasCustomWriteTarget(Class<?> sourceType)
          Returns whether we have a custom conversion registered to write into a Couchbase native type.
 boolean hasCustomWriteTarget(Class<?> sourceType, Class<?> requestedTargetType)
          Returns whether we have a custom conversion registered to write an object of the given source type into an object of the given Couchbase native target type.
 boolean isSimpleType(Class<?> type)
          Check that the given type is of "simple type".
 void registerConvertersIn(GenericConversionService conversionService)
          Populates the given GenericConversionService with the convertes registered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomConversions

public CustomConversions(List<?> converters)
Create a new instance with a given list of conversers.

Parameters:
converters - the list of custom converters.
Method Detail

isSimpleType

public boolean isSimpleType(Class<?> type)
Check that the given type is of "simple type".

Parameters:
type - the type to check.
Returns:
if its simple type or not.

getSimpleTypeHolder

public SimpleTypeHolder getSimpleTypeHolder()
Returns the simple type holder.

Returns:
the simple type holder.

registerConvertersIn

public void registerConvertersIn(GenericConversionService conversionService)
Populates the given GenericConversionService with the convertes registered.

Parameters:
conversionService - the service to register.

getCustomWriteTarget

public 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 Couchbase native one.

Parameters:
sourceType - must not be null
Returns:

getCustomWriteTarget

public Class<?> getCustomWriteTarget(Class<?> sourceType,
                                     Class<?> requestedTargetType)
Returns the target type we can write an object of the given source type to. The returned type might be a subclass oth the given expected type though. If expectedTargetType is null we will simply return the first target type matching or null if no conversion can be found.

Parameters:
sourceType - must not be null
requestedTargetType -
Returns:

hasCustomWriteTarget

public boolean hasCustomWriteTarget(Class<?> sourceType)
Returns whether we have a custom conversion registered to write into a Couchbase native type. The returned type might be a subclass of the given expected type though.

Parameters:
sourceType - must not be null
Returns:

hasCustomWriteTarget

public boolean hasCustomWriteTarget(Class<?> sourceType,
                                    Class<?> requestedTargetType)
Returns whether we have a custom conversion registered to write an object of the given source type into an object of the given Couchbase native target type.

Parameters:
sourceType - must not be null.
requestedTargetType -
Returns:

hasCustomReadTarget

public boolean hasCustomReadTarget(Class<?> sourceType,
                                   Class<?> requestedTargetType)
Returns whether we have a custom conversion registered to read the given source into the given target type.

Parameters:
sourceType - must not be null
requestedTargetType - must not be null
Returns:

Spring Data Couchbase

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.