当前位置: 首页>>代码示例>>Java>>正文


Java F.Promise方法代码示例

本文整理汇总了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)));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:22,代码来源:CalculatorController.java

示例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())));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-des-stub,代码行数:23,代码来源:EligibilityStubController.java

示例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()));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:19,代码来源:CalculatorController.java

示例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)));

}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:18,代码来源:EligibilityController.java

示例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));
            }
        });
    }
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:17,代码来源:SelfAssessmentConnector.java

示例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()));
        }
    }
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:21,代码来源:EligibilityController.java

示例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());
    }
}
 
开发者ID:sismics,项目名称:play-accesslog,代码行数:10,代码来源:CappedEventStream.java

示例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()));
    }
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:13,代码来源:CalculatorController.java

示例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;
}
 
开发者ID:peterszatmary,项目名称:learning-play-framework,代码行数:13,代码来源:LogPerformanceInterceptor.java

示例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()));
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:9,代码来源:EligibilityController.java

示例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);
    }
 
开发者ID:xandradx,项目名称:ovirt-engine-disaster-recovery,代码行数:9,代码来源:Dashboard.java

示例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);
            }
        }
    );
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:12,代码来源:TransactionalAction.java

示例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);
            }
        }
    });
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:14,代码来源:TransactionalAction.java

示例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);
        }
    };
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:17,代码来源:GlobalSettings.java

示例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();
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:15,代码来源:CalculatorController.java


注:本文中的play.libs.F.Promise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。