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:org.ff4j.services.GroupServices.java

public Collection<FeatureApiBean> getFeaturesByGroup(String groupName) {
    featureValidator.assertGroupExist(groupName);
    Collection<Feature> features = ff4j.getFeatureStore().readGroup(groupName).values();
    Collection<FeatureApiBean> featureApiBeans = new ArrayList<>();
    if (!CollectionUtils.isEmpty(features)) {
        featureApiBeans.addAll(features.stream().map(FeatureApiBean::new).collect(Collectors.toList()));
    }/*w  ww .j  a  v a2  s.c om*/
    return featureApiBeans;
}

From source file:org.esbtools.eventhandler.lightblue.testing.TestMetadataJson.java

public static LightblueExternalResource.LightblueTestMethods forEntities(Class<?>... entityClasses) {
    return new LightblueExternalResource.LightblueTestMethods() {
        @Override// ww w.  j a v  a  2s  .  c o m
        public JsonNode[] getMetadataJsonNodes() throws Exception {
            return Arrays.stream(entityClasses).map(TestMetadataJson::entityClassAsTestableJsonMetadata)
                    .collect(Collectors.toList()).toArray(new JsonNode[entityClasses.length]);
        }
    };
}

From source file:com.company.eleave.leave.rest.HolidayController.java

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<HolidayDTO>> getAll() {
    List<HolidayDTO> holidays = holidayService.getAll().stream().map(holiday -> mapper.toDto(holiday))
            .collect(Collectors.toList());

    return new ResponseEntity<>(holidays, HttpStatus.OK);
}

From source file:org.obiba.mica.taxonomy.TaxonomyIndexer.java

@Async
@Subscribe/*from  ww w  .  j a  v a 2s.com*/
public void opalTaxonomiesUpdatedEvent(OpalTaxonomiesUpdatedEvent event) {
    log.info("Reindex all opal taxonomies");
    index(TaxonomyTarget.VARIABLE, event.extractOpalTaxonomies().stream()
            .filter(t -> taxonomyService.metaTaxonomyContains(t.getName())).collect(Collectors.toList()));
}

From source file:co.mafiagame.engine.command.WhoIsPlayingCommand.java

@Override
public ResultMessage execute(EmptyContext context) {
    validateGameNotNull(context);// ww  w.j a v  a 2  s.c  om
    Game game = context.getGame();
    game.update();
    List<Player> players = game.getPlayers();
    List<Message> messages = players.stream().map(p -> new Message("user.playing")
            .setReceiverId(context.getInterfaceContext().getUserId()).setArgs(p.getAccount().getUsername()))
            .collect(Collectors.toList());
    return new ResultMessage(messages, context.getInterfaceContext().getSenderType(),
            context.getInterfaceContext());
}

From source file:io.pivotal.cla.data.repository.CorporateSignatureRepository.java

default CorporateSignature findSignature(String claName, Collection<String> organizations,
        Collection<String> emails) {
    PageRequest pageable = new PageRequest(0, 1);
    List<String> emailDomains = emails == null || emails.isEmpty() ? EMPTY_LIST_FOR_QUERY
            : emails.stream().map(e -> e.substring(e.lastIndexOf("@") + 1)).collect(Collectors.toList());
    organizations = organizations.isEmpty() ? EMPTY_LIST_FOR_QUERY : organizations;
    List<CorporateSignature> results = findSignatures(pageable, claName, organizations, emailDomains);
    return results.isEmpty() ? null : results.get(0);
}

From source file:com.github.rutledgepaulv.testsupport.CriteriaSerializer.java

private List<?> applyList(Collection<?> items) {
    return items.stream().map(item -> {
        if (item instanceof Enum<?>) {
            return Objects.toString(item);
        } else {/*from  w  w  w .j  ava2 s .  co  m*/
            return item;
        }
    }).collect(Collectors.toList());
}

From source file:mtsar.processors.task.FixedNumberAllocator.java

@Override
protected List<Integer> filterTasks(Map<Integer, Integer> counts) {
    checkAnswersPerTask();//from   w w w . jav  a2 s.co m
    return counts.entrySet().stream().filter(entry -> entry.getValue() < answersPerTask)
            .map(entry -> Triple.of(entry.getKey(), entry.getValue(), Math.random())).sorted(INVERSE_COUNT)
            .map(Triple::getLeft).collect(Collectors.toList());
}

From source file:org.trustedanalytics.ingestion.kafka2hdfs.config.KafkaConfiguration.java

private List<String> trackedTopics() {
    String topics = env.getProperty("TOPICS");
    // TODO: could be list in form: topic1:4,topic2:3
    // where number stands for number of partitions
    return Arrays.stream(topics.split(",")).map(String::trim).collect(Collectors.toList());
}

From source file:edu.usu.sdl.opencatalog.web.action.TestAction.java

@DefaultHandler
public Resolution checkSetup() {
    List<String> data = Arrays.asList("Hello", "Test", "Apple");
    data = data.stream().filter(item -> item.startsWith("A")).collect(Collectors.toList());
    return streamResults(data);
}