Interface TypeSet

All Superinterfaces:
Collection<Class<?>>, Iterable<Class<?>>, Set<Class<?>>

public sealed interface TypeSet extends Set<Class<?>>

An extension of the Set interface with behaviour analogous to the TypeMap interface. That is, if the type passed to the contains() method is not present in the Set, but one of its supertypes is, then contains() will return true. a TypeSet is unmodifiable and null-repellent. You obtain an instance of a TypeSet via the various static factory methods on the TypeSet interface. For more information about features like autoboxing and auto-expansion, please read the documentation for the TypeMap interface.

  • Method Details

    • fixedTypeSet

      static TypeSet fixedTypeSet(Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a fixedTypeMap(),
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a fixedTypeMap()
    • fixedTypeSet

      static TypeSet fixedTypeSet(boolean autobox, Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a fixedTypeMap(),
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a fixedTypeMap()
    • fixedTypeSet

      static TypeSet fixedTypeSet(Class<?>... types)
      Returns a TypeSet that is internally backed by a fixedTypeMap(),
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a fixedTypeMap()
    • fixedTypeSet

      static TypeSet fixedTypeSet(boolean autobox, Class<?>... types)
      Returns a TypeSet that is internally backed by a fixedTypeMap(),
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a fixedTypeMap()
    • nativeTypeSet

      static TypeSet nativeTypeSet(Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a nativeTypeMap().
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a nativeTypeMap()
    • nativeTypeSet

      static TypeSet nativeTypeSet(boolean autobox, Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a nativeTypeMap().
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a nativeTypeMap()
    • nativeTypeSet

      static TypeSet nativeTypeSet(Class<?>... types)
      Returns a TypeSet that is internally backed by a nativeTypeMap().
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a nativeTypeMap()
    • nativeTypeSet

      static TypeSet nativeTypeSet(boolean autobox, Class<?>... types)
      Returns a TypeSet that is internally backed by a nativeTypeMap().
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a nativeTypeMap()
    • greedyTypeSet

      static TypeSet greedyTypeSet(Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a greedyTypeMap().
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a greedyTypeMap()
    • greedyTypeSet

      static TypeSet greedyTypeSet(boolean autobox, Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a greedyTypeMap().
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a greedyTypeMap()
    • greedyTypeSet

      static TypeSet greedyTypeSet(Class<?>... types)
      Returns a TypeSet that is internally backed by a greedyTypeMap().
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a greedyTypeMap()
    • greedyTypeSet

      static TypeSet greedyTypeSet(boolean autobox, Class<?>... types)
      Returns a TypeSet that is internally backed by a greedyTypeMap().
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a greedyTypeMap()
    • treeTypeSet

      static TypeSet treeTypeSet(Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a treeTypeMap().
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a treeTypeMap().
    • treeTypeSet

      static TypeSet treeTypeSet(boolean autobox, Collection<Class<?>> types)
      Returns a TypeSet that is internally backed by a treeTypeMap().
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a treeTypeMap().
    • treeTypeSet

      static TypeSet treeTypeSet(Class<?>... types)
      Returns a TypeSet that is internally backed by a treeTypeMap().
      Parameters:
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a treeTypeMap().
    • treeTypeSet

      static TypeSet treeTypeSet(boolean autobox, Class<?>... types)
      Returns a TypeSet that is internally backed by a treeTypeMap().
      Parameters:
      autobox - whether to enable "autoboxing"
      types - the types to initialize the TypeSet with
      Returns:
      a TypeSet that is internally backed by a treeTypeMap().
    • prettySort

      static Set<Class<?>> prettySort(Collection<Class<?>> src)

      Returns an unmodifiable Set in which the types in the provided collection are sorted according to their distance from Object.class. Note that this is a utility method, mainly meant for printing purposes. The returned set is not an instance of TypeSet. Its contains method performs poorly, but it can be iterated over quickly. The Comparator used to sort the types is similar to the one used for treeTypeSet, but much more heavy-handed, applying a fully-deterministic ordering of the types in the provided collection.

      This is how the types in the returned set will be sorted:

      • primitive types
      • primitive wrapper types
      • enums (excluding Enum.class itself)
      • other non-array types, according to their distance from Object .class
      • array types (recursively according to component type)
      • interfaces according to the number of other interfaces they extend
      • Object.class
      • by inverse fully-qualified class name (e.g. OutputStream.io.java)
      Parameters:
      src - the collection to sort
      Returns:
      an unmodifiable Set in which the types are sorted according to their distance from Object.class.