Package com.esotericsoftware.kryo.util
Interface Generics
-
- All Known Implementing Classes:
DefaultGenerics
,NoGenerics
public interface Generics
Handles storage of generic type information
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface 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.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Generics.GenericsHierarchy
buildHierarchy(Class type)
Builds aGenerics.GenericsHierarchy
for the specified type.int
getGenericTypesSize()
Returns the number of generic types currently trackedClass
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 andpushes
the next level of type parameters for subsequent calls.void
popGenericType()
Removes the generic types being tracked since the correspondingpushGenericType(GenericType)
.void
popTypeVariables(int count)
Removes the number of entries that were pushed bypushTypeVariables(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.Class
resolveTypeVariable(TypeVariable typeVariable)
Returns the class for the specified type variable, or null if it is not known.
-
-
-
Method Detail
-
buildHierarchy
Generics.GenericsHierarchy buildHierarchy(Class type)
Builds aGenerics.GenericsHierarchy
for the specified type.
-
pushGenericType
void pushGenericType(Generics.GenericType fieldType)
Sets the type that is currently being serialized. Must be balanced bypopGenericType()
. Between those calls, thetype parameters
are returned bynextGenericTypes()
andnextGenericClass()
.
-
popGenericType
void popGenericType()
Removes the generic types being tracked since the correspondingpushGenericType(GenericType)
. This is safe to call even ifpushGenericType(GenericType)
was not called.
-
nextGenericTypes
Generics.GenericType[] nextGenericTypes()
Returns the current type parameters andpushes
the next level of type parameters for subsequent calls. Must be balanced bypopGenericType()
(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.- Returns:
- May be null.
-
nextGenericClass
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. UsesnextGenericTypes()
, so must be balanced bypopGenericType()
(optional if null is returned).This method is intended for ease of use when a class has a single type parameter.
- Returns:
- May be null.
-
pushTypeVariables
int pushTypeVariables(Generics.GenericsHierarchy hierarchy, Generics.GenericType[] args)
Stores the types of the type parameters for the specified class hierarchy. Must be balanced bypopTypeVariables(int)
if >0 is returned.- Parameters:
args
- May contain null for type arguments that aren't known.- Returns:
- The number of entries that were pushed.
-
popTypeVariables
void popTypeVariables(int count)
Removes the number of entries that were pushed bypushTypeVariables(GenericsHierarchy, GenericType[])
.- Parameters:
count
- Must be even.
-
resolveTypeVariable
Class resolveTypeVariable(TypeVariable typeVariable)
Returns the class for the specified type variable, or null if it is not known.- Returns:
- May be null.
-
getGenericTypesSize
int getGenericTypesSize()
Returns the number of generic types currently tracked
-
-