Example usage for java.util.stream Collectors toList

List of usage examples for java.util.stream Collectors toList

Introduction

In this page you can find the example usage for java.util.stream Collectors toList.

Prototype

public static <T> Collector<T, ?, List<T>> toList() 

Source Link

Document

Returns a Collector that accumulates the input elements into a new List .

Usage

From source file:com.github.horrorho.inflatabledonkey.cloud.clients.AssetsClient.java

public static List<Assets> assets(HttpClient httpClient, CloudKitty kitty, ProtectionZone zone,
        Collection<Manifest> manifests) throws IOException {

    if (manifests.isEmpty()) {
        return new ArrayList<>();
    }/*from   w w w  . ja va  2s.com*/

    List<String> manifestIDs = manifests.stream().map(AssetsClient::manifestIDs).flatMap(Collection::stream)
            .collect(Collectors.toList());

    List<CloudKit.RecordRetrieveResponse> responses = kitty.recordRetrieveRequest(httpClient, "_defaultZone",
            manifestIDs);
    logger.info("-- assets() - responses: {}", responses.size());

    // Manifests with multiple counts only return protection info for the first block, as we are passing blocks in
    // order we can reference the previous protection zone.
    // TODO tighten up.
    AtomicReference<ProtectionZone> previous = new AtomicReference<>(zone);

    return responses.stream().filter(CloudKit.RecordRetrieveResponse::hasRecord)
            .map(CloudKit.RecordRetrieveResponse::getRecord).map(r -> assets(r, zone, previous))
            .collect(Collectors.toList());
}

From source file:io.gravitee.maven.plugins.json.schema.generator.util.ClassFinder.java

/**
 * Find class names from the given root Path that matching the given list of globs.
 * <p/>/*  w w w.j  a v  a 2s.  co m*/
 * Class names are built following the given rule:
 * - Given the root Path: /root/path/
 * - Given the Class Path: /root/path/the/path/to/the/class/Class.class
 * - Then associated Class name would be: the.path.to.the.class.Class
 *
 * @param root  the root Path from which start searching
 * @param globs the glob list to taking into account during path matching
 * @return a list of Paths that match the given list of globs from the root Path
 * @throws IOException if an I/O occurs
 */
public static List<String> findClassNames(Path root, Globs globs) throws IOException {
    Validate.notNull(root, "Unable to handle null root path");
    Validate.isTrue(root.toFile().isDirectory(), "Unable to handle non existing or non directory root path");
    Validate.notNull(globs, "Unable to handle null globs");

    List<String> matchedClassNames = new ArrayList<>();
    matchedClassNames.addAll(findClassPaths(root, globs).stream()
            .map(path -> ClassUtils.convertClassPathToClassName(path.toString(), root.normalize().toString()))
            .collect(Collectors.toList()));
    return matchedClassNames;
}

From source file:com.github.xdcrafts.flower.spring.impl.flows.AsyncFlowFactory.java

@Override
protected AsyncFlow createInstance() throws Exception {
    return new AsyncFlow(getBeanName(), this.actions.stream().map(this::toAction).collect(Collectors.toList()),
            this.configuration, getMiddleware(getBeanName()));
}

From source file:oauth2.authentication.approvals.ApprovalServiceImpl.java

@Override
public List<Approval> getApprovals(String userId, String clientId) {
    return approvalRepository.findByUserIdAndClientId(userId, clientId) //
            .stream() //
            .map(ApprovalServiceImpl::fromEntity) //
            .collect(Collectors.toList());
}

From source file:com.esri.geoportal.harvester.beans.TriggerInstanceManagerBean.java

@Override
public List<Map.Entry<UUID, TaskUuidTriggerInstancePair>> listAll() {
    return map.entrySet().stream().collect(Collectors.toList());
}

From source file:com.spartasystems.holdmail.mapper.MessageListMapper.java

public MessageList toMessageList(Stream<MessageEntity> messageEntityStream) {
    return new MessageList(messageEntityStream.map(this::toMessageListItem).collect(Collectors.toList()));
}

From source file:com.blurengine.blur.framework.ticking.TickMethodsCache.java

/**
 * Loads a Tickable class and generates {@link TaskBuilder}s of the {@code tickable}'s relevant methods. All given TaskBuilders require
 * the plugin to be set./*from w  w  w . j a  v  a  2  s  .  co  m*/
 *
 * @param tickable tickable to load task builders for.
 *
 * @return mutable collection of {@link TaskBuilder}
 */
public static Collection<TaskBuilder> loadTickableReturnTaskBuilders(@Nonnull Object tickable) {
    Preconditions.checkNotNull(tickable, "tickable cannot be null.");
    return loadClass(tickable.getClass()).stream().map(t -> t.toBuilder(tickable)).collect(Collectors.toList());
}

From source file:com.github.horrorho.inflatabledonkey.cloudkitty.operations.RecordRetrieveRequestOperations.java

static List<RequestOperation> operations(String zone, Collection<String> recordNames, String cloudKitUserId) {
    return recordNames.stream().map(u -> operation(zone, u, cloudKitUserId)).collect(Collectors.toList());
}

From source file:com.blackducksoftware.integration.hub.detect.workflow.report.DetectConfigurationReporter.java

private List<DetectOption> sortOptions(final List<DetectOption> detectOptions) {
    return detectOptions.stream().sorted((o1, o2) -> o1.getDetectProperty().getPropertyKey()
            .compareTo(o2.getDetectProperty().getPropertyKey())).collect(Collectors.toList());
}

From source file:am.ik.categolj3.api.jest.JestSync.java

@EventListener
public void handleBulkDelete(EntryEvictEvent.Bulk e) {
    AppState state = eventManager.getState();
    if (state == AppState.INITIALIZED || jestProperties.isInit()) {
        if (log.isInfoEnabled()) {
            log.info("Bulk delete ({})", e.getEvents().size());
        }/* w  ww .j  a  v a2 s.  co  m*/
        try {
            indexer.bulkDelete(
                    e.getEvents().stream().map(EntryEvictEvent::getEntryId).collect(Collectors.toList()));
        } catch (Exception ex) {
            log.warn("Failed to bulk delete", ex);
            e.getEvents().forEach(eventManager::registerEntryEvictEvent);
        }
    } else {
        if (log.isInfoEnabled()) {
            log.info("Skip to bulk delete (status={},jest.init={})", state, jestProperties.isInit());
        }
    }
}