Annotation Interface JSONCollectionType


@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface JSONCollectionType
Provides a hint to the default deserializer that the generic type for a collection takes a specific single type (Lists, Sets).

Java's Generics are not reified as class data, and cannot be queried via reflection, hence why this hint exists.

If the type to deserialize to is an interface or abstract class, the following implementations are used for the underlying collection type (searched in this order):

  • List<T> - ArrayList<T>
  • SortedSet<T> - TreeSet<T>
  • Set<T> - HashSet<T>
  • Iterable<T> - ArrayList<T>
  • Collection<T> - ArrayList<T>
If not a Collection, a JSONConversionException will occur.
Since:
1.1.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Element Details

    • value

      Class<?> value
      Returns:
      the Generic type for the collection.
      Default:
      com.blackrook.json.JSONObject.class