Package org.ldaptive.beans.reflect
Class SingleValueReflectionTranscoder<T>
- java.lang.Object
-
- org.ldaptive.beans.reflect.SingleValueReflectionTranscoder<T>
-
- Type Parameters:
T- type of object to transcode
- All Implemented Interfaces:
ReflectionTranscoder
public class SingleValueReflectionTranscoder<T> extends Object implements ReflectionTranscoder
Reflection transcoder which expects to operate on collections containing a single value.
-
-
Field Summary
Fields Modifier and Type Field Description private ValueTranscoder<T>valueTranscoderUnderlying value transcoder.
-
Constructor Summary
Constructors Constructor Description SingleValueReflectionTranscoder(ValueTranscoder<T> transcoder)Creates a new single value reflection transcoder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectdecodeBinaryValues(Collection<byte[]> values)Decodes the supplied values into an object.ObjectdecodeStringValues(Collection<String> values)Decodes the supplied values into an object.Collection<byte[]>encodeBinaryValues(Object value)Encodes the supplied value into one or more byte arrays for use in an attribute.Collection<String>encodeStringValues(Object value)Encodes the supplied value into one or more strings for use in an attribute.Class<?>getType()Returns the type produced by this transcoder.static <T> SingleValueReflectionTranscoder<T>newInstance(ValueTranscoder<T> transcoder)Creates a new single value reflection transcoder.booleansupports(Class<?> type)Returns whether this transcoder can convert object of the supplied type.StringtoString()
-
-
-
Field Detail
-
valueTranscoder
private final ValueTranscoder<T> valueTranscoder
Underlying value transcoder.
-
-
Constructor Detail
-
SingleValueReflectionTranscoder
public SingleValueReflectionTranscoder(ValueTranscoder<T> transcoder)
Creates a new single value reflection transcoder.- Parameters:
transcoder- for a single value
-
-
Method Detail
-
newInstance
public static <T> SingleValueReflectionTranscoder<T> newInstance(ValueTranscoder<T> transcoder)
Creates a new single value reflection transcoder. Useful when the type of the value transcoder is unknown.- Type Parameters:
T- type to transcode- Parameters:
transcoder- for a single value- Returns:
- single value reflection transcoder
-
decodeStringValues
public Object decodeStringValues(Collection<String> values)
Description copied from interface:ReflectionTranscoderDecodes the supplied values into an object.- Specified by:
decodeStringValuesin interfaceReflectionTranscoder- Parameters:
values- to decode- Returns:
- object initialized with the values
-
decodeBinaryValues
public Object decodeBinaryValues(Collection<byte[]> values)
Description copied from interface:ReflectionTranscoderDecodes the supplied values into an object.- Specified by:
decodeBinaryValuesin interfaceReflectionTranscoder- Parameters:
values- to decode- Returns:
- object initialized with the values
-
encodeStringValues
public Collection<String> encodeStringValues(Object value)
Description copied from interface:ReflectionTranscoderEncodes the supplied value into one or more strings for use in an attribute.- Specified by:
encodeStringValuesin interfaceReflectionTranscoder- Parameters:
value- containing data to encode as strings- Returns:
- string attribute values
-
encodeBinaryValues
public Collection<byte[]> encodeBinaryValues(Object value)
Description copied from interface:ReflectionTranscoderEncodes the supplied value into one or more byte arrays for use in an attribute.- Specified by:
encodeBinaryValuesin interfaceReflectionTranscoder- Parameters:
value- containing data to encode as byte arrays- Returns:
- binary attribute values
-
getType
public Class<?> getType()
Description copied from interface:ReflectionTranscoderReturns the type produced by this transcoder.- Specified by:
getTypein interfaceReflectionTranscoder- Returns:
- type produced by this transcoder
-
supports
public boolean supports(Class<?> type)
Description copied from interface:ReflectionTranscoderReturns whether this transcoder can convert object of the supplied type.- Specified by:
supportsin interfaceReflectionTranscoder- Parameters:
type- of object- Returns:
- whether the supplied type can be converted
-
-