private LinkedHashSet<RandomizerRegistry> setupRandomizerRegistries() { LinkedHashSet<RandomizerRegistry> registries = new LinkedHashSet<>(); registries.add(customRandomizerRegistry); registries.add(exclusionRandomizerRegistry); registries.addAll(userRegistries); registries.addAll(loadRegistries()); registries.forEach(registry -> registry.init(parameters)); return registries; }
private static void addSortedBundle(Bundle bundle, Map<String, Bundle> bundles, LinkedHashSet<Bundle> sortedBundles, LinkedHashSet<String> dependencyStack) { String name = bundle.plugin.getName(); if (dependencyStack.contains(name)) { StringBuilder msg = new StringBuilder("Cycle found in plugin dependencies: "); dependencyStack.forEach(s -> { msg.append(s); msg.append(" -> "); }); msg.append(name); throw new IllegalStateException(msg.toString()); } if (sortedBundles.contains(bundle)) { // already added this plugin, via a dependency return; } dependencyStack.add(name); for (String dependency : bundle.plugin.getExtendedPlugins()) { Bundle depBundle = bundles.get(dependency); if (depBundle == null) { throw new IllegalArgumentException("Missing plugin [" + dependency + "], dependency of [" + name + "]"); } addSortedBundle(depBundle, bundles, sortedBundles, dependencyStack); assert sortedBundles.contains(depBundle); } dependencyStack.remove(name); sortedBundles.add(bundle); }
private static void removeZemberekDictionaryWordsFromList(Path input, Path out) throws IOException { LinkedHashSet<String> list = new LinkedHashSet<>( Files.readAllLines(input, StandardCharsets.UTF_8)); System.out.println("Total amount of lines = " + list.size()); TurkishMorphology morphology = TurkishMorphology.create( RootLexicon.builder().addTextDictionaryResources( "tr/master-dictionary.dict", "tr/non-tdk.dict", "tr/proper.dict", "tr/proper-from-corpus.dict", "tr/abbreviations.dict" ).build()); List<String> toRemove = new ArrayList<>(); for (DictionaryItem item : morphology.getLexicon()) { if (list.contains(item.lemma)) { toRemove.add(item.lemma); } } System.out.println("Total amount to remove = " + toRemove.size()); list.removeAll(toRemove); try (PrintWriter pw = new PrintWriter(out.toFile(), "utf-8")) { list.forEach(pw::println); } }
protected void executeFunctionsUponCommit() { try { uponCommitFunctions.forEach(TransactionFunction::execute); } finally { uponCommitFunctions.clear(); } } }
@Override protected void run() throws Exception { // copy keys to new set to prevent concurrent modification exception. new LinkedHashSet<>(ViewMap.this.unresolved.keySet()).forEach(ViewMap.this::get); } };
public PrefixToSystemPropertySubstituter(final List<String> propertyNames) { new LinkedHashSet<>(propertyNames).forEach(property -> this.converters.add(string -> { final String value = System.getProperty(property); if (StringUtilities.isNullOrTrimmedEmpty(value) || !string.startsWith(value)) { return string; } return "$SYSTEM{" + property + "}" + string.substring(value.length(), string.length()); //$NON-NLS-1$ //$NON-NLS-2$ })); }
public StringToSystemPropertiesSubstituter(final List<String> propertyNames) { new LinkedHashSet<>(propertyNames).forEach(property -> this.converters.add(string -> { final String value = System.getProperty(property); if (StringUtilities.isNullOrTrimmedEmpty(value) || !string.startsWith(value)) { return string; } return "$SYSTEM{" + property + "}" + string.substring(value.length(), string.length()); //$NON-NLS-1$ //$NON-NLS-2$ })); }
public PrefixToSystemPropertySubstituter(final List<String> propertyNames) { new LinkedHashSet<>(propertyNames).forEach(property -> this.converters.add(string -> { final String value = System.getProperty(property); if (StringUtilities.isNullOrTrimmedEmpty(value) || !string.startsWith(value)) { return string; } return "$SYSTEM{" + property + "}" + string.substring(value.length(), string.length()); //$NON-NLS-1$ //$NON-NLS-2$ })); }
public StringToSystemPropertiesSubstituter(final List<String> propertyNames) { new LinkedHashSet<>(propertyNames).forEach(property -> this.converters.add(string -> { final String value = System.getProperty(property); if (StringUtilities.isNullOrTrimmedEmpty(value) || !string.startsWith(value)) { return string; } return "$SYSTEM{" + property + "}" + string.substring(value.length(), string.length()); //$NON-NLS-1$ //$NON-NLS-2$ })); }
protected GroupQuery(TableQuery.Group groupQuery, QueryHook queryHook) throws QueryException { queries = new ArrayList<>(groupQuery.queries.size()); groupQuery.queries.forEach(n -> this.queries.add(Query.prepare(n, queryHook))); }
protected LinkedHashSet<String> getSampleNamesInFile(Integer fileId) { LinkedHashSet<String> samples = new LinkedHashSet<>(); getSamplesInFile(fileId).forEach(sampleId -> { samples.add(studyConfiguration.getSampleIds().inverse().get(sampleId)); }); return samples; }
public static PathBlock deduplicate(PathBlock pattern) { PathBlock result = new PathBlock(); new LinkedHashSet<>(pattern.getList()).forEach(result::add); return result; }
@Override protected void configure() { bind(GovernatorFeatureSet.class).toInstance(featureSet); bind(LifecycleManager.class).toInstance(manager); Multibinder<String> profilesBinder = Multibinder.newSetBinder(binder(), Key.get(String.class, Profiles.class)).permitDuplicates(); profiles.forEach(profile -> profilesBinder.addBinding().toInstance(profile)); bind(String[].class).annotatedWith(Arguments.class).toInstance(args); requestInjection(LifecycleInjectorCreator.this); } },
@Override public void accept(Visitor visitor) { Runnable remove = this::removeFromHierarchy; visitor.visit(this, remove); new LinkedHashSet<>(getChildren()).forEach(child -> child.accept(visitor)); }
/** * Accept a {@link Visitor} to the subtree starting with this descriptor. * * @param visitor the {@code Visitor} to accept; never {@code null} */ default void accept(Visitor visitor) { Preconditions.notNull(visitor, "Visitor must not be null"); visitor.visit(this); // Create a copy of the set in order to avoid a ConcurrentModificationException new LinkedHashSet<>(this.getChildren()).forEach(child -> child.accept(visitor)); }
private void renderSWRLRules() { List<SWRLRule> ruleAxioms = asList(ontology.axioms(SWRL_RULE).sorted()); createGraph(ruleAxioms.stream()); if (!ruleAxioms.isEmpty()) { writeBanner(RULES_BANNER_TEXT); SWRLVariableExtractor variableExtractor = new SWRLVariableExtractor(); ruleAxioms.forEach(rule -> rule.accept(variableExtractor)); variableExtractor.getVariables() .forEach(var -> render(new RDFResourceIRI(var.getIRI()), true)); renderAnonRoots(); } }
private void renderSWRLRules() { List<SWRLRule> ruleAxioms = asList(ontology.axioms(SWRL_RULE).sorted()); createGraph(ruleAxioms.stream()); if (!ruleAxioms.isEmpty()) { writeBanner(RULES_BANNER_TEXT); SWRLVariableExtractor variableExtractor = new SWRLVariableExtractor(); ruleAxioms.forEach(rule -> rule.accept(variableExtractor)); variableExtractor.getVariables() .forEach(var -> render(new RDFResourceIRI(var.getIRI()), true)); renderAnonRoots(); } }
private void renderSWRLRules() { List<SWRLRule> ruleAxioms = asList(ontology.axioms(SWRL_RULE).sorted()); createGraph(ruleAxioms.stream()); if (!ruleAxioms.isEmpty()) { writeBanner(RULES_BANNER_TEXT); SWRLVariableExtractor variableExtractor = new SWRLVariableExtractor(); ruleAxioms.forEach(rule -> rule.accept(variableExtractor)); variableExtractor.getVariables() .forEach(var -> render(new RDFResourceIRI(var.getIRI()), true)); renderAnonRoots(); } }
public void checkSampleData(Variant variant, StudyConfiguration studyConfiguration, Integer fileId, Function<Integer, String> valueProvider, String field) { assertTrue(studyConfiguration.getFileIds().values().contains(fileId)); studyConfiguration.getSamplesInFiles().get(fileId).forEach((sampleId) -> { String sampleName = studyConfiguration.getSampleIds().inverse().get(sampleId); StudyEntry study = variant.getStudy(studyConfiguration.getStudyName()); assertTrue(study.getSamplesName().contains(sampleName)); assertEquals("Variant=" + variant + " StudyId=" + studyConfiguration.getStudyId() + " FileId=" + fileId + " Field=" + field + " Sample=" + sampleName + " (" + sampleId + ")\n"+variant.toJson(), valueProvider.apply(sampleId), study.getSampleData(sampleName, field)); }); }