List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:org.ng200.openolympus.resourceResolvers.OpenOlympusMessageSource.java
private void reportMissingLocalisationKey(final String code) { try {/*from ww w . j a v a2 s.c om*/ if (code.isEmpty() || Character.isUpperCase(code.charAt(0))) { return; } final Path file = FileSystems.getDefault().getPath(this.storagePath, "missingLocalisation.txt"); if (!FileAccess.exists(file)) { FileAccess.createDirectories(file.getParent()); FileAccess.createFile(file); } final Set<String> s = new TreeSet<>(Arrays.asList(FileAccess.readUTF8String(file).split("\n"))); s.add(code); FileAccess.writeUTF8StringToFile(file, s.stream().collect(Collectors.joining("\n"))); } catch (final IOException e) { OpenOlympusMessageSource.logger.error("Couldn't add to missing key repo: {}", e); } }
From source file:am.ik.categolj2.domain.service.entry.EntryServiceImpl.java
void houseKeepTag(Set<Tag> tags) { tagRepository.delete(tags.stream().filter(tag -> tagRepository.countByTagName(tag.getTagName()) == 1) .peek(tag -> log.info("Delete unused tag -> {}", tag)).collect(Collectors.toList())); }
From source file:com.diversityarrays.kdxplore.trials.SampleGroupExportDialog.java
static public Set<Integer> getExcludedTraitIds(Component comp, String msgTitle, KdxploreDatabase kdxdb, SampleGroup sg) {//from w w w . j a v a 2 s . c o m Set<Integer> excludeTheseTraitIds = new HashSet<>(); try { Set<Integer> traitIds = collectTraitIdsFromSamples(kdxdb, sg); List<Trait> undecidableTraits = new ArrayList<>(); Set<Integer> missingTraitIds = new TreeSet<>(); Map<Integer, Trait> traitMap = kdxdb.getKDXploreKSmartDatabase().getTraitMap(); for (Integer traitId : traitIds) { Trait t = traitMap.get(traitId); if (t == null) { missingTraitIds.add(traitId); } else if (TraitLevel.UNDECIDABLE == t.getTraitLevel()) { undecidableTraits.add(t); } } if (!missingTraitIds.isEmpty()) { String msg = missingTraitIds.stream().map(i -> Integer.toString(i)) .collect(Collectors.joining(",")); MsgBox.error(comp, msg, "Missing Trait IDs"); return null; } if (!undecidableTraits.isEmpty()) { String msg = undecidableTraits.stream().map(Trait::getTraitName) .collect(Collectors.joining("\n", "Traits that are neither Plot nor Sub-Plot:\n", "\nDo you want to continue and Exclude samples for those Traits?")); if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(comp, msg, msgTitle, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE)) { return null; } Set<Integer> tmp = undecidableTraits.stream().map(Trait::getTraitId).collect(Collectors.toSet()); excludeTheseTraitIds.addAll(tmp); } } catch (IOException e) { MsgBox.error(comp, "Unable to read samples from database\n" + e.getMessage(), msgTitle); return null; } return excludeTheseTraitIds; }
From source file:ddf.catalog.validation.impl.validator.EnumerationValidator.java
/** * Constructs an {@code EnumerationValidator} with a given set of acceptable values. * * @param values the values accepted by this validator * @throws IllegalArgumentException if {@code values} is null or empty */// ww w. java 2 s . c o m public EnumerationValidator(final Set<String> values) { Preconditions.checkArgument(CollectionUtils.isNotEmpty(values), "Must specify at least one possible enumeration value."); this.values = values.stream().filter(Objects::nonNull).collect(Collectors.toSet()); }
From source file:account.dao.ContactDao.java
private Set<PlaceDTO> createPlaceDTO(Set<Place> places) { Set<PlaceDTO> placesDTO = new HashSet<>(); places.stream().map((place) -> new PlaceDTO(place.getDescription(), place.getTitle(), place.getLongitude(), place.getLatitude())).forEach((placeDTO) -> { placesDTO.add(placeDTO); });//from ww w. ja v a2s . c o m return placesDTO; }
From source file:com.github.horrorho.inflatabledonkey.cloud.AssetPool.java
public Collection<StorageHostChunkList> authorize(HttpClient httpClient) throws IOException { synchronized (lock) { logger.trace("<< authorize()"); Set<Asset> a = assets == null ? assetChunks.items() : assets; Map<ByteString, Asset> fileSignatureToAsset = a.stream() .collect(toMap(u -> ByteString.copyFrom(u.fileSignature().get()), Function.identity())); Collection<StorageHostChunkList> containers = authorize(httpClient, fileSignatureToAsset); logger.trace(">> authorize() - containers: {}", containers.size()); return containers; }//from ww w . ja v a2s.c o m }
From source file:com.wso2.code.quality.matrices.Reviewer.java
/** * Calling the github review API for a selected pull request on its relevant product * * @param githubToken github token for accessing github REST API *//* w ww . java2s . c om*/ public void saveReviewersToList(String githubToken, RestApiCaller restApiCaller) { for (Map.Entry m : mapContainingPRNoAgainstRepoName.entrySet()) { String productLocation = (String) m.getKey(); Set<Integer> prNumbers = (Set<Integer>) m.getValue(); prNumbers.stream().forEach(prNumber -> { setPullRequestReviewAPIUrl(productLocation, prNumber); JSONArray reviewJsonArray = null; try { reviewJsonArray = (JSONArray) restApiCaller.callApi(getPullRequestReviewAPIUrl(), githubToken, false, true); } catch (CodeQualityMatricesException e) { logger.error(e.getMessage(), e.getCause()); System.exit(1); } // for reading the output JSON from above and adding the reviewers to the Set if (reviewJsonArray != null) { readTheReviewOutJSON(reviewJsonArray, productLocation, prNumber); } }); } }
From source file:account.dao.ContactDao.java
private Set<Hobby> createHobbies(Set<HobbyDTO> hobbyDTO) { Set<Hobby> hobbies = new HashSet<>(); hobbyDTO.stream().map((h) -> { Hobby hobby = new Hobby(); hobby.setTitle(h.getTitle());/*from w w w . j a va 2 s . c om*/ hobby.setDescription(h.getDescription()); return hobby; }).forEach((hobby) -> { hobbies.add(hobby); }); return hobbies; }
From source file:be.bittich.quote.controller.impl.DefaultExceptionHandler.java
private Map<String, Map<String, Object>> convertConstraintViolation( Set<ConstraintViolation<?>> constraintViolations) { Map<String, Map<String, Object>> result = newHashMap(); constraintViolations.stream().forEach((constraintViolation) -> { Map<String, Object> violationMap = newHashMap(); violationMap.put("value", constraintViolation.getInvalidValue()); violationMap.put("type", constraintViolation.getRootBeanClass()); violationMap.put("message", constraintViolation.getMessage()); result.put(constraintViolation.getPropertyPath().toString(), violationMap); });/*from ww w . j av a2 s .c om*/ return result; }