Package com.backblaze.b2.json
Class B2JsonUnionBaseHandler<T>
- java.lang.Object
-
- com.backblaze.b2.json.B2JsonInitializedTypeHandler<T>
-
- com.backblaze.b2.json.B2JsonTypeHandlerWithDefaults<T>
-
- com.backblaze.b2.json.B2JsonUnionBaseHandler<T>
-
- All Implemented Interfaces:
B2JsonTypeHandler<T>
public class B2JsonUnionBaseHandler<T> extends B2JsonTypeHandlerWithDefaults<T>
Handler for the class that is the base class for a union type.This handler is used only for deserialization, where it finds the type name in the JSON object, and this dispatches to the subclass for that type.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkDefaultValues()
Check the validity of the default value, if there is one.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
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 b2JsonHandlerMap)
Does any initialization specific to the concrete class.boolean
isStringInJson()
Does this type look like a string in JSON?void
serialize(T obj, B2JsonOptions options, B2JsonWriter out)
Serialize one object of the class to a JSON output stream.-
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 b2JsonHandlerMap) 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
Check the validity of the default value, if there is one.- Specified by:
checkDefaultValues
in classB2JsonTypeHandlerWithDefaults<T>
- Throws:
B2JsonException
- if there is a problem
-
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
Description copied from interface:B2JsonTypeHandler
Serialize one object of the class to a JSON output stream. The object is guaranteed not to be null.- 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
-
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?
-
-