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 Summary
Static MethodsModifier and TypeMethodDescriptionstatic TypeSetfixedTypeSet(boolean autobox, Class<?>... types) Returns aTypeSetthat is internally backed by afixedTypeMap(),static TypeSetfixedTypeSet(boolean autobox, Collection<Class<?>> types) Returns aTypeSetthat is internally backed by afixedTypeMap(),static TypeSetfixedTypeSet(Class<?>... types) Returns aTypeSetthat is internally backed by afixedTypeMap(),static TypeSetfixedTypeSet(Collection<Class<?>> types) Returns aTypeSetthat is internally backed by afixedTypeMap(),static TypeSetgreedyTypeSet(boolean autobox, Class<?>... types) Returns aTypeSetthat is internally backed by agreedyTypeMap().static TypeSetgreedyTypeSet(boolean autobox, Collection<Class<?>> types) Returns aTypeSetthat is internally backed by agreedyTypeMap().static TypeSetgreedyTypeSet(Class<?>... types) Returns aTypeSetthat is internally backed by agreedyTypeMap().static TypeSetgreedyTypeSet(Collection<Class<?>> types) Returns aTypeSetthat is internally backed by agreedyTypeMap().static TypeSetnativeTypeSet(boolean autobox, Class<?>... types) Returns aTypeSetthat is internally backed by anativeTypeMap().static TypeSetnativeTypeSet(boolean autobox, Collection<Class<?>> types) Returns aTypeSetthat is internally backed by anativeTypeMap().static TypeSetnativeTypeSet(Class<?>... types) Returns aTypeSetthat is internally backed by anativeTypeMap().static TypeSetnativeTypeSet(Collection<Class<?>> types) Returns aTypeSetthat is internally backed by anativeTypeMap().prettySort(Collection<Class<?>> src) Returns an unmodifiableSetin which the types in the provided collection are sorted according to their distance fromObject.class.static TypeSettreeTypeSet(boolean autobox, Class<?>... types) Returns aTypeSetthat is internally backed by atreeTypeMap().static TypeSettreeTypeSet(boolean autobox, Collection<Class<?>> types) Returns aTypeSetthat is internally backed by atreeTypeMap().static TypeSettreeTypeSet(Class<?>... types) Returns aTypeSetthat is internally backed by atreeTypeMap().static TypeSettreeTypeSet(Collection<Class<?>> types) Returns aTypeSetthat is internally backed by atreeTypeMap().Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
fixedTypeSet
Returns aTypeSetthat is internally backed by afixedTypeMap(),- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by afixedTypeMap()
-
fixedTypeSet
Returns aTypeSetthat is internally backed by afixedTypeMap(),- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by afixedTypeMap()
-
fixedTypeSet
Returns aTypeSetthat is internally backed by afixedTypeMap(),- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by afixedTypeMap()
-
fixedTypeSet
Returns aTypeSetthat is internally backed by afixedTypeMap(),- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by afixedTypeMap()
-
nativeTypeSet
Returns aTypeSetthat is internally backed by anativeTypeMap().- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by anativeTypeMap()
-
nativeTypeSet
Returns aTypeSetthat is internally backed by anativeTypeMap().- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by anativeTypeMap()
-
nativeTypeSet
Returns aTypeSetthat is internally backed by anativeTypeMap().- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by anativeTypeMap()
-
nativeTypeSet
Returns aTypeSetthat is internally backed by anativeTypeMap().- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by anativeTypeMap()
-
greedyTypeSet
Returns aTypeSetthat is internally backed by agreedyTypeMap().- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by agreedyTypeMap()
-
greedyTypeSet
Returns aTypeSetthat is internally backed by agreedyTypeMap().- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by agreedyTypeMap()
-
greedyTypeSet
Returns aTypeSetthat is internally backed by agreedyTypeMap().- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by agreedyTypeMap()
-
greedyTypeSet
Returns aTypeSetthat is internally backed by agreedyTypeMap().- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by agreedyTypeMap()
-
treeTypeSet
Returns aTypeSetthat is internally backed by atreeTypeMap().- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by atreeTypeMap().
-
treeTypeSet
Returns aTypeSetthat is internally backed by atreeTypeMap().- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by atreeTypeMap().
-
treeTypeSet
Returns aTypeSetthat is internally backed by atreeTypeMap().- Parameters:
types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by atreeTypeMap().
-
treeTypeSet
Returns aTypeSetthat is internally backed by atreeTypeMap().- Parameters:
autobox- whether to enable "autoboxing"types- the types to initialize theTypeSetwith- Returns:
- a
TypeSetthat is internally backed by atreeTypeMap().
-
prettySort
Returns an unmodifiable
Setin which the types in the provided collection are sorted according to their distance fromObject.class. Note that this is a utility method, mainly meant for printing purposes. The returned set is not an instance ofTypeSet. Itscontainsmethod performs poorly, but it can be iterated over quickly. TheComparatorused to sort the types is similar to the one used fortreeTypeSet, but much more heavy-handed (hence slow and impractical), 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.classitself) - 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
Setin which the types are sorted according to their heir distance fromObject.class.
-