public class Util extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPT_ENCODING
The HTTP Accept-Encoding header field name.
|
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 {@code Map |
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 List<Field> |
allFields(Class<?> clazz) |
static Map<String,Collection<String>> |
caseInsensitiveCopyOf(Map<String,Collection<String>> map)
Copy entire map of string collection.
|
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 <T extends Enum<?>> |
enumForName(Class<T> enumClass,
Object object) |
static String |
getThreadIdentifier() |
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)
Deprecated.
|
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 ACCEPT_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)
@Deprecated public static Type resolveLastTypeParameter(Type genericContext, Class<?> supertype) throws IllegalStateException
feign.Types.resolveLastTypeParameter
IllegalStateException
public static Object emptyValueOf(Type type)
[Bb]oolean
byte[]
Collection
Iterator
List
Map
Set
When 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.public static Map<String,Collection<String>> caseInsensitiveCopyOf(Map<String,Collection<String>> map)
The copy is unmodifiable map of unmodifiable collections.
map
- string collection mappublic static String getThreadIdentifier()
Copyright © 2012–2024 OpenFeign. All rights reserved.