public class Util
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONTENT_ENCODING
The HTTP Content-Encoding header field name.
|
static java.lang.String |
CONTENT_LENGTH
The HTTP Content-Length header field name.
|
static java.lang.String |
ENCODING_DEFLATE
Value for the Content-Encoding header that indicates that DEFLATE encoding is in use.
|
static java.lang.String |
ENCODING_GZIP
Value for the Content-Encoding header that indicates that GZIP encoding is in use.
|
static java.nio.charset.Charset |
ISO_8859_1
ISO-8859-1: ISO Latin Alphabet Number 1 (ISO-LATIN-1).
|
static java.lang.String |
RETRY_AFTER
The HTTP Retry-After header field name.
|
static java.nio.charset.Charset |
UTF_8
UTF-8: eight-bit UCS Transformation Format.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Copy of
com.google.common.base.Preconditions#checkArgument. |
static <T> T |
checkNotNull(T reference,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Copy of
com.google.common.base.Preconditions#checkNotNull. |
static void |
checkState(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
Copy of
com.google.common.base.Preconditions#checkState. |
static java.lang.String |
emptyToNull(java.lang.String string)
Adapted from
com.google.common.base.Strings#emptyToNull. |
static java.lang.Object |
emptyValueOf(java.lang.reflect.Type type)
This returns well known empty values for well-known java types.
|
static void |
ensureClosed(java.io.Closeable closeable) |
static java.lang.reflect.Type |
resolveLastTypeParameter(java.lang.reflect.Type genericContext,
java.lang.Class<?> supertype)
Resolves the last type parameter of the parameterized
supertype, based on the genericContext, into its upper bounds. |
static <T> T[] |
toArray(java.lang.Iterable<? extends T> iterable,
java.lang.Class<T> type)
Adapted from
com.google.common.base.Strings#emptyToNull. |
static byte[] |
toByteArray(java.io.InputStream in)
Adapted from
com.google.common.io.ByteStreams.toByteArray(). |
static java.lang.String |
toString(java.io.Reader reader)
Adapted from
com.google.common.io.CharStreams.toString(). |
static <T> java.util.Collection<T> |
valuesOrEmpty(java.util.Map<java.lang.String,java.util.Collection<T>> map,
java.lang.String key)
Returns an unmodifiable collection which may be empty, but is never null.
|
public static final java.lang.String CONTENT_LENGTH
public static final java.lang.String CONTENT_ENCODING
public static final java.lang.String RETRY_AFTER
public static final java.lang.String ENCODING_GZIP
public static final java.lang.String ENCODING_DEFLATE
public static final java.nio.charset.Charset UTF_8
public static final java.nio.charset.Charset ISO_8859_1
public static void checkArgument(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
com.google.common.base.Preconditions#checkArgument.public static <T> T checkNotNull(T reference,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
com.google.common.base.Preconditions#checkNotNull.public static void checkState(boolean expression,
java.lang.String errorMessageTemplate,
java.lang.Object... errorMessageArgs)
com.google.common.base.Preconditions#checkState.public static java.lang.String emptyToNull(java.lang.String string)
com.google.common.base.Strings#emptyToNull.public static <T> T[] toArray(java.lang.Iterable<? extends T> iterable,
java.lang.Class<T> type)
com.google.common.base.Strings#emptyToNull.public static <T> java.util.Collection<T> valuesOrEmpty(java.util.Map<java.lang.String,java.util.Collection<T>> map,
java.lang.String key)
public static void ensureClosed(java.io.Closeable closeable)
public static java.lang.reflect.Type resolveLastTypeParameter(java.lang.reflect.Type genericContext,
java.lang.Class<?> supertype)
throws java.lang.IllegalStateException
supertype, based on the genericContext, into its upper bounds. Implementation copied from retrofit.RestMethodInfo.genericContext - Ex. Field.getGenericType()supertype - Ex. Decoder.classDecoder.java.lang.IllegalStateException - if supertype cannot be resolved into a parameterized type
using context.public static java.lang.Object emptyValueOf(java.lang.reflect.Type type)
[Bb]ooleanbyte[]CollectionIteratorListMapSetdecoding HTTP 404 status, you'll need to teach
decoders a default empty value for a type. This method cheaply supports typical types by only
looking at the raw type (vs type hierarchy). Decorate for sophistication.public static java.lang.String toString(java.io.Reader reader)
throws java.io.IOException
com.google.common.io.CharStreams.toString().java.io.IOExceptionpublic static byte[] toByteArray(java.io.InputStream in)
throws java.io.IOException
com.google.common.io.ByteStreams.toByteArray().java.io.IOException