@Override public List<Map.Entry<String, String>> headerEntries() { return internalHeadersImpl().entries(); }
@Override public Optional<String> header(String name) { return internalHeadersImpl().get(name); }
@Override protected StatusType featureValueOf(Response<T> item) { return item.status(); } };
@Override protected String featureValueOf(Request actual) { return actual.method(); } };
@Override protected String featureValueOf(Request actual) { return actual.uri(); } };
@Override protected StatusType.Family featureValueOf(StatusType item) { return item.family(); } };
private static <T> Response<T> ensureResponse(T t) { if (t instanceof Response) { //noinspection unchecked return (Response<T>) t; } else { return Response.forPayload(t); } } }
@Override public List<Map.Entry<String, String>> headerEntries() { return internalHeadersImpl().entries(); }
@Override public Optional<String> header(String name) { return internalHeadersImpl().get(name); }
@Override @Deprecated public Map<String, String> headers() { return internalHeadersImpl().asMap(); }
/** * Creates a {@link Response} with the given status code and a payload with type {@link T}. * * @param statusCode The status code * @param payload The payload to respond with * @param <T> The response payload type * @return A response object with the given status code and payload */ static <T> Response<T> of(StatusType statusCode, T payload) { return ResponseImpl.create(statusCode, payload); } }
/** * Creates a {@link Request} for the given uri and method. * * @param uri The requested uri * @param method The request method * @return A request with for the given uri and method. */ static Request forUri(String uri, String method) { return RequestValue.create(uri, method); }
/** * Interface for serializing and de-serializing entities to and from a {@link ByteString}. * * <p>A {@link Codec} can be used by a {@link EntityMiddleware} to do the actual entity * serialization. */ @Exploratory public interface Codec { <E> EncodedResponse write(E entity, Class<? extends E> cls, RequestContext ctx) throws IOException; <E> E read(ByteString data, Class<? extends E> cls, RequestContext ctx) throws IOException; }
private static <T> Response<T> createInternal(StatusType statusCode, Optional<T> payload) { return createInternal( statusCode, Headers.EMPTY, payload); }
private static <T> Response<T> createInternal( StatusType statusCode, Headers headers, Optional<T> payload) { return new AutoValue_ResponseImpl<>( statusCode, payload, headers); } }
/** * Creates a {@link Response} with the given status code. * * If {@code code} is OK, this function will be equivalent to {@link #ok()}. * * @param statusCode The status code * @param <T> The response payload type * @return A response object with the given status code */ static <T> Response<T> forStatus(StatusType statusCode) { return ResponseImpl.create(statusCode); }
/** * Creates a {@link Request} for the given uri. * * @param uri The requested uri * @return A request with for the given uri. */ static Request forUri(String uri) { return RequestValue.create(uri); } }