Example usage for java.util.function Supplier get

List of usage examples for java.util.function Supplier get

Introduction

In this page you can find the example usage for java.util.function Supplier get.

Prototype

T get();

Source Link

Document

Gets a result.

Usage

From source file:nu.yona.server.analysis.rest.ActivityControllerBase.java

protected HttpEntity<PagedResources<WeekActivityOverviewResource>> getWeekActivityOverviews(
        Optional<String> password, UUID userId,
        PagedResourcesAssembler<WeekActivityOverviewDto> pagedResourcesAssembler,
        Supplier<Page<WeekActivityOverviewDto>> activitySupplier, LinkProvider linkProvider) {
    try (CryptoSession cryptoSession = CryptoSession.start(password,
            () -> userService.doPreparationsAndCheckCanAccessPrivateData(userId))) {
        return createOkResponse(activitySupplier.get(), pagedResourcesAssembler,
                createWeekActivityOverviewResourceAssembler(linkProvider));
    }//  w  w w. ja va2  s .  c om
}

From source file:org.sahli.asciidoc.confluence.publisher.client.ConfluencePublisher.java

private String addOrUpdatePage(String spaceKey, String ancestorId, ConfluencePageMetadata page, String content,
        Supplier<String> addPage) {
    String contentId;/*from  w w w . j ava 2  s .c  om*/
    try {
        contentId = this.confluenceClient.getPageByTitle(spaceKey, page.getTitle());
        ConfluencePage existingPage = this.confluenceClient.getPageWithContentAndVersionById(contentId);

        if (notSameHtmlContent(content, existingPage.getContent())) {
            this.confluenceClient.updatePage(contentId, ancestorId, page.getTitle(), content,
                    existingPage.getVersion() + 1);
        }
    } catch (NotFoundException e) {
        contentId = addPage.get();
    }

    return contentId;
}

From source file:nu.yona.server.analysis.rest.ActivityControllerBase.java

protected HttpEntity<PagedResources<DayActivityOverviewResource>> getDayActivityOverviews(
        Optional<String> password, UUID userId,
        PagedResourcesAssembler<DayActivityOverviewDto<DayActivityDto>> pagedResourcesAssembler,
        Supplier<Page<DayActivityOverviewDto<DayActivityDto>>> activitySupplier, LinkProvider linkProvider) {
    try (CryptoSession cryptoSession = CryptoSession.start(password,
            () -> userService.doPreparationsAndCheckCanAccessPrivateData(userId))) {
        return createOkResponse(activitySupplier.get(), pagedResourcesAssembler,
                createDayActivityOverviewResourceAssembler(linkProvider));
    }/*  w  ww  .ja  v  a2  s .  co  m*/
}

From source file:com.evolveum.midpoint.task.quartzimpl.work.WorkStateManager.java

public boolean canRun(Supplier<Boolean> canRunSupplier) {
    return canRunSupplier == null || BooleanUtils.isTrue(canRunSupplier.get());
}

From source file:nu.yona.server.analysis.rest.UserActivityController.java

private ResponseEntity<PagedResources<DayActivityOverviewWithBuddiesResource>> getDayActivityOverviewsWithBuddies(
        UUID userId, UUID requestingDeviceId,
        PagedResourcesAssembler<DayActivityOverviewDto<DayActivityWithBuddiesDto>> pagedResourcesAssembler,
        Supplier<Page<DayActivityOverviewDto<DayActivityWithBuddiesDto>>> activitySupplier) {
    GoalIdMapping goalIdMapping = GoalIdMapping.createInstance(userService.getPrivateUser(userId));

    return createOkResponse(activitySupplier.get(), pagedResourcesAssembler,
            createResourceAssembler(userId, requestingDeviceId, goalIdMapping));
}

From source file:org.tomitribe.tribestream.registryng.test.Registry.java

public <T> T withRetries(final Supplier<T> task, final String... description) {
    Throwable lastErr = null;/*from w w  w .  j  a  v a2  s.c  o m*/
    final int max = Integer.getInteger("test.registry.retries", 3);
    final Client client = ClientBuilder.newClient();
    try {
        for (int i = 0; i < max; i++) {
            assertEquals(Response.Status.OK.getStatusCode(),
                    client.target("http://localhost:" + System.getProperty("test.elasticsearch.port"))
                            .path("_refresh").request(MediaType.APPLICATION_JSON_TYPE).get().getStatus());
            try {
                return task.get();
            } catch (final Throwable error) {
                lastErr = error;
                if (i % 3 == 0) {
                    Logger.getLogger(Registry.class.getName())
                            .info("Retry cause (" + (i + 1) + "/" + max + ")"
                                    + ofNullable(description).filter(d -> d.length >= 1)
                                            .map(d -> Stream.of(d).collect(joining(" "))).orElse("")
                                    + ": " + error.getMessage());
                }
                try {
                    sleep(1000);
                } catch (final InterruptedException e) {
                    Thread.interrupted();
                    fail("quitting");
                }
            }
        }
    } finally {
        client.close();
    }
    if (RuntimeException.class.isInstance(lastErr)) {
        throw RuntimeException.class.cast(lastErr);
    }
    throw new IllegalStateException(lastErr);
}

From source file:nu.yona.server.analysis.rest.ActivityControllerBase.java

protected HttpEntity<PagedResources<MessageDto>> getActivityDetailMessages(Optional<String> password,
        UUID userId, PagedResourcesAssembler<MessageDto> pagedResourcesAssembler,
        Supplier<Page<MessageDto>> messageSupplier, LinkProvider linkProvider) {
    try (CryptoSession cryptoSession = CryptoSession.start(password,
            () -> userService.doPreparationsAndCheckCanAccessPrivateData(userId))) {
        UserDto user = userService.getPrivateValidatedUser(userId);
        return messageController.createOkResponse(user, messageSupplier.get(), pagedResourcesAssembler);
    }/* w  ww . j  av  a 2  s . c o  m*/
}

From source file:nu.yona.server.analysis.service.ActivityService.java

private Page<MessageDto> getActivityDetailMessages(UUID userId, Supplier<IntervalActivity> activitySupplier,
        Pageable pageable) {//ww w  .j  a va 2s  .c o m
    IntervalActivity dayActivityEntity = activitySupplier.get();
    if (dayActivityEntity == null) {
        return new PageImpl<>(Collections.emptyList());
    }
    return messageService.getActivityRelatedMessages(userId, dayActivityEntity, pageable);
}

From source file:enumj.EnumeratorTest.java

@Test
public void testAsSupplier() {
    System.out.println("asSupplier");
    EnumeratorGenerator.generatorPairs().limit(100)
            .map(p -> Pair.of(p.getLeft().enumerator(), p.getRight().enumerator().asSupplier())).forEach(p -> {
                long c = p.getLeft().count();
                Supplier<Optional<Double>> supplier = p.getRight();
                Optional<Double> d = supplier.get();
                while (d.isPresent()) {
                    --c;/*  w  w  w.j  av  a  2  s. c  om*/
                    d = supplier.get();
                }
                assertEquals(0, c);
            });
}