Package com.google.common.primitives
Class Primitives
- java.lang.Object
-
- com.google.common.primitives.Primitives
-
@GwtIncompatible public final class Primitives extends Object
Contains static utility methods pertaining to primitive types and their corresponding wrapper types.- Since:
- 1.0
- Author:
- Kevin Bourrillion
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<Class<?>>allPrimitiveTypes()Returns an immutable set of all nine primitive types (includingvoid).static Set<Class<?>>allWrapperTypes()Returns an immutable set of all nine primitive-wrapper types (includingVoid).static booleanisWrapperType(Class<?> type)static <T> Class<T>unwrap(Class<T> type)Returns the corresponding primitive type oftypeif it is a wrapper type; otherwise returnstypeitself.static <T> Class<T>wrap(Class<T> type)Returns the corresponding wrapper type oftypeif it is a primitive type; otherwise returnstypeitself.
-
-
-
Method Detail
-
allPrimitiveTypes
public static Set<Class<?>> allPrimitiveTypes()
Returns an immutable set of all nine primitive types (includingvoid). Note that a simpler way to test whether aClassinstance is a member of this set is to callClass.isPrimitive().- Since:
- 3.0
-
allWrapperTypes
public static Set<Class<?>> allWrapperTypes()
Returns an immutable set of all nine primitive-wrapper types (includingVoid).- Since:
- 3.0
-
isWrapperType
public static boolean isWrapperType(Class<?> type)
- See Also:
Class.isPrimitive()
-
wrap
public static <T> Class<T> wrap(Class<T> type)
Returns the corresponding wrapper type oftypeif it is a primitive type; otherwise returnstypeitself. Idempotent.wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class
-
-