List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:org.obiba.mica.study.rest.DraftHarmonizationStudiesResource.java
@GET @Path("/harmonization-studies") @Timed//from w w w. j a v a2s. c o m public List<Mica.StudyDto> list() { return harmonizationStudyService.findAllDraftStudies().stream() .filter(s -> subjectAclService.isPermitted("/draft/harmonization-study", "VIEW", s.getId())) .sorted(Comparator.comparing(AbstractGitPersistable::getId)).map(s -> dtos.asDto(s, true)) .collect(Collectors.toList()); }
From source file:org.artifactory.ui.rest.service.artifacts.browse.treebrowser.tabs.general.licenses.ScanArtifactForLicensesService.java
@Override public void execute(ArtifactoryRestRequest request, RestResponse response) { RepoPath path = RequestUtils.getPathFromRequest(request); if (!authService.canAnnotate(path)) { response.error("Insufficient permissions for operation").responseCode(HttpStatus.SC_UNAUTHORIZED); return;//from w ww .j a va2s . com } Set<LicenseInfo> foundLicenses = addonsManager.addonByType(LicensesAddon.class).scanPathForLicenses(path); if (foundLicenses.isEmpty() || (foundLicenses.size() == 1 && foundLicenses.iterator().next().isNotFound())) { //Don't send "not found" object - UI gets empty array and handles response.iModelList(Lists.newArrayList()); } else { response.iModel(foundLicenses.stream().map(GeneralTabLicenseModel::new).collect(Collectors.toList())); } }
From source file:delfos.dataset.basic.user.UsersDatasetAdapter.java
public static <RatingType extends Rating> int hashCode(UsersDataset usersDataset) { HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(37, 11); List<Integer> usersSorted = usersDataset.allIDs().stream().sorted().collect(Collectors.toList()); List<Feature> features = Arrays.asList(usersDataset.getFeatures()).stream().sorted(Feature.BY_ID) .collect(Collectors.toList()); for (int idUser : usersSorted) { User user = usersDataset.get(idUser); hashCodeBuilder.append(idUser);/* ww w . ja v a2 s . c om*/ hashCodeBuilder.append(user.getName()); for (Feature feature : features) { if (user.getFeatures().contains(feature)) { Object featureValue = user.getFeatureValue(feature); hashCodeBuilder.append(feature.getName()); hashCodeBuilder.append(feature.getType().name()); hashCodeBuilder.append(featureValue); } } } final int finalHashValue = hashCodeBuilder.hashCode(); return finalHashValue; }
From source file:com.github.rutledgepaulv.qbuilders.visitors.MongoVisitor.java
@Override protected Criteria visit(ComparisonNode node) { ComparisonOperator operator = node.getOperator(); Collection<?> values = node.getValues().stream().map(normalizer).collect(Collectors.toList()); String field = node.getField().asKey(); if (ComparisonOperator.EQ.equals(operator)) { return where(field).is(single(values)); } else if (ComparisonOperator.NE.equals(operator)) { return where(field).ne(single(values)); } else if (ComparisonOperator.EX.equals(operator)) { return where(field).exists((Boolean) single(values)); } else if (ComparisonOperator.GT.equals(operator)) { return where(field).gt(single(values)); } else if (ComparisonOperator.LT.equals(operator)) { return where(field).lt(single(values)); } else if (ComparisonOperator.GTE.equals(operator)) { return where(field).gte(single(values)); } else if (ComparisonOperator.LTE.equals(operator)) { return where(field).lte(single(values)); } else if (ComparisonOperator.IN.equals(operator)) { return where(field).in(values); } else if (ComparisonOperator.NIN.equals(operator)) { return where(field).nin(values); } else if (ComparisonOperator.RE.equals(operator)) { return where(field).regex((String) single(values)); } else if (ComparisonOperator.SUB_CONDITION_ANY.equals(operator)) { return where(field).elemMatch(condition(node)); }//from w ww . j a va 2s. com throw new UnsupportedOperationException("This visitor does not support the operator " + operator + "."); }
From source file:co.mafiagame.engine.command.StartFinalElectionCommand.java
@Override public ResultMessage execute(EmptyContext context) { validateGameNotNull(context);//from w w w . j a va 2s.c o m Game game = context.getGame(); game.update(); if (game.getElectionMood() != ElectionMood.NONE) throw new ElectionAlreadyStarted(); if (game.getGameMood() != GameMood.DAY) throw new VoteOnNightException(); game.startElection(true); List<String> users = game.getPlayers().stream().map(Player::getAccount).map(Account::getUsername) .collect(Collectors.toList()); return new ResultMessage(new Message("final.election.started") .setOptions(game.makeOption(Constants.CMD.VOTE, true)).setToUsers(users), ChannelType.GENERAL, context.getInterfaceContext()); }
From source file:cz.muni.fi.editor.webapp.controllers.ajax.AjaxBrowseController.java
@RequestMapping("/folders/") public @ResponseBody List<AjaxFolder> listFolders(@RequestParam(value = "folder") String folder) { return repoTreeService.generateTree().stream().map(AjaxFolder::new).collect(Collectors.toList()); }
From source file:am.ik.categolj3.api.tag.InMemoryTagService.java
@Override public List<String> findAllOrderByNameAsc() { return this.tags.values().stream().flatMap(Collection::stream).distinct().sorted() .collect(Collectors.toList()); }
From source file:io.syndesis.rest.v1.handler.tests.TestSupportHandler.java
public TestSupportHandler(DataManager dataMgr, List<DataAccessObject<?>> daos, OpenShiftService openShiftService) { this.dataMgr = dataMgr; this.daos = daos.stream().filter(x -> !x.isReadOnly()).collect(Collectors.toList()); this.openShiftService = openShiftService; }
From source file:io.sqp.proxy.customtypes.CustomTypeMapper.java
public void registerMapping(String name, JsonNode schema, List<String> keywords, ResultHandler<String> resultHandler) throws TypeMappingNotPossibleException { name = name.toLowerCase();/*from ww w . j a va 2s .c o m*/ checkMappingName(name); keywords = keywords.stream().map(String::toLowerCase).collect(Collectors.toList()); SchemaMatcher schemaMatcher; schemaMatcher = new SchemaMatcher(schema); // TODO: support standard type repository and throw an error if it fits a standard type? String match = findMappingInRepo(schemaMatcher, keywords, _backendTypeRepo, "backend repository"); if (match == null) { throw new TypeMappingNotPossibleException("No native type matches the provided schema."); } registerWorkingMapping(name, match, schema, resultHandler); }