Package com.backblaze.b2.json
Class B2JsonObjectHandler<T>
- java.lang.Object
-
- com.backblaze.b2.json.B2JsonInitializedTypeHandler<T>
-
- com.backblaze.b2.json.B2JsonTypeHandlerWithDefaults<T>
-
- com.backblaze.b2.json.B2JsonObjectHandler<T>
-
- All Implemented Interfaces:
B2JsonTypeHandler<T>
public class B2JsonObjectHandler<T> extends B2JsonTypeHandlerWithDefaults<T>
(De)serializes Java objects based on field annotations.See doc comment on B2Json for annotation requirements.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkDefaultValues()
Checks the validity of all of the default values for fields with optionalWithDefault.T
defaultValueForOptional()
Returns the default value to use when an optional field is not present.T
deserialize(B2JsonReader in, B2JsonOptions options)
Deserialize one object from a JSON input stream.T
deserializeFromFieldNameToValueMap(java.util.Map<java.lang.String,java.lang.Object> fieldNameToValue, B2JsonOptions options)
T
deserializeFromUrlParameterMap(java.util.Map<java.lang.String,java.lang.String> parameterMap, B2JsonOptions options)
T
deserializeUrlParam(java.lang.String urlValue)
When an API is called with GET, this is used to deserialize one of the values.java.lang.reflect.Type
getHandledType()
What class does this handle?protected void
initializeImplementation(B2JsonHandlerMap handlerMap)
Does any initialization specific to the concrete class.static boolean
isBuiltInZeroableType(java.lang.Class<?> type)
boolean
isStringInJson()
Does this type look like a string in JSON?static boolean
isZero(java.lang.Object value)
void
serialize(T obj, B2JsonOptions options, B2JsonWriter out)
Serializes the object, adding all fields to the JSON.-
Methods inherited from class com.backblaze.b2.json.B2JsonTypeHandlerWithDefaults
throwIfBadDefaultValue
-
Methods inherited from class com.backblaze.b2.json.B2JsonInitializedTypeHandler
isInitialized
-
-
-
-
Method Detail
-
initializeImplementation
protected void initializeImplementation(B2JsonHandlerMap handlerMap) throws B2JsonException
Description copied from class:B2JsonInitializedTypeHandler
Does any initialization specific to the concrete class. Override in classes that need to gather information from other handlers.- Overrides:
initializeImplementation
in classB2JsonInitializedTypeHandler<T>
- Throws:
B2JsonException
-
checkDefaultValues
protected void checkDefaultValues() throws B2JsonException
Checks the validity of all of the default values for fields with optionalWithDefault.- Specified by:
checkDefaultValues
in classB2JsonTypeHandlerWithDefaults<T>
- Throws:
B2JsonException
- if any are bad
-
getHandledType
public java.lang.reflect.Type getHandledType()
Description copied from interface:B2JsonTypeHandler
What class does this handle?- Returns:
-
serialize
public void serialize(T obj, B2JsonOptions options, B2JsonWriter out) throws java.io.IOException, B2JsonException
Serializes the object, adding all fields to the JSON.Optional fields are always present, and set to null/0 when not present.
The type name field for a member of a union type is added alphabetically in sequence, if needed.
- Throws:
java.io.IOException
B2JsonException
-
deserializeUrlParam
public T deserializeUrlParam(java.lang.String urlValue) throws B2JsonException
Description copied from interface:B2JsonTypeHandler
When an API is called with GET, this is used to deserialize one of the values.- Throws:
B2JsonException
-
deserialize
public T deserialize(B2JsonReader in, B2JsonOptions options) throws B2JsonException, java.io.IOException
Description copied from interface:B2JsonTypeHandler
Deserialize one object from a JSON input stream. Will never be called when there is "null" in the input stream, and will never return null.- Throws:
B2JsonException
java.io.IOException
-
deserializeFromFieldNameToValueMap
public T deserializeFromFieldNameToValueMap(java.util.Map<java.lang.String,java.lang.Object> fieldNameToValue, B2JsonOptions options) throws B2JsonException
- Throws:
B2JsonException
-
deserializeFromUrlParameterMap
public T deserializeFromUrlParameterMap(java.util.Map<java.lang.String,java.lang.String> parameterMap, B2JsonOptions options) throws B2JsonException
- Throws:
B2JsonException
-
defaultValueForOptional
public T defaultValueForOptional()
Description copied from interface:B2JsonTypeHandler
Returns the default value to use when an optional field is not present.
-
isStringInJson
public boolean isStringInJson()
Description copied from interface:B2JsonTypeHandler
Does this type look like a string in JSON?
-
isBuiltInZeroableType
public static boolean isBuiltInZeroableType(java.lang.Class<?> type)
-
isZero
public static boolean isZero(java.lang.Object value)
-
-