public static List<String> topicsListsMinus(List<String> list1, List<String> list2) { HashSet<String> s1 = new HashSet<>(list1); s1.removeAll(list2); return s1.stream().collect(Collectors.toList()); }
private Set<E> getDiff(Set<? extends E> set1, Set<? extends E> set2) { HashSet<E> hashSet = new HashSet<>(); hashSet.addAll(set1); hashSet.addAll(set2); return hashSet.stream().filter(new Predicate<E>() { @Override public boolean test(E e) { return set1.contains(e) && !set2.contains(e); } }).collect(Collectors.toSet()); } };
private Set<E> getDiff(Set<? extends E> set1, Set<? extends E> set2) { HashSet<E> hashSet = new HashSet<>(); hashSet.addAll(set1); hashSet.addAll(set2); return hashSet.stream().filter(new Predicate<E>() { @Override public boolean test(E e) { return set1.contains(e) && !set2.contains(e); } }).collect(Collectors.toSet()); } };
private static List<String> sanitizeScmAccounts(@Nullable List<String> scmAccounts) { if (scmAccounts != null) { return new HashSet<>(scmAccounts).stream() .map(Strings::emptyToNull) .filter(Objects::nonNull) .sorted(String::compareToIgnoreCase) .collect(toList(scmAccounts.size())); } return Collections.emptyList(); }
@Override @Deprecated public Set<OfflinePlayer> getPlayers() throws IllegalStateException { Set<OfflinePlayer> playerObjectSet = new HashSet<>(players.size()); playerObjectSet.addAll( players.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toList())); return playerObjectSet; }
private void warnAboutDeprecatedConnectors( @Nonnull Map<String,String> connectorSettings, @Nonnull Consumer<String> warningConsumer ) { final HashSet<String> nonDefaultConnectors = new HashSet<>(); connectorSettings.entrySet().stream() .map( Entry::getKey ) .filter( settingKey -> { String name = settingKey.split( "\\." )[2]; return isDeprecatedConnectorName( name ); } ) .forEach( nonDefaultConnectors::add ); if ( !nonDefaultConnectors.isEmpty() ) { warningConsumer.accept( format( DEPRECATED_CONNECTOR_MSG, nonDefaultConnectors.stream() .sorted() .map( s -> format( "> %s%n", s ) ) .collect( joining() ) ) ); } }
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) { Set<Material> materials = transparent.stream().map(Material::getMaterial) .collect(Collectors.toSet()); return getLineOfSight(materials, maxDistance, maxLength); }
@GenerateMicroBenchmark public int serialHashSet() { return hashSet.stream().mapToInt(i -> i).sum(); }
protected void trySyncUserRole(final String userId, final List<String> roleIdList) { new HashSet<>(roleIdList).stream() .map(roleId -> { UserRoleEntity roleEntity = entityFactory.newInstance(UserRoleEntity.class); roleEntity.setRoleId(roleId); roleEntity.setUserId(userId); return roleEntity; }) .forEach(userRoleDao::insert); }
public List<URL> getListeners() { return Arrays.stream(server.getConnectors()) .filter(connector -> connector instanceof ServerConnector) .map(ServerConnector.class::cast) .map(connector -> { try { final String protocol = new HashSet<>(connector.getProtocols()) .stream() .map(String::toLowerCase) .anyMatch(s -> s.equals("ssl")) ? "https" : "http"; final int localPort = connector.getLocalPort(); return new URL(protocol, "localhost", localPort, ""); } catch (final Exception e) { throw new RuntimeException("Malformed listener", e); } }) .collect(Collectors.toList()); }
int foo(int y) { MathOperation case1 = (x) -> x + x; MathOperation case2 = (x) -> { return x + x; }; MathOperation case3 = (int x) -> x + x; MathOperation case4 = x -> x + x; MathOperation2 case5 = (a, b) -> a + b; MathOperation2 case6 = (int a, int b) -> a + b; MathOperation2 case7 = (int a, int b) -> { return a + b; }; Objects.requireNonNull(null, () -> "message"); call((x) -> x + x); new HashSet<Integer>().stream().filter((filter) -> filter > 0); return y; }
new HashSet<>(props.keySet()).stream().filter(key -> !key.toString().startsWith("openie.")).forEach(key -> props.setProperty("openie." + key.toString(), props.getProperty(key.toString())));
e.getValue().setLocation("<html>" + locs.stream().collect(Collectors.joining("<br>")) + "</html>");
new HashSet<>(properties).stream() .filter(prop -> UNDOCUMENTED_PROPERTIES.contains(clss.getSimpleName() + "." + prop)) .forEach(properties::remove);
/** * Returns a list whose elements are instances of all the {@link GremlinScriptEngineFactory} classes * found by the discovery mechanism. * * @return List of all discovered {@link GremlinScriptEngineFactory} objects. */ @Override public List<GremlinScriptEngineFactory> getEngineFactories() { final List<GremlinScriptEngineFactory> res = new ArrayList<>(engineSpis.size()); res.addAll(engineSpis.stream().collect(Collectors.toList())); return Collections.unmodifiableList(res); }
/** * Generates a new LmVocabulary instance that contains words that exist in both `v1` and `v2` * There is no guarantee that new vocabulary indexes will match with v1 or v2. */ public static LmVocabulary intersect(LmVocabulary v1, LmVocabulary v2) { HashSet<String> ls = new HashSet<>(v1.vocabulary); List<String> intersection = new ArrayList<>(Math.min(v1.size(), v2.size())); intersection.addAll(new HashSet<>(v2.vocabulary) .stream() .filter(ls::contains) .collect(Collectors.toList())); return new LmVocabulary(intersection); }
@Override public void addSummarizers(String tableName, SummarizerConfiguration... newConfigs) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { HashSet<SummarizerConfiguration> currentConfigs = new HashSet<>( SummarizerConfiguration.fromTableProperties(getProperties(tableName))); HashSet<SummarizerConfiguration> newConfigSet = new HashSet<>(Arrays.asList(newConfigs)); newConfigSet.removeIf(currentConfigs::contains); Set<String> newIds = newConfigSet.stream().map(SummarizerConfiguration::getPropertyId) .collect(toSet()); for (SummarizerConfiguration csc : currentConfigs) { if (newIds.contains(csc.getPropertyId())) { throw new IllegalArgumentException("Summarizer property id is in use by " + csc); } } Set<Entry<String,String>> es = SummarizerConfiguration.toTableProperties(newConfigSet) .entrySet(); for (Entry<String,String> entry : es) { setProperty(tableName, entry.getKey(), entry.getValue()); } }
missingPartitions = new HashSet<>(); String values = set.stream().map(item -> format("('%s')", item)).collect(Collectors.joining(", ")); ResultSet resultSet = statement.executeQuery(format("select part from (VALUES%s) data (part) where part not in (\n" + "\tselect substring(cchild.relname, %d) from pg_catalog.pg_class c \n" +
private Set<E> getDiff(Set<? extends E> set1, Set<? extends E> set2) { HashSet<E> hashSet = new HashSet<>(); hashSet.addAll(set1); hashSet.addAll(set2); return hashSet.stream().filter(new Predicate<E>() { @Override public boolean test(E e) { return set1.contains(e) && !set2.contains(e); } }).collect(Collectors.toSet()); } };
@Property(trials = DEFAULT_TRIALS) public void containsAfterInsert(@Size(min = 0, max = 0) final CT emptySet, @Size(min = 1, max = MAX_SIZE) final java.util.HashSet<T> inputValues) { CT testSet = emptySet; for (T newValue : inputValues) { final CT tmpSet = (CT) testSet.__insert(newValue); testSet = tmpSet; } boolean containsInsertedValues = inputValues.stream().allMatch(testSet::contains); assertTrue("Must contain all inserted values.", containsInsertedValues); }