public final class APIUtil
extends java.lang.Object
Method names in this class are prefixed with api
to avoid ambiguities
when used with static imports.
Modifier and Type | Class and Description |
---|---|
static class |
APIUtil.APIVersion
A data class for API versioning information.
|
static interface |
APIUtil.TokenFilter
Simple interface for Field filtering.
|
Modifier and Type | Method and Description |
---|---|
static APIBuffer |
apiBuffer()
Returns a thread-local
APIBuffer that has been reset. |
static java.util.Map<java.lang.Integer,java.lang.String> |
apiClassTokens(APIUtil.TokenFilter filter,
java.util.Map<java.lang.Integer,java.lang.String> target,
java.lang.Class<?>... tokenClasses)
Returns a map of public static final integer fields in the specified
classes, to their String representations.
|
static java.lang.Class<?> |
apiOptionalClass(java.lang.String className) |
static APIUtil.APIVersion |
apiParseVersion(java.lang.String version)
Parses a version string.
|
static APIUtil.APIVersion |
apiParseVersion(java.lang.String version,
java.lang.String prefix)
Parses a version string.
|
static APIBuffer |
apiStack()
Returns a thread-local
APIBuffer , without resetting it. |
static java.lang.String |
apiUnknownToken(int token) |
static java.lang.String |
apiUnknownToken(java.lang.String description,
int token) |
static <T> T[] |
toArray(T... arguments)
Converts dynamic arguments to object array.
|
@SafeVarargs public static <T> T[] toArray(T... arguments)
arguments
- the list of arguments.public static APIBuffer apiStack()
APIBuffer
, without resetting it. This
makes the APIBuffer work like a stack when used in nested API calls. The
user is responsible for resetting the APIBuffer
to an appropriate
state before the nested call returns.APIBuffer.pop()
public static APIUtil.APIVersion apiParseVersion(java.lang.String version)
MAJOR.MINOR.REVISION IMPL
, where MAJOR
is the major
version (integer), MINOR
is the minor version (integer),
REVISION
is the revision version (string, optional) and
IMPL
is implementation-specific information (string, optional).version
- the API version stringAPIUtil.APIVersion
public static APIUtil.APIVersion apiParseVersion(java.lang.String version, java.lang.String prefix)
PREFIX MAJOR.MINOR.REVISION IMPL
, where PREFIX
is the
specified prefix (string, optional), MAJOR
is the major version
(integer), MINOR
is the minor version (integer), REVISION
is the revision version (string, optional) and IMPL
is
implementation-specific information (string, optional).version
- the version stringprefix
- the version string prefix, may be nullAPIUtil.APIVersion
public static java.lang.String apiUnknownToken(int token)
public static java.lang.String apiUnknownToken(java.lang.String description, int token)
public static java.util.Map<java.lang.Integer,java.lang.String> apiClassTokens(APIUtil.TokenFilter filter, java.util.Map<java.lang.Integer,java.lang.String> target, java.lang.Class<?>... tokenClasses)
This method is useful when debugging to quickly identify values returned from an API.
filter
- the filter to use (optional)target
- the target map (optional)tokenClasses
- the classes to get tokens frompublic static java.lang.Class<?> apiOptionalClass(java.lang.String className)