@Override protected Result clone() { Result result = new Result(); headers.forEach(result::header); result.status = status; result.type = type; result.value = value; return result; }
/** * Set the response status. * * @param status A status! * @return A new result. */ @Nonnull public static Result with(final int status) { requireNonNull(status, "A HTTP status is required."); return new Result().status(status); }
/** * Set the response status. * * @param status A status! * @return A new result. */ @Nonnull public static Result with(final Status status) { requireNonNull(status, "A HTTP status is required."); return new Result().status(status); }
/** * Set the result * * @param entity A result value. * @return A new result. */ @Nonnull public static Result with(final Object entity) { return new Result().set(entity); }
/** * Performs content-negotiation on the Accept HTTP header on the request object. It select a * handler for the request, based on the acceptable types ordered by their quality values. * If the header is not specified, the first callback is invoked. When no match is found, * the server responds with 406 "Not Acceptable", or invokes the default callback: {@code ** / *}. * * <pre> * get("/jsonOrHtml", () {@literal ->} * Results * .when("text/html", () {@literal ->} Results.html("view").put("model", model))) * .when("application/json", () {@literal ->} model) * .when("*", () {@literal ->} {throw new Err(Status.NOT_ACCEPTABLE);}) * ); * </pre> * * @param type A media type. * @param supplier A result supplier. * @return A new result. */ @Nonnull public static Result when(final MediaType type, final Supplier<Object> supplier) { return new Result().when(type, supplier); }
/** * Set the result * * @param entity A result value. * @param status A HTTP status. * @return A new result. */ @Nonnull public static Result with(final Object entity, final Status status) { return new Result().status(status).set(entity); }
/** * Performs content-negotiation on the Accept HTTP header on the request object. It select a * handler for the request, based on the acceptable types ordered by their quality values. * If the header is not specified, the first callback is invoked. When no match is found, * the server responds with 406 "Not Acceptable", or invokes the default callback: {@code ** / *}. * * <pre> * get("/jsonOrHtml", () {@literal ->} * Results * .when("text/html", () {@literal ->} Results.html("view").put("model", model))) * .when("application/json", () {@literal ->} model) * .when("*", () {@literal ->} {throw new Err(Status.NOT_ACCEPTABLE);}) * ); * </pre> * * @param type A media type. * @param supplier A result supplier. * @return A new result. */ @Nonnull public static Result when(final String type, final Supplier<Object> supplier) { return new Result().when(type, supplier); }
@Override protected Result clone() { Result result = new Result(); headers.forEach(result::header); result.status = status; result.type = type; result.value = value; return result; }
/** * Set the result * * @param entity A result value. * @return A new result. */ @Nonnull public static Result with(final Object entity) { return new Result().set(entity); }
/** * Set the response status. * * @param status A status! * @return A new result. */ @Nonnull public static Result with(final int status) { requireNonNull(status, "A HTTP status is required."); return new Result().status(status); }
/** * Set the response status. * * @param status A status! * @return A new result. */ @Nonnull public static Result with(final Status status) { requireNonNull(status, "A HTTP status is required."); return new Result().status(status); }
/** * Performs content-negotiation on the Accept HTTP header on the request object. It select a * handler for the request, based on the acceptable types ordered by their quality values. * If the header is not specified, the first callback is invoked. When no match is found, * the server responds with 406 "Not Acceptable", or invokes the default callback: {@code ** / *}. * * <pre> * get("/jsonOrHtml", () {@literal ->} * Results * .when("text/html", () {@literal ->} Results.html("view").put("model", model))) * .when("application/json", () {@literal ->} model) * .when("*", () {@literal ->} {throw new Err(Status.NOT_ACCEPTABLE);}) * ); * </pre> * * @param type A media type. * @param supplier A result supplier. * @return A new result. */ @Nonnull public static Result when(final MediaType type, final Supplier<Object> supplier) { return new Result().when(type, supplier); }
/** * Set the result * * @param entity A result value. * @param status A HTTP status. * @return A new result. */ @Nonnull public static Result with(final Object entity, final Status status) { return new Result().status(status).set(entity); }
/** * Performs content-negotiation on the Accept HTTP header on the request object. It select a * handler for the request, based on the acceptable types ordered by their quality values. * If the header is not specified, the first callback is invoked. When no match is found, * the server responds with 406 "Not Acceptable", or invokes the default callback: {@code ** / *}. * * <pre> * get("/jsonOrHtml", () {@literal ->} * Results * .when("text/html", () {@literal ->} Results.html("view").put("model", model))) * .when("application/json", () {@literal ->} model) * .when("*", () {@literal ->} {throw new Err(Status.NOT_ACCEPTABLE);}) * ); * </pre> * * @param type A media type. * @param supplier A result supplier. * @return A new result. */ @Nonnull public static Result when(final String type, final Supplier<Object> supplier) { return new Result().when(type, supplier); }