org.codegist.crest.serializer
Class Serializers

java.lang.Object
  extended by org.codegist.crest.serializer.Serializers

public final class Serializers
extends Object

Author:
Laurent Gilles (laurent.gilles@codegist.org)
See Also:
getFor(java.util.Map, java.lang.reflect.Type)

Method Summary
static Serializer getFor(Map<String,Object> customProperties, Type type)
          Handy method to retrieve a serializer instance for the given Type using the given customProperties following the behavior described by CRest for amethod argument serialization.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFor

public static Serializer getFor(Map<String,Object> customProperties,
                                Type type)

Handy method to retrieve a serializer instance for the given Type using the given customProperties following the behavior described by CRest for amethod argument serialization.

The returned serializer is:

- a serializer from the map if the type match

- otherwise an instance of DateSerializer if no serializer for the given type has been found in the map and the type is a Date that serialize to ISO-8601 date format by default.

- otherwise an instance of ArraySerializer if the type happens to be either a Array or a Collection. The collection/array items serializer selection follows the same rules a stated before

- otherwise an instance of ToStringSerializer if no serializer for the given type has been found in the map

The custom properties can customize the default behavior, it may contain values mapped with the following keys:

- CRestProperty.SERIALIZER_CUSTOM_SERIALIZER_MAP

- CRestProperty.SERIALIZER_LIST_SEPARATOR

- CRestProperty.SERIALIZER_DATE_FORMAT

Parameters:
customProperties - Map of default serializer per Type
type - Type to get the serializer for
Returns:
the serializer


Copyright © 2011. All Rights Reserved.