List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:se.uu.it.cs.recsys.service.resource.DomainReasoningResource.java
@GET @Path("/related") @Produces(MediaType.APPLICATION_JSON)// ww w. j a v a 2 s . co m @ApiOperation(value = "related", response = ComputingDomain.class, responseContainer = "Set") public Response getRelatedComputingDomains(@QueryParam("domainIds") Set<String> domainIds) { Set<ComputingDomain> output = new HashSet<>(); Set<String> relatedIds = this.domainReasoner.getRelatedCourseIdsForCollection(domainIds); relatedIds.stream().forEach(domainId -> { se.uu.it.cs.recsys.persistence.entity.ComputingDomain entity = this.computingDomainRepository .findById(domainId); output.add(new ComputingDomain(entity.getId(), entity.getName())); }); return Response.ok(output, MediaType.APPLICATION_JSON).build(); }
From source file:org.jimsey.projects.turbine.condenser.service.TurbineService.java
public List<EnableTurbineStrategy> getStrategies() { Reflections reflections = new Reflections(EnableTurbineStrategy.class.getPackage().getName()); Set<Class<?>> classes = reflections.getTypesAnnotatedWith(EnableTurbineStrategy.class); return classes.stream().map(c -> c.getDeclaredAnnotation(EnableTurbineStrategy.class)) .collect(Collectors.toList()); }
From source file:org.openmhealth.dsu.controller.EndUserController.java
protected List<String> asErrorMessageList( Set<ConstraintViolation<EndUserRegistrationData>> constraintViolations) { return constraintViolations.stream().map(ConstraintViolation::getMessage).collect(Collectors.toList()); }
From source file:org.jimsey.projects.turbine.condenser.service.TurbineService.java
public List<EnableTurbineIndicator> getIndicators() { Reflections reflections = new Reflections(EnableTurbineIndicator.class.getPackage().getName()); Set<Class<?>> classes = reflections.getTypesAnnotatedWith(EnableTurbineIndicator.class); return classes.stream().map(c -> c.getDeclaredAnnotation(EnableTurbineIndicator.class)) .collect(Collectors.toList()); }
From source file:se.uu.it.cs.recsys.service.resource.DomainReasoningResource.java
@GET @Path("/narrower") @Produces(MediaType.APPLICATION_JSON)/*from w w w. j a v a 2s. c o m*/ @ApiOperation(value = "narrower", response = ComputingDomain.class, responseContainer = "Set") public Response getNarrowerComputingDomains(@QueryParam("domainIds") Set<String> domainIds) { Set<ComputingDomain> output = new HashSet<>(); Set<String> narrowerIds = this.domainReasoner.getNarrowerCourseIdsForCollection(domainIds); narrowerIds.stream().forEach(domainId -> { se.uu.it.cs.recsys.persistence.entity.ComputingDomain entity = this.computingDomainRepository .findById(domainId); output.add(new ComputingDomain(entity.getId(), entity.getName())); }); return Response.ok(output, MediaType.APPLICATION_JSON).build(); }
From source file:natalia.dymnikova.cluster.scheduler.impl.requirements.ComputeMemberRequirementsBuilder.java
private Set<String> roles(final Set<ScannedGenericBeanDefinition> candidates) { return candidates.stream() .map(def -> ofNullable(def.getMetadata().getAllAnnotationAttributes(Profile.class.getName())) .map(map -> ((List<String[]>) (Object) map.get("value")).stream().flatMap(Arrays::stream) .collect(toList()))) .filter(Optional::isPresent).map(Optional::get).flatMap(Collection::stream).collect(toSet()); }
From source file:com.yqboots.security.web.form.GroupFormConverter.java
/** * Gets the id of users.//from w ww .java 2 s .c o m * * @param users users * @return id of users */ private Long[] getUsers(Set<User> users) { List<Long> results = new ArrayList<>(); if (CollectionUtils.isNotEmpty(users)) { results.addAll(users.stream().map(User::getId).collect(Collectors.toList())); } return results.toArray(new Long[results.size()]); }
From source file:com.yqboots.security.web.form.GroupFormConverter.java
/** * Gets the id of roles./* w w w . j a v a 2 s . c om*/ * * @param roles roles * @return id of roles */ private Long[] getRoles(Set<Role> roles) { List<Long> results = new ArrayList<>(); if (CollectionUtils.isNotEmpty(roles)) { results.addAll(roles.stream().map(Role::getId).collect(Collectors.toList())); } return results.toArray(new Long[results.size()]); }
From source file:org.ow2.proactive.connector.iaas.service.InstanceService.java
public Instance getInstanceById(String infrastructureId, String instanceId) { Set<Instance> instances = getAllInstances(infrastructureId); return instances.stream().filter(instance -> instance.getId().equals(instanceId)).findFirst() .orElseThrow(() -> new RuntimeException("Instance not found")); }
From source file:com.nebhale.buildmonitor.web.ControllerUtils.java
@ExceptionHandler(ConstraintViolationException.class) ResponseEntity<Set<String>> handleConstraintViolation(ConstraintViolationException e) { Set<ConstraintViolation<?>> constraintViolations = e.getConstraintViolations(); Set<String> messages = new HashSet<>(constraintViolations.size()); messages.addAll(constraintViolations.stream() .map(constraintViolation -> String.format("%s value '%s' %s", constraintViolation.getPropertyPath(), constraintViolation.getInvalidValue(), constraintViolation.getMessage())) .collect(Collectors.toList())); return new ResponseEntity<>(messages, HttpStatus.BAD_REQUEST); }