List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:com.ikanow.aleph2.aleph2_rest_utils.QueryComponentBeanUtils.java
/** * Converts our simple QueryComponentBean into a QueryComponent composed of SingleQueryComponents and MultiQueryComponents. * Note: if an 'and' or 'or' are present in the current stage of the QueryComponentBean, we ignore anything in the operator * fields (because a QueryComponent can only be a SingleQueryComponent of operations OR a MultiQueryComponent composed of ands and ors (no operations)). * If 'and' and 'or' are both specified, we default to 'and'. * //from w w w . j a va2s . co m * @param toConvert * @param clazz * @return */ public static <T> QueryComponent<T> convertQueryComponentBeanToComponent(final QueryComponentBean toConvert, Class<T> clazz, Optional<Long> limit) { if ((!toConvert.and().isEmpty())) { //is multi and query return CrudUtils.allOf(toConvert.and().stream() .map(a -> convertQueryComponentBeanToComponent(a, clazz, limit)).collect(Collectors.toList())); } else if (!toConvert.or().isEmpty()) { //is multi or query return CrudUtils.anyOf(toConvert.or().stream() .map(a -> convertQueryComponentBeanToComponent(a, clazz, limit)).collect(Collectors.toList())); } else { //otherwise create a singleQuery return getSingleQueryComponent(toConvert, clazz, limit); } }
From source file:com.baifendian.swordfish.common.job.struct.node.storm.param.IStormParam.java
default void addProjectResourceFiles(List<ResourceInfo> resourceInfos, List<String> resFiles) { if (CollectionUtils.isNotEmpty(resourceInfos)) { resFiles.addAll(resourceInfos.stream().filter(p -> p.isProjectScope()).map(p -> p.getRes()) .collect(Collectors.toList())); }//w ww. j ava 2 s .c o m }
From source file:com.netflix.spinnaker.clouddriver.artifacts.ArtifactCredentialsRepository.java
public ArtifactCredentialsRepository(List<List<? extends ArtifactCredentials>> allCredentials) { this.allCredentials = Collections.unmodifiableList(allCredentials.stream().filter(Objects::nonNull) .flatMap(Collection::stream).collect(Collectors.toList())); }
From source file:am.ik.categolj2.domain.service.logger.LogbackLoggerService.java
@Override public synchronized List<LoggerDto> findAll() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList().stream() .map(logger -> new LoggerDto(logger.getName(), logger.getEffectiveLevel().toString())) .collect(Collectors.toList()); }
From source file:com.nebhale.springone2014.web.DoorsResourceAssembler.java
@Override public Resources<Resource<Door>> toResource(Game game) { List<Resource<Door>> doors = game.getDoors().stream().map(door -> toResource(game, door)) .collect(Collectors.toList()); Resources<Resource<Door>> resource = new Resources<Resource<Door>>(doors); resource.add(linkTo(GamesController.class).slash(game.getId()).slash("doors").withSelfRel()); return resource; }
From source file:uk.ac.ebi.ep.data.repositories.UniprotXrefRepositoryImpl.java
@Override public List<UniprotXref> findPDBcodesByAccession(String accession) { JPAQuery query = new JPAQuery(entityManager); BooleanExpression isAccession = $.accession.accession.equalsIgnoreCase(accession); List<UniprotXref> pdb = query.from($).where($.source.equalsIgnoreCase(PDB) .and($.sourceName.isNotNull().or($.sourceName.isNotEmpty())).and(isAccession)).list($); return pdb.stream().distinct().collect(Collectors.toList()); }
From source file:io.github.carlomicieli.footballdb.starter.parsers.PlayerCareerParser.java
protected static List<Map<String, String>> seasonRows(Document doc) { Elements rows = careerTable(doc).map(e -> e.getElementsByTag("tr")) .orElseThrow(() -> new RuntimeException("")); List<Map<String, String>> seasons = rows.stream().filter(e -> e.className().equals("")) .filter(e -> e.children().size() > 1).map(PlayerCareerParser::extractValues) .filter(mv -> !mv.get("SeasonStats").equals("TOTAL")).collect(Collectors.toList()); return seasons; }
From source file:com.epam.reportportal.auth.AuthUtilsTest.java
@Test public void testAuthoritiesConverter() { Collection<GrantedAuthority> grantedAuthorities = Collections.singletonList(UserRole.USER).stream() .map(AuthUtils.AS_AUTHORITIES).collect(Collectors.toList()).get(0); Assert.assertThat("Incorrect authority conversion", grantedAuthorities.iterator().next().getAuthority(), Matchers.is(UserRole.USER.getAuthority())); }
From source file:com.github.xdcrafts.flower.spring.impl.flows.SyncFlowFactory.java
@Override protected SyncFlow createInstance() throws Exception { return new SyncFlow(getBeanName(), this.actions.stream().map(this::toAction).collect(Collectors.toList()), getMiddleware(getBeanName())); }
From source file:com.infinitechaos.vpcviewer.web.rest.dto.VpcDTO.java
public VpcDTO(final Vpc vpc) { this.vpcId = vpc.getVpcId(); this.cidrBlock = vpc.getCidrBlock(); this.state = vpc.getState(); this.tags.addAll(vpc.getTags().stream().map(TagDTO::new).collect(Collectors.toList())); this.name = vpc.getTags().stream().filter(t -> t.getKey().equals("Name")).findFirst().map(Tag::getValue) .orElse("n/a"); }