Package com.google.common.primitives
Class Primitives
-
- com.google.common.primitives.Primitives
-
@GwtIncompatible public final class Primitives extends
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 <<?>>
allPrimitiveTypes()
Returns an immutable set of all nine primitive types (includingvoid
).static <<?>>
allWrapperTypes()
Returns an immutable set of all nine primitive-wrapper types (including ).static boolean
<?> type)
Returnstrue
iftype
is one of the nine primitive-wrapper types, such as .static <T> <T>
<T> type)
Returns the corresponding primitive type oftype
if it is a wrapper type; otherwise returnstype
itself.static <T> <T>
<T> type)
Returns the corresponding wrapper type oftype
if it is a primitive type; otherwise returnstype
itself.
-
-
-
Method Detail
-
allPrimitiveTypes
public static <<?>> allPrimitiveTypes()
Returns an immutable set of all nine primitive types (includingvoid
). Note that a simpler way to test whether aClass
instance is a member of this set is to call .- Since:
- 3.0
-
allWrapperTypes
public static <<?>> allWrapperTypes()
Returns an immutable set of all nine primitive-wrapper types (including ).- Since:
- 3.0
-
isWrapperType
public static boolean <?> type)
Returnstrue
iftype
is one of the nine primitive-wrapper types, such as .- See Also:
-
wrap
public static <T> <T> <T> type)
Returns the corresponding wrapper type oftype
if it is a primitive type; otherwise returnstype
itself. Idempotent.wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class
-
unwrap
public static <T> <T> <T> type)
Returns the corresponding primitive type oftype
if it is a wrapper type; otherwise returnstype
itself. Idempotent.unwrap(Integer.class) == int.class unwrap(int.class) == int.class unwrap(String.class) == String.class
-
-