/** * Resolve the deferred with an error and handle it. This method will handle the given exception, * send the response to a client and cleanup and close all the resources. * * @param cause A value for this deferred. */ public void reject(final Throwable cause) { super.set(cause); handler.handle(null, cause); }
/** * 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); }
/** * @param entity A result content! * @return A new result with {@link Status#OK} and given content. */ @Nonnull public static Result ok(final Object entity) { return ok().set(entity); }
/** * Creates a new {@link View}. * * @param name View's name. */ protected View(final String name) { this.name = requireNonNull(name, "View name is required."); type(MediaType.html); super.set(this); }
/** * @param content A result content! * @return A new result with {@link Status#ACCEPTED}. */ @Nonnull public static Result accepted(final Object content) { return accepted().set(content); }
/** * 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); }
/** * Resolve the deferred value and handle it. This method will send the response to a client and * cleanup and close all the resources. * * @param value A value for this deferred. */ public void resolve(@Nullable final Object value) { if (value == null) { handler.handle(null, null); } else { Result result; if (value instanceof Result) { super.set(value); result = (Result) value; } else { super.set(value); result = clone(); } handler.handle(result, null); } }
/** * @param entity A result content! * @return A new result with {@link Status#OK} and given content. */ @Nonnull public static Result ok(final Object entity) { return ok().set(entity); }
/** * @param content A result content! * @return A new result with {@link Status#ACCEPTED}. */ @Nonnull public static Result accepted(final Object content) { return accepted().set(content); }
/** * Resolve the deferred with an error and handle it. This method will handle the given exception, * send the response to a client and cleanup and close all the resources. * * @param cause A value for this deferred. */ public void reject(final Throwable cause) { super.set(cause); handler.handle(null, cause); }
/** * 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); }
/** * Creates a new {@link View}. * * @param name View's name. */ protected View(final String name) { this.name = requireNonNull(name, "View name is required."); type(MediaType.html); super.set(this); }
/** * 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); }
/** * Resolve the deferred value and handle it. This method will send the response to a client and * cleanup and close all the resources. * * @param value A value for this deferred. */ public void resolve(@Nullable final Object value) { if (value == null) { handler.handle(null, null); } else { Result result; if (value instanceof Result) { super.set(value); result = (Result) value; } else { super.set(value); result = clone(); } handler.handle(result, null); } }