Package org.cyclos.impl.utils.conversion
Class ConversionHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.utils.conversion.ConversionHandlerImpl
-
- All Implemented Interfaces:
ConversionHandler,ConversionHandlerInternal
@Component public class ConversionHandlerImpl extends BaseNetworkedHandlerImpl implements ConversionHandlerInternal
implementation forConversionHandler
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description ConversionHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends SimpleEntity,R>
RcachedEntityFromId(Class<E> entityType, Class<R> resultType, Long id, boolean rawHandler)Finds the given entity by id and then converts it to the result type.<T> Tclone(T object)Clones the given object, copying all properties<T> Tconvert(Class<T> toType, Object source)Converts an object into the given type<T> Tconvert(Class<T> toType, Object source, Object[] excluding, InvocationContext.ConversionContext context)Converts from the given object to the given type, with full context<T> TconvertExcluding(Class<T> toType, Object object, Object... excluding)Converts an object into the given type, excluding the given properties<T> Function<Object,T>convertingFunction(Class<T> toType, Object... excluding)Returns a function that converts any input object to a given type, excluding the given properties<T> com.mysema.commons.lang.CloseableIterator<T>convertIterator(Class<T> toType, com.mysema.commons.lang.CloseableIterator<?> iterator)Converts a closeable iterator, item by item, into the given type<T> Iterator<T>convertIterator(Class<T> toType, Iterator<?> iterator)Converts an iterator, item by item, into the given type<T> List<T>convertList(Class<T> elementType, Iterable<?> collection)Converts a collection of objects into a list the given type<T> List<T>convertList(Class<T> toType, Iterable<?> collection, Map<?,?> additionalProperties)Converts a collection of objects into a list the given type, setting the given additional properties to each element<T> List<T>convertList(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection)Converts a collection of objects into a list using the given type mapping<T> List<T>convertList(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties)Converts a collection of objects into a list using the given type mapping, setting the given additional properties to each element<T> List<T>convertList(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties, InvocationContext.ConversionContext context)Converts a collection of objects into a list using the given type mapping, setting the given additional properties to each element<K,V>
Map<K,V>convertMap(Class<K> keyType, Class<V> valueType, Map<?,?> map)Converts the given map's keys and values to the given types<K,V>
Map<K,V>convertMap(Class<K> keyType, Class<V> valueType, Map<?,?> map, InvocationContext.ConversionContext context)Converts the given map's keys and values to the given types, with full context<T> Page<T>convertPage(Class<T> toType, Iterable<?> collection)Converts a page of objects into a list the given type<T> Page<T>convertPage(Map<Class<?>,Class<?>> typeMapping, Iterable<?> iterable)Converts a collection of objects into a page using the given type mapping<T> Set<T>convertSet(Class<T> toType, Iterable<?> collection)Converts a collection of objects into a set the given type<T> Set<T>convertSet(Class<T> toType, Iterable<?> collection, Map<?,?> additionalProperties)Converts a collection of objects into a set of the given type, setting the given additional properties to each element<T> Set<T>convertSet(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection)Converts a collection of objects into a set using the given type mapping<T> Set<T>convertSet(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties)Converts a collection of objects into a set using the given type mapping, setting the given additional properties to each element<T> Set<T>convertSet(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties, InvocationContext.ConversionContext context)Converts a collection of objects into a set using the given type mapping, setting the given additional properties to each elementvoidfill(Object source, Object destination)Fills the destination object with the source propertiesvoidfill(Object source, Object destination, Object[] excludingProperties, InvocationContext.ConversionContext context)Fills the destination object with the source properties, with full contextvoidfillExcluding(Object source, Object destination, Object... excludedProprties)Fills the destination object with the source properties, excluding the given propertiesFormatterImplgetFormatter()Returns a new formatter instancevoidinitialize()DatetoDate(IDate dateTime)DateTimetoDateTime(Date date)-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
cachedEntityFromId
public <E extends SimpleEntity,R> R cachedEntityFromId(Class<E> entityType, Class<R> resultType, Long id, boolean rawHandler)
Description copied from interface:ConversionHandlerFinds the given entity by id and then converts it to the result type. The result is cached in the invocation context by entity type and id.- Specified by:
cachedEntityFromIdin interfaceConversionHandler
-
clone
public <T> T clone(T object)
Description copied from interface:ConversionHandlerClones the given object, copying all properties- Specified by:
clonein interfaceConversionHandler
-
convert
public <T> T convert(Class<T> toType, Object source)
Description copied from interface:ConversionHandlerConverts an object into the given type- Specified by:
convertin interfaceConversionHandler
-
convert
public <T> T convert(Class<T> toType, Object source, Object[] excluding, InvocationContext.ConversionContext context)
Description copied from interface:ConversionHandlerInternalConverts from the given object to the given type, with full context- Specified by:
convertin interfaceConversionHandlerInternal
-
convertExcluding
public <T> T convertExcluding(Class<T> toType, Object object, Object... excluding)
Description copied from interface:ConversionHandlerConverts an object into the given type, excluding the given properties- Specified by:
convertExcludingin interfaceConversionHandler
-
convertingFunction
public <T> Function<Object,T> convertingFunction(Class<T> toType, Object... excluding)
Description copied from interface:ConversionHandlerReturns a function that converts any input object to a given type, excluding the given properties- Specified by:
convertingFunctionin interfaceConversionHandler
-
convertIterator
public <T> com.mysema.commons.lang.CloseableIterator<T> convertIterator(Class<T> toType, com.mysema.commons.lang.CloseableIterator<?> iterator)
Description copied from interface:ConversionHandlerConverts a closeable iterator, item by item, into the given type- Specified by:
convertIteratorin interfaceConversionHandler
-
convertIterator
public <T> Iterator<T> convertIterator(Class<T> toType, Iterator<?> iterator)
Description copied from interface:ConversionHandlerConverts an iterator, item by item, into the given type- Specified by:
convertIteratorin interfaceConversionHandler
-
convertList
public <T> List<T> convertList(Class<T> elementType, Iterable<?> collection)
Description copied from interface:ConversionHandlerConverts a collection of objects into a list the given type- Specified by:
convertListin interfaceConversionHandler
-
convertList
public <T> List<T> convertList(Class<T> toType, Iterable<?> collection, Map<?,?> additionalProperties)
Description copied from interface:ConversionHandlerConverts a collection of objects into a list the given type, setting the given additional properties to each element- Specified by:
convertListin interfaceConversionHandler
-
convertList
public <T> List<T> convertList(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection)
Description copied from interface:ConversionHandlerConverts a collection of objects into a list using the given type mapping- Specified by:
convertListin interfaceConversionHandler
-
convertList
public <T> List<T> convertList(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties)
Description copied from interface:ConversionHandlerConverts a collection of objects into a list using the given type mapping, setting the given additional properties to each element- Specified by:
convertListin interfaceConversionHandler
-
convertList
public <T> List<T> convertList(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties, InvocationContext.ConversionContext context)
Description copied from interface:ConversionHandlerInternalConverts a collection of objects into a list using the given type mapping, setting the given additional properties to each element- Specified by:
convertListin interfaceConversionHandlerInternal
-
convertMap
public <K,V> Map<K,V> convertMap(Class<K> keyType, Class<V> valueType, Map<?,?> map)
Description copied from interface:ConversionHandlerConverts the given map's keys and values to the given types- Specified by:
convertMapin interfaceConversionHandler
-
convertMap
public <K,V> Map<K,V> convertMap(Class<K> keyType, Class<V> valueType, Map<?,?> map, InvocationContext.ConversionContext context)
Description copied from interface:ConversionHandlerInternalConverts the given map's keys and values to the given types, with full context- Specified by:
convertMapin interfaceConversionHandlerInternal
-
convertPage
public <T> Page<T> convertPage(Class<T> toType, Iterable<?> collection)
Description copied from interface:ConversionHandlerConverts a page of objects into a list the given type- Specified by:
convertPagein interfaceConversionHandler
-
convertPage
public <T> Page<T> convertPage(Map<Class<?>,Class<?>> typeMapping, Iterable<?> iterable)
Description copied from interface:ConversionHandlerConverts a collection of objects into a page using the given type mapping- Specified by:
convertPagein interfaceConversionHandler
-
convertSet
public <T> Set<T> convertSet(Class<T> toType, Iterable<?> collection)
Description copied from interface:ConversionHandlerConverts a collection of objects into a set the given type- Specified by:
convertSetin interfaceConversionHandler
-
convertSet
public <T> Set<T> convertSet(Class<T> toType, Iterable<?> collection, Map<?,?> additionalProperties)
Description copied from interface:ConversionHandlerConverts a collection of objects into a set of the given type, setting the given additional properties to each element- Specified by:
convertSetin interfaceConversionHandler
-
convertSet
public <T> Set<T> convertSet(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection)
Description copied from interface:ConversionHandlerConverts a collection of objects into a set using the given type mapping- Specified by:
convertSetin interfaceConversionHandler
-
convertSet
public <T> Set<T> convertSet(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties)
Description copied from interface:ConversionHandlerConverts a collection of objects into a set using the given type mapping, setting the given additional properties to each element- Specified by:
convertSetin interfaceConversionHandler
-
convertSet
public <T> Set<T> convertSet(Map<Class<?>,Class<?>> typeMapping, Iterable<?> collection, Map<?,?> additionalProperties, InvocationContext.ConversionContext context)
Description copied from interface:ConversionHandlerInternalConverts a collection of objects into a set using the given type mapping, setting the given additional properties to each element- Specified by:
convertSetin interfaceConversionHandlerInternal
-
fill
public void fill(Object source, Object destination)
Description copied from interface:ConversionHandlerFills the destination object with the source properties- Specified by:
fillin interfaceConversionHandler
-
fill
public void fill(Object source, Object destination, Object[] excludingProperties, InvocationContext.ConversionContext context)
Description copied from interface:ConversionHandlerInternalFills the destination object with the source properties, with full context- Specified by:
fillin interfaceConversionHandlerInternal
-
fillExcluding
public void fillExcluding(Object source, Object destination, Object... excludedProprties)
Description copied from interface:ConversionHandlerFills the destination object with the source properties, excluding the given properties- Specified by:
fillExcludingin interfaceConversionHandler
-
getFormatter
public FormatterImpl getFormatter()
Description copied from interface:ConversionHandlerReturns a new formatter instance- Specified by:
getFormatterin interfaceConversionHandler- Overrides:
getFormatterin classAbstractServerComponent
-
initialize
@PostConstruct public void initialize()
-
toDate
public Date toDate(IDate dateTime)
Description copied from interface:ConversionHandlerConverts a IDate (probably aDateTime) representing a date in the logged user's time zone to aDate.- Specified by:
toDatein interfaceConversionHandler
-
toDateTime
public DateTime toDateTime(Date date)
Description copied from class:AbstractNetworkedServerComponentConverts aDateto aDateTimeusing the logged user's time zone delegating to the conversion handler.- Specified by:
toDateTimein interfaceConversionHandler- Overrides:
toDateTimein classAbstractNetworkedServerComponent
-
-