List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.iisigroup.cap.mvc.i18n.MessageBundleScriptCreator.java
/** * filter ??/* ww w.j av a 2 s. c o m*/ * * @param filterList * filter list * @return String */ private static String generateFilterReg(Set<String> filterList) { if (filterList == null) { filterList = defaultFilter; } if (!filterList.isEmpty()) { StringBuffer regSb = new StringBuffer("^("); for (Iterator<String> it = filterList.iterator(); it.hasNext();) { regSb.append(it.next()).append(Constants.VALUES_SEPARATOR); } regSb.deleteCharAt(regSb.length() - 1).append(")"); return regSb.toString(); } else { return null; } }
From source file:com.frostwire.vuze.VuzeDownloadFactory.java
private static void setupPartialSelection(DownloadManager dm, Set<String> paths) { DiskManagerFileInfo[] infs = dm.getDiskManagerFileInfoSet().getFiles(); try {//ww w . j a va 2 s . co m dm.getDownloadState().suppressStateSave(true); if (paths == null || paths.isEmpty()) { for (DiskManagerFileInfo inf : infs) { if (inf.isSkipped()) { // I don't want to trigger any internal logic inf.setSkipped(false); } } } else { String savePath = dm.getSaveLocation().getPath(); for (DiskManagerFileInfo inf : infs) { String path = inf.getFile(false).getPath(); path = VuzeDownloadManager.removePrefixPath(savePath, path); inf.setSkipped(!paths.contains(path)); } } } finally { dm.getDownloadState().suppressStateSave(false); } }
From source file:mvm.rya.indexing.accumulo.StatementSerializer.java
/** * Creates a Regular Expression to match serialized statements meeting these constraints. A <code>null</code> or empty parameters imply * no constraint. A <code>null</code> return value implies no constraints. * //from w ww .j a v a 2 s . c o m * @param context * context constraint * @param subject * subject constraint * @param predicates * list of predicate constraints * @return a regular expression that can be used to match serialized statements. A <code>null</code> return value implies no * constraints. */ public static String createStatementRegex(StatementContraints contraints) { Resource context = contraints.getContext(); Resource subject = contraints.getSubject(); Set<URI> predicates = contraints.getPredicates(); if (context == null && subject == null && (predicates == null || predicates.isEmpty())) { return null; } // match on anything but a separator String anyReg = "[^" + SEP + "]*"; // if context is empty, match on any context String contextReg = (context == null) ? anyReg : context.stringValue(); // if subject is empty, match on any subject String subjectReg = (subject == null) ? anyReg : subject.stringValue(); // if the predicates are empty, match on any predicate. Otherwise, "or" the predicates. String predicateReg = ""; if (predicates == null || predicates.isEmpty()) { predicateReg = anyReg; } else { predicateReg = "(" + StringUtils.join(predicates, "|") + ")"; } return "^" + contextReg + SEP + subjectReg + SEP + predicateReg + SEP + ".*"; }
From source file:com.btkelly.gnag.utils.ReportWriter.java
public static boolean writeReportToDirectory(@NotNull final Set<Violation> violations, @NotNull final File directory) { //noinspection ResultOfMethodCallIgnored directory.mkdirs();// w w w.ja v a2 s . c om final StringBuilder builder = new StringBuilder().append(HTML_REPORT_PREFIX); if (violations.isEmpty()) { builder.append(LOCAL_SUCCESS_COMMENT); } else { builder.append(ViolationsFormatter.getHtmlStringForAggregatedComment(violations)); } builder.append(HTML_REPORT_SUFFIX); try { final File htmlReportFile = new File(directory, REPORT_FILE_NAME); FileUtils.write(htmlReportFile, builder.toString()); } catch (final IOException e) { System.out.println("Error writing Gnag local report."); e.printStackTrace(); return false; } copyCssFileToDirectory(directory); return true; }
From source file:io.ecarf.core.cloud.task.processor.reason.phase2.ReasonUtils.java
/** * //from ww w . j a va 2 s .c o m * @param file * @param writer * @param compressed * @return * @throws IOException */ public static int reason(String inFile, String outFile, boolean compressed, Map<Long, Set<Triple>> schemaTerms, Set<Long> productiveTerms) throws IOException { log.info("Reasoning for file: " + inFile + ", memory usage: " + Utils.getMemoryUsageInGB() + "GB"); int inferredTriples = 0; // loop through the instance triples probably stored in a file and generate all the triples matching the schema triples set try (BufferedReader reader = getQueryResultsReader(inFile, compressed); PrintWriter writer = new PrintWriter(new BufferedOutputStream( new GZIPOutputStream(new FileOutputStream(outFile), Constants.GZIP_BUF_SIZE), Constants.GZIP_BUF_SIZE));) { Iterable<CSVRecord> records; if (compressed) { // ignore first row subject,predicate,object records = CSVFormat.DEFAULT.withHeader().withSkipHeaderRecord().parse(reader); } else { records = CSVFormat.DEFAULT.parse(reader); } Long term; for (CSVRecord record : records) { ETriple instanceTriple = ETriple.fromCSV(record.values()); // TODO review for OWL ruleset if (SchemaURIType.RDF_TYPE.id == instanceTriple.getPredicate()) { term = instanceTriple.getObject(); // object } else { term = instanceTriple.getPredicate(); // predicate } Set<Triple> schemaTriples = schemaTerms.get(term); if ((schemaTriples != null) && !schemaTriples.isEmpty()) { productiveTerms.add(term); for (Triple schemaTriple : schemaTriples) { Rule rule = GenericRule.getRule(schemaTriple); Triple inferredTriple = rule.head(schemaTriple, instanceTriple); if (inferredTriple != null) { writer.println(inferredTriple.toCsv()); inferredTriples++; } } } } } return inferredTriples; }
From source file:io.ecarf.core.cloud.task.processor.reason.phase2.ReasonUtils.java
/** * //from ww w . j av a 2 s . c o m * @param file * @param writer * @param compressed * @return * @throws IOException */ public static int reason(String inFile, String outFile, boolean compressed, Map<Long, Set<Triple>> schemaTerms, Set<Long> productiveTerms, DuplicatesBuster duplicatesBuster) throws IOException { log.info("Reasoning for file: " + inFile + ", memory usage: " + Utils.getMemoryUsageInGB() + "GB"); int inferredTriples = 0; // loop through the instance triples probably stored in a file and generate all the triples matching the schema triples set try (BufferedReader reader = getQueryResultsReader(inFile, compressed); PrintWriter writer = new PrintWriter(new BufferedOutputStream( new GZIPOutputStream(new FileOutputStream(outFile), Constants.GZIP_BUF_SIZE), Constants.GZIP_BUF_SIZE));) { Iterable<CSVRecord> records; if (compressed) { // ignore first row subject,predicate,object records = CSVFormat.DEFAULT.withHeader().withSkipHeaderRecord().parse(reader); } else { records = CSVFormat.DEFAULT.parse(reader); } Long term; for (CSVRecord record : records) { ETriple instanceTriple = ETriple.fromCSV(record.values()); // TODO review for OWL ruleset if (SchemaURIType.RDF_TYPE.id == instanceTriple.getPredicate()) { term = instanceTriple.getObject(); // object } else { term = instanceTriple.getPredicate(); // predicate } Set<Triple> schemaTriples = schemaTerms.get(term); if ((schemaTriples != null) && !schemaTriples.isEmpty()) { productiveTerms.add(term); for (Triple schemaTriple : schemaTriples) { Rule rule = GenericRule.getRule(schemaTriple); Triple inferredTriple = rule.head(schemaTriple, instanceTriple); if ((inferredTriple != null) && !duplicatesBuster.isDuplicate(inferredTriple)) { writer.println(inferredTriple.toCsv()); inferredTriples++; } } } } } return inferredTriples; }
From source file:net.andydvorak.intellij.lessc.fs.VirtualFileLocationChange.java
public static int copyCssFiles(@NotNull final VirtualFileCopyEvent virtualFileCopyEvent, @Nullable final LessProfile lessProfile, @NotNull final VfsLocationChangeDialog vfsLocationChangeDialog) throws IOException { final Set<VirtualFileLocationChange> changes = getChanges(lessProfile, virtualFileCopyEvent); if (changes.isEmpty() || !vfsLocationChangeDialog.shouldCopyCssFile(virtualFileCopyEvent)) return 0; for (VirtualFileLocationChange locationChange : changes) { locationChange.copy();/*from ww w . j a va 2 s . co m*/ } return changes.size(); }
From source file:net.andydvorak.intellij.lessc.fs.VirtualFileLocationChange.java
public static int moveCssFiles(@NotNull final VirtualFileMoveEvent virtualFileMoveEvent, @Nullable final LessProfile lessProfile, @NotNull final VfsLocationChangeDialog vfsLocationChangeDialog) throws IOException { final Set<VirtualFileLocationChange> changes = getChanges(lessProfile, virtualFileMoveEvent); if (changes.isEmpty() || !vfsLocationChangeDialog.shouldMoveCssFile(virtualFileMoveEvent)) return 0; for (VirtualFileLocationChange locationChange : changes) { locationChange.move();/*from w w w . j a va2s.co m*/ } return changes.size(); }
From source file:io.cloudslang.maven.compiler.CloudSlangMavenCompiler.java
protected static Set<String> getSourceFilesForSourceRoot(CompilerConfiguration config, String sourceLocation) { Path path = Paths.get(sourceLocation); if (!Files.exists(path)) { return emptySet(); }//from w ww. j a v a 2s. co m DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(sourceLocation); Set<String> includes = config.getIncludes(); if (includes != null && !includes.isEmpty()) { String[] inclStrs = includes.toArray(new String[includes.size()]); scanner.setIncludes(inclStrs); } else { scanner.setIncludes(new String[] { "**/*.sl.yaml", "**/*.sl", "**/*.sl.yml" }); } Set<String> configExcludes = config.getExcludes(); if (configExcludes != null && !configExcludes.isEmpty()) { String[] exclStrs = configExcludes.toArray(new String[configExcludes.size()]); scanner.setExcludes(exclStrs); } else { scanner.setExcludes(new String[] { "**/*prop.sl" }); } scanner.scan(); String[] sourceDirectorySources = scanner.getIncludedFiles(); Set<String> sources = new HashSet<>(); for (String sourceDirectorySource : sourceDirectorySources) { sources.add(new File(sourceLocation, sourceDirectorySource).getPath()); } return sources; }
From source file:com.github.gdfm.shobaidogu.StatsUtils.java
/** * Computes the Jaccard overlap between two sets. * /*from w ww . j a v a2 s . c om*/ * @param s1 * first set. * @param s2 * second set. * @return the Jaccard overlap. */ public static <T> double jaccardOverlap(Set<T> s1, Set<T> s2) { checkNotNull(s1); checkNotNull(s2); if (s1.isEmpty() || s2.isEmpty()) return 0; double intersectSize = Sets.intersection(s1, s2).size(); double unionSize = Sets.union(s1, s2).size(); return intersectSize / unionSize; }