NoneableLong

@JsonQualifier()
public @interface NoneableLong

Marks a Long field as carrying Alpha Vantage's numeric-or-"None" convention, routing its deserialization through NoneableLongAdapter instead of Moshi's default Long handling.

Several Alpha Vantage endpoints report a numeric field that hasn't been computed yet — for example a company overview's market capitalization before the company has reported financials — as the literal JSON string "None", rather than omitting the key or sending JSON null. Moshi cannot coerce that string into a Long on its own, so a field holding such a value fails to parse unless something intercepts it; a plain Optional<Long> field wouldn't help either, since the problem is the incoming string, not the field's nullability. Annotating the field with this qualifier instead redirects its deserialization to NoneableLongAdapter, which distinguishes Alpha Vantage's explicit "None" placeholder from an ordinary numeric value by producing null for the former.

This annotation carries no data of its own; it is a Moshi JsonQualifier used purely to select the adapter.

Author

Sylvester Sefa-Yeboah

Since

1.7.0

Functions

Link copied to clipboard
public abstract Class<? extends Annotation> annotationType()
Link copied to clipboard
public abstract boolean equals(Object p)
Link copied to clipboard
public abstract int hashCode()
Link copied to clipboard
public abstract String toString()