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
Modifier and TypeMethodDescriptionstatic TypeSet
fixedTypeSet
(boolean autobox, Class<?>... types) Returns aTypeSet
that is internally backed by afixedTypeMap()
,static TypeSet
fixedTypeSet
(boolean autobox, Collection<Class<?>> types) Returns aTypeSet
that is internally backed by afixedTypeMap()
,static TypeSet
fixedTypeSet
(Class<?>... types) Returns aTypeSet
that is internally backed by afixedTypeMap()
,static TypeSet
fixedTypeSet
(Collection<Class<?>> types) Returns aTypeSet
that is internally backed by afixedTypeMap()
,static TypeSet
greedyTypeSet
(boolean autobox, Class<?>... types) Returns aTypeSet
that is internally backed by agreedyTypeMap()
.static TypeSet
greedyTypeSet
(boolean autobox, Collection<Class<?>> types) Returns aTypeSet
that is internally backed by agreedyTypeMap()
.static TypeSet
greedyTypeSet
(Class<?>... types) Returns aTypeSet
that is internally backed by agreedyTypeMap()
.static TypeSet
greedyTypeSet
(Collection<Class<?>> types) Returns aTypeSet
that is internally backed by agreedyTypeMap()
.static TypeSet
nativeTypeSet
(boolean autobox, Class<?>... types) Returns aTypeSet
that is internally backed by anativeTypeMap()
.static TypeSet
nativeTypeSet
(boolean autobox, Collection<Class<?>> types) Returns aTypeSet
that is internally backed by anativeTypeMap()
.static TypeSet
nativeTypeSet
(Class<?>... types) Returns aTypeSet
that is internally backed by anativeTypeMap()
.static TypeSet
nativeTypeSet
(Collection<Class<?>> types) Returns aTypeSet
that is internally backed by anativeTypeMap()
.prettySort
(Collection<Class<?>> src) Returns an unmodifiableSet
in which the types in the provided collection are sorted according to their distance fromObject.class
.static TypeSet
treeTypeSet
(boolean autobox, Class<?>... types) Returns aTypeSet
that is internally backed by atreeTypeMap()
.static TypeSet
treeTypeSet
(boolean autobox, Collection<Class<?>> types) Returns aTypeSet
that is internally backed by atreeTypeMap()
.static TypeSet
treeTypeSet
(Class<?>... types) Returns aTypeSet
that is internally backed by atreeTypeMap()
.static TypeSet
treeTypeSet
(Collection<Class<?>> types) Returns aTypeSet
that is internally backed by atreeTypeMap()
.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
fixedTypeSet
Returns aTypeSet
that is internally backed by afixedTypeMap()
,- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by afixedTypeMap()
-
fixedTypeSet
Returns aTypeSet
that is internally backed by afixedTypeMap()
,- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by afixedTypeMap()
-
fixedTypeSet
Returns aTypeSet
that is internally backed by afixedTypeMap()
,- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by afixedTypeMap()
-
fixedTypeSet
Returns aTypeSet
that is internally backed by afixedTypeMap()
,- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by afixedTypeMap()
-
nativeTypeSet
Returns aTypeSet
that is internally backed by anativeTypeMap()
.- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by anativeTypeMap()
-
nativeTypeSet
Returns aTypeSet
that is internally backed by anativeTypeMap()
.- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by anativeTypeMap()
-
nativeTypeSet
Returns aTypeSet
that is internally backed by anativeTypeMap()
.- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by anativeTypeMap()
-
nativeTypeSet
Returns aTypeSet
that is internally backed by anativeTypeMap()
.- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by anativeTypeMap()
-
greedyTypeSet
Returns aTypeSet
that is internally backed by agreedyTypeMap()
.- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by agreedyTypeMap()
-
greedyTypeSet
Returns aTypeSet
that is internally backed by agreedyTypeMap()
.- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by agreedyTypeMap()
-
greedyTypeSet
Returns aTypeSet
that is internally backed by agreedyTypeMap()
.- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by agreedyTypeMap()
-
greedyTypeSet
Returns aTypeSet
that is internally backed by agreedyTypeMap()
.- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by agreedyTypeMap()
-
treeTypeSet
Returns aTypeSet
that is internally backed by atreeTypeMap()
.- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by atreeTypeMap()
.
-
treeTypeSet
Returns aTypeSet
that is internally backed by atreeTypeMap()
.- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by atreeTypeMap()
.
-
treeTypeSet
Returns aTypeSet
that is internally backed by atreeTypeMap()
.- Parameters:
types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by atreeTypeMap()
.
-
treeTypeSet
Returns aTypeSet
that is internally backed by atreeTypeMap()
.- Parameters:
autobox
- whether to enable "autoboxing"types
- the types to initialize theTypeSet
with- Returns:
- a
TypeSet
that is internally backed by atreeTypeMap()
.
-
prettySort
Returns an unmodifiable
Set
in 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
. Itscontains
method performs poorly, but it can be iterated over quickly. TheComparator
used to sort the types is similar to the one used fortreeTypeSet
, 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 fromObject.class
.
-