public class Util extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CONTENT_ENCODING
The HTTP Content-Encoding header field name.
|
static String |
CONTENT_LENGTH
The HTTP Content-Length header field name.
|
static String |
ENCODING_DEFLATE
Value for the Content-Encoding header that indicates that DEFLATE encoding is in use.
|
static String |
ENCODING_GZIP
Value for the Content-Encoding header that indicates that GZIP encoding is in use.
|
static Charset |
ISO_8859_1
ISO-8859-1: ISO Latin Alphabet Number 1 (ISO-LATIN-1).
|
static Type |
MAP_STRING_WILDCARD
Type literal for
Map<String, ?> . |
static String |
RETRY_AFTER
The HTTP Retry-After header field name.
|
static Charset |
UTF_8
UTF-8: eight-bit UCS Transformation Format.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkArgument(boolean expression,
String errorMessageTemplate,
Object... errorMessageArgs)
Copy of
com.google.common.base.Preconditions#checkArgument . |
static <T> T |
checkNotNull(T reference,
String errorMessageTemplate,
Object... errorMessageArgs)
Copy of
com.google.common.base.Preconditions#checkNotNull . |
static void |
checkState(boolean expression,
String errorMessageTemplate,
Object... errorMessageArgs)
Copy of
com.google.common.base.Preconditions#checkState . |
static String |
decodeOrDefault(byte[] data,
Charset charset,
String defaultValue) |
static String |
emptyToNull(String string)
Adapted from
com.google.common.base.Strings#emptyToNull . |
static Object |
emptyValueOf(Type type)
This returns well known empty values for well-known java types.
|
static void |
ensureClosed(Closeable closeable) |
static boolean |
isBlank(String value)
If the provided String is null or empty.
|
static boolean |
isDefault(Method method)
Identifies a method as a default instance method.
|
static boolean |
isNotBlank(String value)
If the provided String is not null or empty.
|
static <T> T[] |
removeValues(T[] values,
Predicate<T> shouldRemove,
Class<T> type)
Removes values from the array that meet the criteria for removal via the supplied
Predicate value |
static Type |
resolveLastTypeParameter(Type genericContext,
Class<?> supertype)
Resolves the last type parameter of the parameterized
supertype , based on the genericContext , into its upper bounds. |
static <T> T[] |
toArray(Iterable<? extends T> iterable,
Class<T> type)
Adapted from
com.google.common.base.Strings#emptyToNull . |
static byte[] |
toByteArray(InputStream in)
Adapted from
com.google.common.io.ByteStreams.toByteArray() . |
static String |
toString(Reader reader)
Adapted from
com.google.common.io.CharStreams.toString() . |
static <T> Collection<T> |
valuesOrEmpty(Map<String,Collection<T>> map,
String key)
Returns an unmodifiable collection which may be empty, but is never null.
|
public static final String CONTENT_LENGTH
public static final String CONTENT_ENCODING
public static final String RETRY_AFTER
public static final String ENCODING_GZIP
public static final String ENCODING_DEFLATE
public static final Charset UTF_8
public static final Charset ISO_8859_1
public static final Type MAP_STRING_WILDCARD
Map<String, ?>
.public static void checkArgument(boolean expression, String errorMessageTemplate, Object... errorMessageArgs)
com.google.common.base.Preconditions#checkArgument
.public static <T> T checkNotNull(T reference, String errorMessageTemplate, Object... errorMessageArgs)
com.google.common.base.Preconditions#checkNotNull
.public static void checkState(boolean expression, String errorMessageTemplate, Object... errorMessageArgs)
com.google.common.base.Preconditions#checkState
.public static boolean isDefault(Method method)
public static String emptyToNull(String string)
com.google.common.base.Strings#emptyToNull
.public static <T> T[] removeValues(T[] values, Predicate<T> shouldRemove, Class<T> type)
Predicate
valuepublic static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type)
com.google.common.base.Strings#emptyToNull
.public static <T> Collection<T> valuesOrEmpty(Map<String,Collection<T>> map, String key)
public static void ensureClosed(Closeable closeable)
public static Type resolveLastTypeParameter(Type genericContext, Class<?> supertype) throws IllegalStateException
supertype
, based on the genericContext
, into its upper bounds.
Implementation copied from retrofit.RestMethodInfo
.genericContext
- Ex. Field.getGenericType()
supertype
- Ex. Decoder.class
Decoder
.IllegalStateException
- if supertype
cannot be resolved into a parameterized type
using context
.public static Object emptyValueOf(Type type)
[Bb]oolean
byte[]
Collection
Iterator
List
Map
Set
decoding 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 String toString(Reader reader) throws IOException
com.google.common.io.CharStreams.toString()
.IOException
public static byte[] toByteArray(InputStream in) throws IOException
com.google.common.io.ByteStreams.toByteArray()
.IOException
public static String decodeOrDefault(byte[] data, Charset charset, String defaultValue)
public static boolean isNotBlank(String value)
value
- to evaluate.public static boolean isBlank(String value)
value
- to evaluate.Copyright © 2012–2020 OpenFeign. All rights reserved.