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.przemo.projectmanagementweb.services.SprintService.java

public void saveSprint(Sprint object) throws Exception {
    if (object.getSprintStatus() == null) {
        object.setSprintStatus(getAllStatuses().stream().filter(s -> s.getName().equals("Created"))
                .collect(Collectors.toList()).get(0));
    }/*ww  w  .  ja v  a2s  .c  o  m*/
    HibernateUtil.saveObject(object);
}

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

public static List<Snapshot> snapshots(HttpClient httpClient, CloudKitty kitty, ProtectionZone zone,
        Collection<SnapshotID> snapshotIDs) throws IOException {

    if (snapshotIDs.isEmpty()) {
        return new ArrayList<>();
    }//from   ww w .j  a v a 2s.c  o  m

    List<String> snapshots = snapshotIDs.stream().map(SnapshotID::id).collect(Collectors.toList());

    List<CloudKit.RecordRetrieveResponse> responses = kitty.recordRetrieveRequest(httpClient, "mbksync",
            snapshots);
    logger.debug("-- manifests() - responses: {}", responses);

    return responses.stream().filter(CloudKit.RecordRetrieveResponse::hasRecord)
            .map(CloudKit.RecordRetrieveResponse::getRecord).map(r -> manifests(r, zone))
            .filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
}

From source file:com.create.validation.ValidationErrorsProvider.java

public List<ValidationError<?>> getValidationErrors() {
    return IntStream.range(0, targets.size()).boxed().map(this::getValidationError).filter(Objects::nonNull)
            .collect(Collectors.toList());
}

From source file:com.infinitechaos.vpcviewer.web.rest.dto.RouteTableDTO.java

public RouteTableDTO(final RouteTable routeTable) {
    this.routeTableId = routeTable.getRouteTableId();
    this.vpcId = routeTable.getVpcId();
    this.routes.addAll(routeTable.getRoutes().stream().map(RouteDTO::new).collect(Collectors.toList()));
    this.tags.addAll(routeTable.getTags().stream().map(TagDTO::new).collect(Collectors.toList()));
    this.associations.addAll(routeTable.getAssociations().stream().map(RouteTableAssociationDTO::new)
            .collect(Collectors.toList()));
    this.propagatingVgws.addAll(
            routeTable.getPropagatingVgws().stream().map(PropagatingVgwDTO::new).collect(Collectors.toList()));
}

From source file:com.github.rutledgepaulv.qbuilders.structures.FieldPath.java

public FieldPath append(String... path) {
    List<FieldNamespace> chain = new LinkedList<>();
    chain.addAll(this.chain);
    chain.addAll(Arrays.stream(path).map(FieldNamespace::new).collect(Collectors.toList()));
    return new FieldPath(chain);
}

From source file:io.github.bluemarlin.ui.searchtree.SearchFile.java

public SearchFile(File file) throws IOException {
    List<String> lines = FileUtils.readLines(file, "UTF-8");

    List<String> comments = lines.stream().filter(l -> l.startsWith("`")).collect(Collectors.toList());

    renderer = comments.stream().filter(c -> c.contains("$renderer")).findFirst().orElse("default");

    if ("default".equals(renderer)) {
        renderer = BluemarlinConfig.defaultRenderer();
    } else {//  w w  w  .j a v a2  s. com
        renderer = StringUtils.substringAfter(renderer, "=");
    }

    int twentyMinsInMillis = 20 * 60 * 1000;
    long timeNowInMillis = (new Date()).getTime();
    String twentyMinsAgoInMillis = String.valueOf(timeNowInMillis - twentyMinsInMillis);
    jsonSearch = lines.stream().filter(l -> !l.startsWith("`"))
            .map(l -> l.replace("$DEFAULT_LEAGUE", BluemarlinConfig.defaultLeague()))
            .map(l -> l.replace("$TWENTY_MINS_AGO_IN_MILLISEC", twentyMinsAgoInMillis))
            .collect(Collectors.joining(System.lineSeparator()));
}

From source file:it.polimi.diceH2020.launcher.FileService.java

public List<Solution> getBaseSolutions() {
    Stream<Path> strm = getBaseSolutionsPath();
    return strm == null ? new ArrayList<>()
            : strm.map(p -> getObjectFromPath(p, Solution.class)).collect(Collectors.toList());
}

From source file:io.knotx.knot.service.ServiceKnotConfiguration.java

public ServiceKnotConfiguration(JsonObject config) {
    address = config.getString("address");
    services = config.getJsonArray("services").stream().map(item -> (JsonObject) item).map(item -> {
        ServiceMetadata metadata = new ServiceMetadata();
        metadata.name = item.getString("name");
        metadata.address = item.getString("address");
        metadata.params = item.getJsonObject("params");
        metadata.cacheKey = item.getString("cacheKey");
        return metadata;
    }).collect(Collectors.toList());
}

From source file:ru.jts_dev.gameserver.inventory.InventoryService.java

/**
 * Collect all items, that type not equals to {@link ItemClass#QUESTITEM}.
 * Returns copied and filtered list of {@code character} items.
 * There are no guaranties of mutability, thread-safety for returned {@link List}.
 *
 * @param character - character, which items will be returned
 * @return - list of all items, except quest items
 *//*from   ww  w  .j  ava2s.c om*/
public static List<GameItem> getCommonItemsFrom(final GameCharacter character) {
    return character.getInventory().getItems().stream()
            .filter(item -> item.getItemData().getItemType() != ItemClass.QUESTITEM)
            .collect(Collectors.toList());
}

From source file:am.ik.categolj2.api.recentpost.RecentPostRestController.java

@RequestMapping(method = RequestMethod.GET)
public List<RecentPostResource> getRecentPosts() {
    List<Entry> entries = entryService.findAllPublishedUpdatedRecently();
    return entries.stream().map(entry -> beanMapper.map(entry, RecentPostResource.class))
            .collect(Collectors.toList());
}