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.obiba.mica.comment.rest.CommentsResource.java

@GET
public List<Mica.CommentDto> comments(@PathParam("id") String id) {
    subjectAclService.checkPermission(String.format("/draft/%s", service.getTypeName()), "VIEW", id);
    return commentsService.findByResourceAndInstance(String.format("/draft/%s", service.getTypeName()), id)
            .stream().map(dtos::asDto).collect(Collectors.toList());
}

From source file:io.gravitee.repository.jdbc.converter.UserJpaConverter.java

public User convertTo(final UserJpa userJpa) {
    if (userJpa == null) {
        return null;
    }//  ww  w  .  j a  v a2 s  .  c  o  m
    final User user = new User();
    copyProperties(userJpa, user);
    user.setUsername(userJpa.getName());
    final List<RoleJpa> roles = userJpa.getRoles();
    if (roles != null && !roles.isEmpty()) {
        user.setRoles(roles.stream().map(role -> role.getName()).collect(Collectors.toList()));
    }
    return user;
}

From source file:org.obiba.mica.variable.search.rest.PublishedDatasetVariablesSetsResource.java

@GET
public List<Mica.DocumentSetDto> list(@QueryParam("id") List<String> ids) {
    if (ids.isEmpty())
        return variableSetService.getAllCurrentUser().stream().map(s -> dtos.asDto(s))
                .collect(Collectors.toList());
    else//from www.j  a  va  2s .c o m
        return ids.stream().map(id -> dtos.asDto(variableSetService.get(id))).collect(Collectors.toList());
}

From source file:com.yahoo.elide.jsonapi.models.Relationship.java

public Relationship(@JsonProperty("links") Map<String, String> links,
        @JsonProperty("data") Data<Resource> data) {
    this.links = links;
    this.data = data;
    if (data != null) {
        if (data.isToOne()) {
            Resource resource = data.get().iterator().next();
            this.idData = new Data<>(resource != null ? resource.toResourceIdentifier() : null);
        } else {//from w w w  .  j  ava 2s .  c o  m
            this.idData = new Data<>(
                    data.get().stream().map(Resource::toResourceIdentifier).collect(Collectors.toList()));
        }
    } else {
        this.idData = null;
    }
}

From source file:io.kahu.hawaii.runtime.RuntimeFeaturesHolder.java

public List<RuntimeFeature> getRuntimeFeatures(List<String> exclude) {
    if (exclude == null) {
        return new ArrayList<>(lookupMap.values());
    }/*from  w  ww . ja va2 s.c  o m*/
    return lookupMap.keySet().stream().filter(key -> {
        for (String pattern : exclude) {
            if (key.startsWith(pattern)) {
                return false;
            }
        }
        return true;
    }).map(lookupMap::get).collect(Collectors.toList());
}

From source file:com.neu.controller.OutcomeController.java

@RequestMapping(value = "/outcome.htm", method = RequestMethod.GET, headers = "Accept=*/*", produces = "application/json")
@ResponseStatus(HttpStatus.OK)//from w  ww. ja  va  2s  .c  om
public @ResponseBody String searchresult(HttpServletRequest request) throws Exception {
    System.out.println("in drugsearch controller");
    String action = request.getParameter("action");
    List<DrugOutcome> outcomes;
    String csvFile = "Merge.csv";
    String rpath = request.getRealPath("/");
    rpath = rpath + "/dataFiles/" + csvFile;
    Pattern pattern = Pattern.compile(",");

    BufferedReader in = new BufferedReader(new FileReader(rpath));
    outcomes = in.lines().skip(1).map(line -> {
        String[] x = pattern.split(line);
        return new DrugOutcome(x[3], x[20], x[7], x[6], x[8], x[13], x[4], x[5]);
    }).collect(Collectors.toList());
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationConfig.Feature.INDENT_OUTPUT);
    mapper.writeValue(System.out, outcomes);

    //            Drugs drug=new Drugs("AZ","sn");
    return mapper.writeValueAsString(outcomes);
}

From source file:org.shredzone.cilla.web.plugin.manager.ImageProcessingManager.java

/**
 * Sets up the manager.//from  ww w . jav a 2s . c  o m
 */
@PostConstruct
protected void setup() {
    factories = Collections.unmodifiableList(applicationContext.getBeansOfType(ImageProcessingFactory.class)
            .values().stream().sorted(new PriorityComparator<>(ImageProcessingFactory.class))
            .collect(Collectors.toList()));
}

From source file:de.sainth.recipe.backend.db.repositories.FoodRepository.java

public List<Food> findAll() {
    return create
            .selectFrom(FOODS).fetch().stream().map(record -> new Food(record.getId(), record.getName(),
                    record.getPoints(), record.getPointsBaseAmount(), record.getBasicUnit()))
            .collect(Collectors.toList());
}

From source file:com.carlomicieli.jtrains.test.ValidationResult.java

public List<String> fieldErrors(String fieldName) {
    return errorsStream().filter(fieldNamePredicate(fieldName)).map(ConstraintViolation::getMessageTemplate)
            .sorted().collect(Collectors.toList());
}

From source file:com.github.rutledgepaulv.qbuilders.visitors.MongoVisitor.java

@Override
protected Criteria visit(OrNode node) {
    Criteria criteria = new Criteria();
    List<Criteria> children = node.getChildren().stream().map(this::visitAny).collect(Collectors.toList());
    return criteria.orOperator(children.toArray(new Criteria[children.size()]));
}