List of usage examples for java.util.stream Collectors toSet
public static <T> Collector<T, ?, Set<T>> toSet()
From source file:com.vsct.dt.strowgr.admin.gui.mapping.json.EntryPointBackendMappingJson.java
public EntryPointBackendMappingJson(EntryPointBackend b) { this(b.getId(), b.getServers().stream().map(EntryPointBackendServerMappingJson::new).collect(Collectors.toSet()), b.getContext());//w w w . j a v a2s . com }
From source file:com.netflix.metacat.common.server.properties.PropertyUtils.java
/** * Convert a delimited string into a Set of {@code QualifiedName}. * * @param names The list of names to split * @param delimiter The delimiter to use for splitting * @return The list of qualified names/*from ww w .j ava 2s. c om*/ */ static Set<QualifiedName> delimitedStringsToQualifiedNamesSet(@Nonnull @NonNull final String names, final char delimiter) { if (StringUtils.isNotBlank(names)) { return Splitter.on(delimiter).omitEmptyStrings().splitToList(names).stream() .map(QualifiedName::fromString).collect(Collectors.toSet()); } else { return Sets.newHashSet(); } }
From source file:com.samsung.sjs.theorysolver.TheorySolverTest.java
/** * This tests the {@link TheorySolver} using a theory which has a random set of * blacklisted objects. We verify that the TheorySolver always finds the entire * set of non-blacklisted objects./*w ww . j a v a 2s . c o m*/ */ @Test public void testBasics() { List<Object> all = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h"); for (int i = 0; i < 100; ++i) { Random r = new Random(SEED + i); Collection<Object> truthy = all.stream().filter(x -> r.nextBoolean()).collect(Collectors.toSet()); Theory<Object, Void> theory = positive -> { Collection<Object> bad = positive.stream().filter(x -> !truthy.contains(x)) .collect(Collectors.toSet()); if (bad.size() > 0) { // Construct a random, nonempty unsat core. Collection<Object> unsat = new HashSet<>(); unsat.add(bad.iterator().next()); bad.stream().filter(x -> r.nextBoolean()).forEach(unsat::add); return Either.right(unsat); } else { return Either.left(null); } }; Pair<Void, Collection<Object>> result = TheorySolver.solve(theory, new SatFixingSetFinder<>(new Sat4J()), Collections.emptyList(), all); Assert.assertEquals(all.size() - truthy.size(), result.getRight().size()); Assert.assertEquals(truthy, all.stream().filter(x -> !result.getRight().contains(x)).collect(Collectors.toSet())); } }
From source file:net.fabricmc.loader.launch.MixinLoader.java
public Set<String> getCommonMixinConfigs() { return mods.stream().map(ModContainer::getInfo).map(ModInfo::getMixins).map(ModInfo.Mixins::getCommon) .filter(s -> s != null && !s.isEmpty()).collect(Collectors.toSet()); }
From source file:com.vsct.dt.strowgr.admin.gui.mapping.json.UpdatedEntryPointMappingJson.java
@JsonCreator public UpdatedEntryPointMappingJson(@JsonProperty("hapUser") String hapUser, @JsonProperty("hapVersion") String hapVersion, @JsonProperty("bindingId") int bindingId, @JsonProperty("context") Map<String, String> context, @JsonProperty("frontends") Set<UpdatedEntryPointFrontendMappingJson> frontends, @JsonProperty("backends") Set<UpdatedEntryPointBackendMappingJson> backends) { super(bindingId, hapUser, context, frontends.stream().map(identity()).collect(Collectors.toSet()), backends.stream().map(identity()).collect(Collectors.toSet()), hapVersion); }
From source file:com.vsct.dt.strowgr.admin.repository.consul.mapping.json.EntryPointBackendMappingJson.java
public EntryPointBackendMappingJson(EntryPointBackend entryPointBackend) { this(entryPointBackend.getId(), entryPointBackend.getServers().stream() .map(EntryPointBackendServerMappingJson::new).collect(Collectors.toSet()), entryPointBackend.getContext()); }
From source file:nu.yona.server.subscriptions.service.WhiteListedNumberService.java
@Transactional public Set<String> getAllWhiteListedNumbers() { return StreamSupport.stream(WhiteListedNumber.getRepository().findAll().spliterator(), false) .map(WhiteListedNumber::getMobileNumber).collect(Collectors.toSet()); }
From source file:com.vsct.dt.strowgr.admin.gui.mapping.json.EntryPointMappingJson.java
@JsonCreator public EntryPointMappingJson(@JsonProperty("haproxy") String haproxy, @JsonProperty("hapUser") String hapUser, @JsonProperty("hapVersion") String hapVersion, @JsonProperty("bindingId") int bindingId, @JsonProperty("frontends") Set<EntryPointFrontendMappingJson> frontends, @JsonProperty("backends") Set<EntryPointBackendMappingJson> backends, @JsonProperty("context") Map<String, String> context) { super(haproxy, hapUser, hapVersion, bindingId, frontends.stream().map(identity()).collect(Collectors.toSet()), backends.stream().map(identity()).collect(Collectors.toSet()), context); }
From source file:io.gravitee.repository.redis.management.RedisPlanRepository.java
@Override public Set<Plan> findByApi(String api) throws TechnicalException { return planRedisRepository.findByApi(api).stream().map(this::convert).collect(Collectors.toSet()); }
From source file:se.inera.intyg.intygstjanst.web.integration.stub.SendMessageToCareStorage.java
public Set<MessageKey> getMessagesIdsForLogicalAddress(String logicalAddress) { return messages.keySet().stream().filter(k -> k.logicalAddress.equals(logicalAddress)) .collect(Collectors.toSet()); }