@Documented
@JsonQualifier
@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD})
public @interface FallbackOnNull
null in the json source and thus requires a
fallback value.
To leverage from FallbackOnNull ADAPTER_FACTORY must be added to your Moshi instance:
Moshi moshi = new Moshi.Builder()
.add(FallbackOnNull.ADAPTER_FACTORY)
.build();
| Modifier and Type | Fields and Description |
|---|---|
static com.squareup.moshi.JsonAdapter.Factory |
ADAPTER_FACTORY
Builds an adapter that can process a types annotated with
FallbackOnNull. |
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
fallbackBoolean
Fallback value for
boolean primitives. |
byte |
fallbackByte
Fallback value for
byte primitives. |
char |
fallbackChar
Fallback value for
char primitives. |
double |
fallbackDouble
Fallback value for
double primitives. |
float |
fallbackFloat
Fallback value for
float primitives. |
int |
fallbackInt
Fallback value for
int primitives. |
long |
fallbackLong
Fallback value for
long primitives. |
short |
fallbackShort
Fallback value for
short primitives. |
public static final com.squareup.moshi.JsonAdapter.Factory ADAPTER_FACTORY
FallbackOnNull.public abstract boolean fallbackBoolean
boolean primitives. Default: false.public abstract byte fallbackByte
byte primitives. Default: Byte.MIN_VALUE.public abstract char fallbackChar
char primitives. Default: Character.MIN_VALUE.public abstract double fallbackDouble
double primitives. Default: Double.MIN_VALUE.public abstract float fallbackFloat
float primitives. Default: Float.MIN_VALUE.public abstract int fallbackInt
int primitives. Default: Integer.MIN_VALUE.