Package org.ldaptive.beans.reflect
Class DefaultReflectionTranscoder
java.lang.Object
org.ldaptive.beans.reflect.DefaultReflectionTranscoder
- All Implemented Interfaces:
ReflectionTranscoder
Default implementation of a reflection transcoder. Determines the correct underlying reflection transcoder by
inspecting the class type characteristics.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SingleValueReflectionTranscoder<?>
Custom transcoder to override the default transcoder.protected final org.slf4j.Logger
Logger for this class.private final Set<SingleValueReflectionTranscoder<?>>
Set of transcoders support single values.private final ReflectionTranscoder
Transcoder for this type. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new default reflection transcoder.DefaultReflectionTranscoder
(Type type, ValueTranscoder<?> transcoder) Creates a new default reflection transcoder. -
Method Summary
Modifier and TypeMethodDescriptiondecodeBinaryValues
(Collection<byte[]> values) Decodes the supplied values into an object.decodeStringValues
(Collection<String> values) Decodes the supplied values into an object.Collection<byte[]>
encodeBinaryValues
(Object values) Encodes the supplied value into one or more byte arrays for use in an attribute.encodeStringValues
(Object values) Encodes the supplied value into one or more strings for use in an attribute.protected ReflectionTranscoder
getCollectionEncoder
(Class<?> type, Type genericType) Returns the appropriate collection encoder for the supplied type.protected Set<SingleValueReflectionTranscoder<?>>
Initializes the set of default single value transcoders.protected SingleValueReflectionTranscoder
getSingleValueReflectionTranscoder
(Class<?> type) Returns the appropriate single value encoder for the supplied type.Class<?>
getType()
Returns the type produced by this transcoder.boolean
Returns whether this transcoder can convert object of the supplied type.toString()
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger for this class. -
customTranscoder
Custom transcoder to override the default transcoder. -
valueTranscoder
Transcoder for this type. -
singleValueTranscoders
Set of transcoders support single values.
-
-
Constructor Details
-
DefaultReflectionTranscoder
Creates a new default reflection transcoder.- Parameters:
type
- of object to transcode
-
DefaultReflectionTranscoder
Creates a new default reflection transcoder.- Parameters:
type
- of object to transcodetranscoder
- custom transcoder for this type
-
-
Method Details
-
getDefaultSingleValueTranscoders
Initializes the set of default single value transcoders.- Returns:
- single value transcoders
-
getSingleValueReflectionTranscoder
Returns the appropriate single value encoder for the supplied type.- Parameters:
type
- to provide a single value encoder for- Returns:
- single value reflection transcoder
-
getCollectionEncoder
Returns the appropriate collection encoder for the supplied type.- Parameters:
type
- to provide a collection encoder forgenericType
- of the collection- Returns:
- reflection transcoder for a collection
-
decodeStringValues
Description copied from interface:ReflectionTranscoder
Decodes the supplied values into an object.- Specified by:
decodeStringValues
in interfaceReflectionTranscoder
- Parameters:
values
- to decode- Returns:
- object initialized with the values
-
decodeBinaryValues
Description copied from interface:ReflectionTranscoder
Decodes the supplied values into an object.- Specified by:
decodeBinaryValues
in interfaceReflectionTranscoder
- Parameters:
values
- to decode- Returns:
- object initialized with the values
-
encodeStringValues
Description copied from interface:ReflectionTranscoder
Encodes the supplied value into one or more strings for use in an attribute.- Specified by:
encodeStringValues
in interfaceReflectionTranscoder
- Parameters:
values
- containing data to encode as strings- Returns:
- string attribute values
-
encodeBinaryValues
Description copied from interface:ReflectionTranscoder
Encodes the supplied value into one or more byte arrays for use in an attribute.- Specified by:
encodeBinaryValues
in interfaceReflectionTranscoder
- Parameters:
values
- containing data to encode as byte arrays- Returns:
- binary attribute values
-
getType
Description copied from interface:ReflectionTranscoder
Returns the type produced by this transcoder.- Specified by:
getType
in interfaceReflectionTranscoder
- Returns:
- type produced by this transcoder
-
supports
Description copied from interface:ReflectionTranscoder
Returns whether this transcoder can convert object of the supplied type.- Specified by:
supports
in interfaceReflectionTranscoder
- Parameters:
type
- of object- Returns:
- whether the supplied type can be converted
-
toString
-