當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。