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 voidcheckDefaultValues()Checks the validity of all of the default values for fields with optionalWithDefault.TdefaultValueForOptional()Returns the default value to use when an optional field is not present.Tdeserialize(B2JsonReader in, B2JsonOptions options)Deserialize one object from a JSON input stream.TdeserializeFromFieldNameToValueMap(java.util.Map<java.lang.String,java.lang.Object> fieldNameToValue, B2JsonOptions options)TdeserializeFromUrlParameterMap(java.util.Map<java.lang.String,java.lang.String> parameterMap, B2JsonOptions options)TdeserializeUrlParam(java.lang.String urlValue)When an API is called with GET, this is used to deserialize one of the values.java.lang.reflect.TypegetHandledType()What class does this handle?protected voidinitializeImplementation(B2JsonHandlerMap handlerMap)Does any initialization specific to the concrete class.static booleanisBuiltInZeroableType(java.lang.Class<?> type)booleanisStringInJson()Does this type look like a string in JSON?static booleanisZero(java.lang.Object value)voidserialize(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:B2JsonInitializedTypeHandlerDoes any initialization specific to the concrete class. Override in classes that need to gather information from other handlers.- Overrides:
initializeImplementationin classB2JsonInitializedTypeHandler<T>- Throws:
B2JsonException
-
checkDefaultValues
protected void checkDefaultValues() throws B2JsonExceptionChecks the validity of all of the default values for fields with optionalWithDefault.- Specified by:
checkDefaultValuesin classB2JsonTypeHandlerWithDefaults<T>- Throws:
B2JsonException- if any are bad
-
getHandledType
public java.lang.reflect.Type getHandledType()
Description copied from interface:B2JsonTypeHandlerWhat 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.IOExceptionB2JsonException
-
deserializeUrlParam
public T deserializeUrlParam(java.lang.String urlValue) throws B2JsonException
Description copied from interface:B2JsonTypeHandlerWhen 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:B2JsonTypeHandlerDeserialize 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:
B2JsonExceptionjava.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:B2JsonTypeHandlerReturns the default value to use when an optional field is not present.
-
isStringInJson
public boolean isStringInJson()
Description copied from interface:B2JsonTypeHandlerDoes 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)
-
-