Package com.esotericsoftware.kryo.util
Class Util
- java.lang.Object
-
- com.esotericsoftware.kryo.util.Util
-
public class Util extends java.lang.ObjectA few utility methods, mostly for private use.- Author:
- Nathan Sweet
-
-
Field Summary
Fields Modifier and Type Field Description static booleanisAndroidstatic intmaxArraySizestatic booleanunsafeTrue if Unsafe is available.
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringclassName(java.lang.Class type)Returns the class formatted as a string.static java.lang.StringclassNames(java.lang.Class[] types)Returns the classes formatted as a string.static intgetDimensionCount(java.lang.Class arrayClass)Returns the number of dimensions of an array.static java.lang.ClassgetElementClass(java.lang.Class arrayClass)Returns the base element type of an n-dimensional array class.static java.lang.ClassgetPrimitiveClass(java.lang.Class type)Returns the primitive class for a primitive wrapper class.static java.lang.ClassgetWrapperClass(java.lang.Class type)Returns the primitive wrapper class for a primitive class, or the specified class if it is not primitive.static booleanisAscii(java.lang.String value)static booleanisAssignableTo(java.lang.Class<?> from, java.lang.Class<?> to)static booleanisClassAvailable(java.lang.String className)static booleanisEnum(java.lang.Class type)static booleanisWrapperClass(java.lang.Class type)static voidlog(java.lang.String message, java.lang.Object object, int position)Logs a message about an object.static <T extends SerializerFactory>
TnewFactory(java.lang.Class<T> factoryClass, java.lang.Class<? extends Serializer> serializerClass)static java.lang.Stringpos(int position)static java.lang.StringsimpleName(java.lang.Class type, Generics.GenericType genericType)static java.lang.StringsimpleName(java.lang.reflect.Type type)static java.lang.Stringstring(java.lang.Object object)Returns the object formatted as a string.
-
-
-
Field Detail
-
isAndroid
public static final boolean isAndroid
-
unsafe
public static final boolean unsafe
True if Unsafe is available. Unsafe can be disabled by setting the system property "kryo.unsafe" to "false".
-
maxArraySize
public static final int maxArraySize
- See Also:
- Constant Field Values
-
-
Method Detail
-
isClassAvailable
public static boolean isClassAvailable(java.lang.String className)
-
getWrapperClass
public static java.lang.Class getWrapperClass(java.lang.Class type)
Returns the primitive wrapper class for a primitive class, or the specified class if it is not primitive.
-
getPrimitiveClass
public static java.lang.Class getPrimitiveClass(java.lang.Class type)
Returns the primitive class for a primitive wrapper class. Otherwise returns the type parameter.- Parameters:
type- Must be a wrapper class.
-
isWrapperClass
public static boolean isWrapperClass(java.lang.Class type)
-
isEnum
public static boolean isEnum(java.lang.Class type)
-
log
public static void log(java.lang.String message, java.lang.Object object, int position)Logs a message about an object. The log level and the string format of the object depend on the object type.
-
pos
public static java.lang.String pos(int position)
-
string
public static java.lang.String string(java.lang.Object object)
Returns the object formatted as a string. The format depends on the object's type and whetherObject.toString()has been overridden.
-
className
public static java.lang.String className(java.lang.Class type)
Returns the class formatted as a string. The format varies depending on the type.
-
classNames
public static java.lang.String classNames(java.lang.Class[] types)
Returns the classes formatted as a string. The format varies depending on the type.
-
simpleName
public static java.lang.String simpleName(java.lang.reflect.Type type)
-
simpleName
public static java.lang.String simpleName(java.lang.Class type, Generics.GenericType genericType)
-
getDimensionCount
public static int getDimensionCount(java.lang.Class arrayClass)
Returns the number of dimensions of an array.
-
getElementClass
public static java.lang.Class getElementClass(java.lang.Class arrayClass)
Returns the base element type of an n-dimensional array class.
-
isAssignableTo
public static boolean isAssignableTo(java.lang.Class<?> from, java.lang.Class<?> to)
-
isAscii
public static boolean isAscii(java.lang.String value)
-
newFactory
public static <T extends SerializerFactory> T newFactory(java.lang.Class<T> factoryClass, java.lang.Class<? extends Serializer> serializerClass)
- Parameters:
factoryClass- Must have a constructor that takes a serializer class, or a zero argument constructor.serializerClass- May be null if the factory already knows the serializer class to create.
-
-