Package org.ldaptive.beans.reflect
Class AbstractCollectionReflectionTranscoder
- java.lang.Object
-
- org.ldaptive.beans.reflect.AbstractCollectionReflectionTranscoder
-
- All Implemented Interfaces:
ReflectionTranscoder
- Direct Known Subclasses:
ListReflectionTranscoder,SetReflectionTranscoder
public abstract class AbstractCollectionReflectionTranscoder extends Object implements ReflectionTranscoder
Reflection transcoder for an object that implements aCollection.
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayReflectionTranscoderarrayTranscoderUsed for collections that contain arrays.private SingleValueReflectionTranscoder<?>singleValueTranscoderUsed for collections that do not contain arrays.private Class<?>typeType that is a collection.
-
Constructor Summary
Constructors Constructor Description AbstractCollectionReflectionTranscoder(Class<?> c, ArrayReflectionTranscoder transcoder)Creates a new abstract collection reflection transcoder.AbstractCollectionReflectionTranscoder(Class<?> c, SingleValueReflectionTranscoder<?> transcoder)Creates a new abstract collection reflection transcoder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract <T> Collection<T>createCollection(Class<T> clazz)Returns a collection implementation of the correct type for this transcoder.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 values)Encodes the supplied value into one or more byte arrays for use in an attribute.Collection<String>encodeStringValues(Object values)Encodes the supplied value into one or more strings for use in an attribute.Class<?>getType()Returns the type produced by this transcoder.booleansupports(Class<?> t)Returns whether this transcoder can convert object of the supplied type.StringtoString()
-
-
-
Field Detail
-
type
private final Class<?> type
Type that is a collection.
-
singleValueTranscoder
private final SingleValueReflectionTranscoder<?> singleValueTranscoder
Used for collections that do not contain arrays.
-
arrayTranscoder
private final ArrayReflectionTranscoder arrayTranscoder
Used for collections that contain arrays.
-
-
Constructor Detail
-
AbstractCollectionReflectionTranscoder
public AbstractCollectionReflectionTranscoder(Class<?> c, SingleValueReflectionTranscoder<?> transcoder)
Creates a new abstract collection reflection transcoder.- Parameters:
c- class that is a collectiontranscoder- to operate on elements of the collection
-
AbstractCollectionReflectionTranscoder
public AbstractCollectionReflectionTranscoder(Class<?> c, ArrayReflectionTranscoder transcoder)
Creates a new abstract collection reflection transcoder.- Parameters:
c- class that is a collectiontranscoder- to operate on elements of the collection
-
-
Method Detail
-
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 values)
Description copied from interface:ReflectionTranscoderEncodes the supplied value into one or more strings for use in an attribute.- Specified by:
encodeStringValuesin interfaceReflectionTranscoder- Parameters:
values- containing data to encode as strings- Returns:
- string attribute values
-
encodeBinaryValues
public Collection<byte[]> encodeBinaryValues(Object values)
Description copied from interface:ReflectionTranscoderEncodes the supplied value into one or more byte arrays for use in an attribute.- Specified by:
encodeBinaryValuesin interfaceReflectionTranscoder- Parameters:
values- containing data to encode as byte arrays- Returns:
- binary attribute values
-
createCollection
protected abstract <T> Collection<T> createCollection(Class<T> clazz)
Returns a collection implementation of the correct type for this transcoder.- Type Parameters:
T- type of collection- Parameters:
clazz- type of collection- Returns:
- collection implementation
-
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<?> t)
Description copied from interface:ReflectionTranscoderReturns whether this transcoder can convert object of the supplied type.- Specified by:
supportsin interfaceReflectionTranscoder- Parameters:
t- of object- Returns:
- whether the supplied type can be converted
-
-