Class TypeConvertingVisitor<T>
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.internal.converter.TypeConvertingVisitor<T>
-
public abstract class TypeConvertingVisitor<T> extends Object
A visitor across all possible types of aEnhancedAttributeValue.This is useful in
AttributeConverterimplementations, without having to write a switch statement on theEnhancedAttributeValue.type().
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<?>targetType
-
Constructor Summary
Constructors Modifier Constructor Description protectedTypeConvertingVisitor(Class<?> targetType)Called by subclasses to provide enhanced logging when a specific type isn't handled.protectedTypeConvertingVisitor(Class<?> targetType, Class<?> converterClass)Called by subclasses to provide enhanced logging when a specific type isn't handled.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tconvert(EnhancedAttributeValue value)Convert the provided value into the target type.TconvertBoolean(Boolean value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isBoolean()is true.TconvertBytes(SdkBytes value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isBytes()is true.TconvertListOfAttributeValues(List<AttributeValue> value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isListOfAttributeValues()is true.TconvertMap(Map<String,AttributeValue> value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isMap()is true.TconvertNull()Invoked when visiting an attribute in whichEnhancedAttributeValue.isNull()is true.TconvertNumber(String value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isNumber()is true.TconvertSetOfBytes(List<SdkBytes> value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isSetOfBytes()is true.TconvertSetOfNumbers(List<String> value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isSetOfNumbers()is true.TconvertSetOfStrings(List<String> value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isSetOfStrings()is true.TconvertString(String value)Invoked when visiting an attribute in whichEnhancedAttributeValue.isString()is true.TdefaultConvert(AttributeValueType type, Object value)This is invoked by default if a different "convert" method is not overridden.
-
-
-
Field Detail
-
targetType
protected final Class<?> targetType
-
-
Constructor Detail
-
TypeConvertingVisitor
protected TypeConvertingVisitor(Class<?> targetType)
Called by subclasses to provide enhanced logging when a specific type isn't handled.Reasons this call may fail with a
RuntimeException:- If the provided type is null.
- Parameters:
targetType- The type to which this visitor is converting.
-
TypeConvertingVisitor
protected TypeConvertingVisitor(Class<?> targetType, Class<?> converterClass)
Called by subclasses to provide enhanced logging when a specific type isn't handled.Reasons this call may fail with a
RuntimeException:- If the provided type is null.
- Parameters:
targetType- The type to which this visitor is converting.converterClass- The converter implementation that is creating this visitor. This may be null.
-
-
Method Detail
-
convert
public final T convert(EnhancedAttributeValue value)
Convert the provided value into the target type.Reasons this call may fail with a
RuntimeException:- If the value cannot be converted by this visitor.
-
convertNull
public T convertNull()
Invoked when visiting an attribute in whichEnhancedAttributeValue.isNull()is true.
-
convertMap
public T convertMap(Map<String,AttributeValue> value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isMap()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertString
public T convertString(String value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isString()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertNumber
public T convertNumber(String value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isNumber()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertBytes
public T convertBytes(SdkBytes value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isBytes()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertBoolean
public T convertBoolean(Boolean value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isBoolean()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertSetOfStrings
public T convertSetOfStrings(List<String> value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isSetOfStrings()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertSetOfNumbers
public T convertSetOfNumbers(List<String> value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isSetOfNumbers()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertSetOfBytes
public T convertSetOfBytes(List<SdkBytes> value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isSetOfBytes()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
convertListOfAttributeValues
public T convertListOfAttributeValues(List<AttributeValue> value)
Invoked when visiting an attribute in whichEnhancedAttributeValue.isListOfAttributeValues()is true. The provided value is the underlying value of theEnhancedAttributeValuebeing converted.
-
defaultConvert
public T defaultConvert(AttributeValueType type, Object value)
This is invoked by default if a different "convert" method is not overridden. By default, this throws an exception.- Parameters:
type- The type that wasn't handled by another "convert" method.value- The value that wasn't handled by another "convert" method.
-
-