feign
Class Util

java.lang.Object
  extended by feign.Util

public class Util
extends java.lang.Object

Utilities, typically copied in from guava, so as to avoid dependency conflicts.


Field Summary
static java.lang.String CONTENT_LENGTH
          The HTTP Content-Length header field name.
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.
 
Method Summary
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 void ensureClosed(Response.Body body)
           
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
<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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_LENGTH

public static final java.lang.String CONTENT_LENGTH
The HTTP Content-Length header field name.

See Also:
Constant Field Values

RETRY_AFTER

public static final java.lang.String RETRY_AFTER
The HTTP Retry-After header field name.

See Also:
Constant Field Values

UTF_8

public static final java.nio.charset.Charset UTF_8
UTF-8: eight-bit UCS Transformation Format.

Method Detail

checkArgument

public static void checkArgument(boolean expression,
                                 java.lang.String errorMessageTemplate,
                                 java.lang.Object... errorMessageArgs)
Copy of com.google.common.base.Preconditions#checkArgument.


checkNotNull

public static <T> T checkNotNull(T reference,
                                 java.lang.String errorMessageTemplate,
                                 java.lang.Object... errorMessageArgs)
Copy of com.google.common.base.Preconditions#checkNotNull.


checkState

public static void checkState(boolean expression,
                              java.lang.String errorMessageTemplate,
                              java.lang.Object... errorMessageArgs)
Copy of com.google.common.base.Preconditions#checkState.


emptyToNull

public static java.lang.String emptyToNull(java.lang.String string)
Adapted from com.google.common.base.Strings#emptyToNull.


toArray

public static <T> T[] toArray(java.lang.Iterable<? extends T> iterable,
                              java.lang.Class<T> type)
Adapted from com.google.common.base.Strings#emptyToNull.


valuesOrEmpty

public 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.


ensureClosed

public static void ensureClosed(Response.Body body)

resolveLastTypeParameter

public static java.lang.reflect.Type resolveLastTypeParameter(java.lang.reflect.Type genericContext,
                                                              java.lang.Class<?> supertype)
                                                       throws java.lang.IllegalStateException
Resolves the last type parameter of the parameterized supertype, based on the genericContext, into its upper bounds.

Implementation copied from retrofit.RestMethodInfo.

Parameters:
genericContext - Ex. Field.getGenericType()
supertype - Ex. Decoder.class
Returns:
in the example above, the type parameter of Decoder.
Throws:
java.lang.IllegalStateException - if supertype cannot be resolved into a parameterized type using context.