本文整理汇总了Java中play.libs.F.Promise方法的典型用法代码示例。如果您正苦于以下问题:Java F.Promise方法的具体用法?Java F.Promise怎么用?Java F.Promise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.libs.F
的用法示例。
在下文中一共展示了F.Promise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultsSubmit
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> resultsSubmit() {
final Integer monthsToShow;
String formMonths = form().bindFromRequest().get("months_to_show");
if (formMonths != null) {
monthsToShow = Ints.tryParse(formMonths);
} else {
monthsToShow = 3;
}
List<PaymentSchedule> schedules = getPaymentSchedules(monthsToShow);
final PaymentSchedule scheduleToShow;
if (Optional.ofNullable(monthsToShow).isPresent()) {
scheduleToShow = schedules.stream().filter(s -> s.getInstalments().size() == monthsToShow).findFirst().orElse(schedules.stream().findFirst().get());
} else {
scheduleToShow = schedules.stream().findFirst().get();
}
List<Integer> availableOptions = schedules.stream().map(s -> s.getInstalments().size()).collect(Collectors.toList());
return F.Promise.promise(() -> ok(results.render(scheduleToShow, availableOptions)));
}
示例2: generateSAReturns
import play.libs.F; //导入方法依赖的package包/类
public F.Promise<Result> generateSAReturns(String utr) {
try {
if (!request().getHeader(AUTHORIZATION).isEmpty()) {
switch (utr) {
case "0": //404
return F.Promise.pure(Results.notFound());
case "force500":
return F.Promise.pure(Results.internalServerError(toJson(statusCodeService.generate500())));
case "force503":
return F.Promise.pure(new Status(ServiceUnavailable(), toJson(statusCodeService.generate503()), utf8));
case "1234567890Z":
return F.Promise.pure(Results.badRequest(toJson(statusCodeService.invalidRequest())));
default:
JsonNode json = JsonNodeFactory.instance.objectNode().set("returns", toJson(saReturnStubService.generateSAReturns()));
return F.Promise.pure(Results.ok(json));
}
}
} catch (NullPointerException e) {
return F.Promise.pure(Results.unauthorized(toJson(statusCodeService.generate401())));
}
return F.Promise.pure(Results.badRequest(toJson(statusCodeService.invalidRequest())));
}
示例3: paymentTodayPresent
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> paymentTodayPresent() {
JsonNode key = keystoreConnector.getKey(session("uuid")).get(timeout);
Form<CalculatorPaymentToday> form = form(CalculatorPaymentToday.class);
if(Optional.ofNullable(key).isPresent()) {
JsonNode amountsDue = key.get("data").get("calculator-amounts-due-form");
JsonNode paymentToday = key.get("data").get("calculator-payment-today-form");
if (Optional.ofNullable(amountsDue).isPresent()) {
if (Optional.ofNullable(paymentToday).isPresent())
return F.Promise.promise(() -> ok(payment_today_form.render(Form.form(CalculatorPaymentToday.class)
.fill(fromJson(paymentToday, CalculatorPaymentToday.class)))));
else
return F.Promise.promise(() -> ok(payment_today_form.render(form)));
} else return F.Promise.promise(() -> redirect(routes.CalculatorController.amountsDuePresent()));
} else return F.Promise.promise(() -> redirect(routes.CalculatorController.amountsDuePresent()));
}
示例4: existingTtpPresent
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> existingTtpPresent() {
JsonNode key = keystoreConnector.getKey(session("uuid")).get(SsttpFrontendConfig.timeout);
Form<EligibilityExistingTTP> form = Form.form(EligibilityExistingTTP.class);
if(Optional.ofNullable(key).isPresent()) {
JsonNode debtType = key.get("data").get("eligibility-debt-type-form");
JsonNode existingTtp = key.get("data").get("eligibility-existing-ttp-form");
if(Optional.ofNullable(debtType).isPresent()) {
if(Optional.ofNullable(existingTtp).isPresent())
return F.Promise.promise(() ->
ok(existing_ttp.render(Form.form(EligibilityExistingTTP.class).fill(fromJson(existingTtp, EligibilityExistingTTP.class)))));
else return F.Promise.promise(() -> ok(existing_ttp.render(form)));
} else
return F.Promise.promise(() -> redirect(routes.EligibilityController.present()));
} else return F.Promise.promise(() -> ok(existing_ttp.render(form)));
}
示例5: sendUserInput
import play.libs.F; //导入方法依赖的package包/类
public F.Promise<List<PaymentSchedule>> sendUserInput(CalculatorInput calcInput) {
String calculatorUrl = String.format("%s/%s", baseUrl, "paymentschedule");
Logger.debug(toJson(calcInput).toString());
F.Promise<WSResponse> result = WS.url(calculatorUrl).post(toJson(calcInput));
return result.map(r -> {
if (r.getStatus() != 200) {
return new ArrayList<PaymentSchedule>();
} else {
return Arrays.asList(fromJson(r.asJson(), PaymentSchedule[].class));
}
});
}
示例6: debtTypeSubmit
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> debtTypeSubmit() {
Form<EligibilityDebtType> form = Form.form(EligibilityDebtType.class).bindFromRequest();
if(form.hasErrors()) {
return F.Promise.promise(() -> ok(debt_type.render(form)));
} else {
EligibilityDebtType debtTypeAnswer = form.get();
Logger.debug(toJson(debtTypeAnswer).toString());
String uuid = session("uuid");
if(Optional.ofNullable(uuid).isPresent())
keystoreConnector.putKey(toJson(debtTypeAnswer), uuid, "eligibility-debt-type-form");
if(debtTypeAnswer.isOtherTaxDebt()) {
return F.Promise.promise(() -> redirect(routes.SelfServiceTimeToPayController.ttpCallUs()));
} else {
return F.Promise.promise(() -> redirect(routes.EligibilityController.existingTtpPresent()));
}
}
}
示例7: nextEvent
import play.libs.F; //导入方法依赖的package包/类
public synchronized F.Promise<T> nextEvent() {
if (this.events.isEmpty()) {
CappedEventStream<T>.LazyTask task = new CappedEventStream.LazyTask();
this.waiting.add(task);
return task;
} else {
return new CappedEventStream.LazyTask(this.events.peek());
}
}
示例8: amountsDueSubmit
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> amountsDueSubmit() {
Form<CalculatorAmountsDue> form = form(CalculatorAmountsDue.class).bindFromRequest();
if (form.hasErrors()) {
return F.Promise.promise(() -> ok(amounts_due_form.render(form)));
} else {
CalculatorAmountsDue formData = form.get();
String uuid = session("uuid");
if(Optional.ofNullable(uuid).isPresent())
keystoreConnector.putKey(toJson(formData), uuid, "calculator-amounts-due-form");
return F.Promise.promise(() -> redirect(routes.CalculatorController.paymentTodayPresent()));
}
}
示例9: call
import play.libs.F; //导入方法依赖的package包/类
@Override
public F.Promise<Result> call(Http.Context context) throws Throwable {
// finding out which method in which controller is performed
final String METHOD = context.args.get("ROUTE_CONTROLLER") + "." + context.args.get("ROUTE_ACTION_METHOD");
Logger.info("Method " + METHOD + " started");
long start = System.currentTimeMillis();
F.Promise<Result> result = delegate.call(context);
long end = System.currentTimeMillis();
Logger.info("Method " + METHOD + " end in " + (end - start) + " milliseconds.");
return result;
}
示例10: present
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> present() {
String refererUrl = request().getHeader("referer");
if(Optional.ofNullable(refererUrl).isPresent() && refererUrl.contains(routes.SelfServiceTimeToPayController.serviceStart().url()))
return F.Promise.promise(() -> redirect(routes.EligibilityController.debtTypePresent()));
else
return F.Promise.promise(() -> redirect(routes.SelfServiceTimeToPayController.serviceStart()));
}
示例11: checkConnectionStatus
import play.libs.F; //导入方法依赖的package包/类
public static void checkConnectionStatus() {
F.Promise<ConnectionStatusJob.ConnectionStatus> apiStatus = new ConnectionStatusJob().now();
ConnectionStatusJob.ConnectionStatus status = await(apiStatus);
ServiceResponse serviceResponse = ServiceResponse.success(status);
renderJSON(serviceResponse);
}
示例12: call
import play.libs.F; //导入方法依赖的package包/类
public F.Promise<SimpleResult> call(final Context ctx) throws Throwable {
return JPA.withTransactionAsync(
configuration.value(),
configuration.readOnly(),
new play.libs.F.Function0<F.Promise<SimpleResult>>() {
public F.Promise<SimpleResult> apply() throws Throwable {
return delegate.call(ctx);
}
}
);
}
示例13: call
import play.libs.F; //导入方法依赖的package包/类
public F.Promise<SimpleResult> call(final Context ctx) throws Throwable {
return Ebean.execute(new TxCallable<F.Promise<SimpleResult>>() {
public F.Promise<SimpleResult> call() {
try {
return delegate.call(ctx);
} catch(RuntimeException e) {
throw e;
} catch(Throwable t) {
throw new RuntimeException(t);
}
}
});
}
示例14: onRequest
import play.libs.F; //导入方法依赖的package包/类
/**
* Call to create the root Action of a request for a Java application.
* The request and actionMethod values are passed for information.
*
* @param request The HTTP Request
* @param actionMethod The action method containing the user code for this Action.
* @return The default implementation returns a raw Action calling the method.
*/
@SuppressWarnings("rawtypes")
public Action onRequest(Request request, Method actionMethod) {
return new Action.Simple() {
public F.Promise<SimpleResult> call(Context ctx) throws Throwable {
return delegate.call(ctx);
}
};
}
示例15: paymentTodaySubmit
import play.libs.F; //导入方法依赖的package包/类
public static F.Promise<Result> paymentTodaySubmit() {
Form<CalculatorPaymentToday> form = form(CalculatorPaymentToday.class).bindFromRequest();
if (form.hasErrors()) {
return F.Promise.promise(() -> ok(payment_today_form.render(form)));
} else {
CalculatorPaymentToday formData = form.get();
String uuid = session("uuid");
if(Optional.ofNullable(uuid).isPresent())
keystoreConnector.putKey(toJson(formData), uuid, "calculator-payment-today-form");
}
return resultsSubmit();
}