public class Generics
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Generics.GenericsHierarchy
Stores the type parameters for a class and, for parameters passed to super classes, the corresponding super class type
parameters.
|
static class |
Generics.GenericType
Stores a type and its type parameters, recursively.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Class |
nextGenericClass()
Resolves the first type parameter and returns the class, or null if it could not be resolved or there are no type
parameters.
|
Generics.GenericType[] |
nextGenericTypes()
Returns the current type parameters and
pushes the next level of type parameters for
subsquent calls. |
void |
popGenericType()
Removes the generic types being tracked since the corresponding
pushGenericType(GenericType) . |
void |
popTypeVariables(int count)
Removes the number of entries that were pushed by
pushTypeVariables(GenericsHierarchy, GenericType[]) . |
void |
pushGenericType(Generics.GenericType fieldType)
Sets the type that is currently being serialized.
|
int |
pushTypeVariables(Generics.GenericsHierarchy hierarchy,
Generics.GenericType[] args)
Stores the types of the type parameters for the specified class hierarchy.
|
java.lang.Class |
resolveTypeVariable(java.lang.reflect.TypeVariable typeVariable)
Returns the class for the specified type variable, or null if it is not known.
|
java.lang.String |
toString() |
public Generics(Kryo kryo)
public void pushGenericType(Generics.GenericType fieldType)
popGenericType()
. Between those calls, the
type parameters
are returned by nextGenericTypes()
and
nextGenericClass()
.public void popGenericType()
pushGenericType(GenericType)
. This is safe to call
even if pushGenericType(GenericType)
was not called.public Generics.GenericType[] nextGenericTypes()
pushes
the next level of type parameters for
subsquent calls. Must be balanced by popGenericType()
(optional if null is returned). If multiple type parameters
are returned, the last is used to advance to the next level of type parameters.
nextGenericClass()
is easier to use when a class has a single type parameter. When a class has multiple type
parameters, pushGenericType(GenericType)
must be used for all except the last parameter.
public java.lang.Class nextGenericClass()
nextGenericTypes()
, so must be balanced by popGenericType()
(optional if null is
returned).
This method is intended for ease of use when a class has a single type parameter.
public int pushTypeVariables(Generics.GenericsHierarchy hierarchy, Generics.GenericType[] args)
popTypeVariables(int)
if >0 is returned.args
- May contain null for type arguments that aren't known.public void popTypeVariables(int count)
pushTypeVariables(GenericsHierarchy, GenericType[])
.count
- Must be even.public java.lang.Class resolveTypeVariable(java.lang.reflect.TypeVariable typeVariable)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2019. All Rights Reserved.