Class CollectionTypeAdapterFactory

java.lang.Object
com.suse.salt.netapi.parser.CollectionTypeAdapterFactory
All Implemented Interfaces:
com.google.gson.TypeAdapterFactory

public class CollectionTypeAdapterFactory extends Object implements com.google.gson.TypeAdapterFactory
Adapt a homogeneous collection of objects.
  • Constructor Details

    • CollectionTypeAdapterFactory

      public CollectionTypeAdapterFactory()
  • Method Details

    • create

      public <T> com.google.gson.TypeAdapter<T> create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> typeToken)
      Specified by:
      create in interface com.google.gson.TypeAdapterFactory
    • collectionElementType

      private static Type collectionElementType(Type type)
      Returns the element type of a Collection parameterized type. Handles wildcard upper bounds (e.g. Collection<? extends Foo>).
    • collectionSupplier

      private static Supplier<Collection<?>> collectionSupplier(Class<?> rawType)
      Returns a Supplier that creates a suitable mutable Collection instance for the given raw collection type.