List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java
/** * Match by fieldConfigBean labels//from w w w. j a va 2 s . co m * @param excelColumnNames * @param fieldConfigsMap * @param previousMappings */ private static void addMatch(Set<String> excelColumnNames, Map<String, TFieldConfigBean> fieldConfigsMap, Map<String, Integer> previousMappings) { if (!excelColumnNames.isEmpty()) { Iterator<String> itrExcelColumNames = excelColumnNames.iterator(); while (itrExcelColumNames.hasNext()) { String columName = itrExcelColumNames.next(); if (fieldConfigsMap.containsKey(columName)) { TFieldConfigBean fieldConfigBean = fieldConfigsMap.get(columName); if (fieldConfigBean != null) { previousMappings.put(columName, fieldConfigBean.getObjectID()); itrExcelColumNames.remove(); } } } } }
From source file:com.gcm.client.GcmHelper.java
/** * A debugging method which helps print the entire bundle * * @param data instance of the {@link Bundle} which needs to be printed */// w w w . j a va2 s. c o m static void printBundle(Bundle data) { try { if (null == data) { Log.d(TAG, "printBundle:No extras to log"); return; } Set<String> ketSet = data.keySet(); if (null == ketSet || ketSet.isEmpty()) return; Log.d(TAG, "------Start of bundle extras------"); for (String key : ketSet) { Object obj = data.get(key); if (null != obj) { Log.d(TAG, "[ " + key + " = " + obj.toString() + " ]"); } } Log.d(TAG, "-------End of bundle extras-------"); } catch (Exception e) { if (DEBUG_ENABLED) Log.e(TAG, "printBundle", e); } }
From source file:edu.wpi.checksims.ChecksimsCommandLine.java
/** * Parse basic CLI flags and produce a ChecksimsConfig. * * @param cli Parsed command line//ww w . java 2 s. c o m * @return Config derived from parsed CLI * @throws ChecksimsException Thrown on invalid user input or internal error */ static ChecksimsConfig parseBaseFlags(CommandLine cli) throws ChecksimsException { checkNotNull(cli); // If we don't have a logger, set one up if (logs == null) { logs = LoggerFactory.getLogger(ChecksimsCommandLine.class); } // Create a base config to work from ChecksimsConfig config = new ChecksimsConfig(); // Parse plagiarism detection algorithm if (cli.hasOption("a")) { config = config.setAlgorithm( AlgorithmRegistry.getInstance().getImplementationInstance(cli.getOptionValue("a"))); config = config.setTokenization(config.getAlgorithm().getDefaultTokenType()); } // Parse tokenization if (cli.hasOption("t")) { config = config.setTokenization(TokenType.fromString(cli.getOptionValue("t"))); } // Parse file output value boolean outputToFile = cli.hasOption("f"); if (outputToFile) { File outputFile = new File(cli.getOptionValue("f")); OutputPrinter filePrinter = new OutputAsFilePrinter(outputFile); config = config.setOutputMethod(filePrinter); logs.info("Saving output to file " + outputFile.getName()); } // Parse number of threads to use if (cli.hasOption("j")) { int numThreads = Integer.parseInt(cli.getOptionValue("j")); if (numThreads < 1) { throw new ChecksimsException("Thread count must be positive!"); } config = config.setNumThreads(numThreads); } // Parse preprocessors // Ensure no duplicates if (cli.hasOption("p")) { List<SubmissionPreprocessor> preprocessors = SetUniqueList.setUniqueList(new ArrayList<>()); String[] splitPreprocessors = cli.getOptionValue("p").split(","); for (String s : splitPreprocessors) { SubmissionPreprocessor p = PreprocessorRegistry.getInstance().getImplementationInstance(s); preprocessors.add(p); } config = config.setPreprocessors(preprocessors); } // Parse output strategies // Ensure no duplicates if (cli.hasOption("o")) { String[] desiredStrategies = cli.getOptionValue("o").split(","); Set<String> deduplicatedStrategies = new HashSet<>(Arrays.asList(desiredStrategies)); if (deduplicatedStrategies.isEmpty()) { throw new ChecksimsException("Error: did not obtain a valid output strategy!"); } // Convert to MatrixPrinters List<MatrixPrinter> printers = new ArrayList<>(); for (String name : deduplicatedStrategies) { printers.add(MatrixPrinterRegistry.getInstance().getImplementationInstance(name)); } config = config.setOutputPrinters(printers); } return config; }
From source file:gov.nih.nci.caintegrator.common.QueryUtil.java
private static ReporterTypeEnum getReporterTypeFromQueries(Set<Query> queries, ResultTypeEnum resultType) throws InvalidCriterionException { if (queries == null || queries.isEmpty()) { return ResultTypeEnum.GENE_EXPRESSION.equals(resultType) ? ReporterTypeEnum.GENE_EXPRESSION_PROBE_SET : ReporterTypeEnum.DNA_ANALYSIS_REPORTER; }/*from w w w. j a va 2 s .c o m*/ ReporterTypeEnum reporterType = null; for (Query query : queries) { if (reporterType == null) { reporterType = query.getReporterType(); } else { if (reporterType != query.getReporterType()) { throw new InvalidCriterionException( "Trying to create a combined genomic query where two of the " + "queries have different reporter types."); } } } return reporterType; }
From source file:edu.umass.cs.reconfiguration.reconfigurationutils.ConsistentReconfigurableNodeConfig.java
/** * A utility method to split a collection of names into batches wherein * names in each batch map to the same reconfigurator group. The set of * reconfigurators can be specified either as a NodeIDType or a String set * but not as an InetSocketAddress set (unless NodeIDType is * InetSocketAddress).//from w ww.j a va 2 s.c om * * @param names * @param reconfigurators * @return A set of batches of names wherein names in each batch map to the * same reconfigurator group. */ public static Collection<Set<String>> splitIntoRCGroups(Set<String> names, Set<?> reconfigurators) { if (reconfigurators.isEmpty()) throw new RuntimeException("A nonempty set of reconfigurators must be specified."); ConsistentHashing<?> ch = new ConsistentHashing<>(reconfigurators); Map<String, Set<String>> batches = new HashMap<String, Set<String>>(); for (String name : names) { String rc = ch.getNode(name).toString(); if (!batches.containsKey(rc)) batches.put(rc, new HashSet<String>()); batches.get(rc).add(name); // no need to put again } return batches.values(); }
From source file:edu.uci.ics.jung.utils.GraphUtils.java
/** * Given a set of vertices, creates a new <tt>Graph</tt> that contains * all of those vertices, and all the edges that connect them. Uses the * <tt>{@link edu.uci.ics.jung.graph.filters.UnassembledGraph UnassembledGraph}</tt> * mechanism to create the graph.//from w w w . jav a 2s .c o m * * @param s * A set of <tt>Vertex</tt> s that want to be a part of a new * Graph * @return A graph, created with <tt>{@link edu.uci.ics.jung.graph.Graph#newInstance Graph.newInstance}</tt>, * containing vertices equivalent to (and that are copies of!) all * the vertices in the input set. Note that if the input is an * empty set, <tt>null</tt> is returned. */ public static Graph vertexSetToGraph(Set s) { if (s.isEmpty()) return null; Vertex v = (Vertex) s.iterator().next(); Graph g = (Graph) v.getGraph(); return new UnassembledGraph("vertexSetToGraph", s, g.getEdges(), g).assemble(); }
From source file:com.anyi.gp.license.RegisterTools.java
public static String getKeyString(String encodeType) { StringBuffer sb = new StringBuffer(); sb.append("Host[" + getHostName() + "];"); sb.append("Ip["); Set entrySet = getInetAddresses().entrySet(); java.util.Map.Entry entry;// www. j a v a 2s . c o m for (Iterator iterator = entrySet.iterator(); iterator.hasNext(); sb.append(entry.getValue() + ",")) { entry = (java.util.Map.Entry) iterator.next(); } if (!entrySet.isEmpty()) { sb = new StringBuffer(sb.substring(0, sb.length() - 1)); } sb.append("];"); sb.append("ENCODETYPE[" + encodeType + "];"); sb.append("Mac["); List macList = getMacAddresses(); for (int i = 0; i < macList.size(); i++) { if (i != 0) { sb.append(","); } sb.append(macList.get(i)); } sb.append("]"); return sb.toString(); }
From source file:com.netflix.genie.web.data.repositories.jpa.specifications.JpaCommandSpecs.java
/** * Get all the clusters given the specified parameters. * * @param applicationId The id of the application that is registered with these commands * @param statuses The status of the commands * @return The specification/* w w w. ja va 2 s . com*/ */ public static Specification<CommandEntity> findCommandsForApplication(final String applicationId, @Nullable final Set<CommandStatus> statuses) { return (final Root<CommandEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> { final List<Predicate> predicates = new ArrayList<>(); final Join<CommandEntity, ApplicationEntity> application = root.join(CommandEntity_.applications); predicates.add(cb.equal(application.get(ApplicationEntity_.uniqueId), applicationId)); if (statuses != null && !statuses.isEmpty()) { predicates.add( cb.or(statuses.stream().map(status -> cb.equal(root.get(CommandEntity_.status), status)) .toArray(Predicate[]::new))); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }; }
From source file:com.delicious.deliciousfeeds4J.DeliciousUtil.java
public static UrlInfo deserializeUrlInfoFromJson(String json) throws Exception { logger.debug("Trying to deserialize JSON to UrlInfos..."); logger.trace("Deserializing JSON: " + json); //Check if empty or null if (json == null || json.isEmpty()) { logger.debug("Nothing to deserialize. JSON-string was empty!"); return null; }//ww w .ja va 2s . c o m //Actually deserialize final Set<UrlInfo> urlInfos = ((Set<UrlInfo>) objectMapper.readValue(json, new TypeReference<Set<UrlInfo>>() { })); if (urlInfos == null || urlInfos.isEmpty()) { logger.debug("No UrlInfos found. Collection was empty."); return null; } return urlInfos.iterator().next(); }
From source file:com.reactivetechnologies.platform.datagrid.util.EntityFinder.java
/** * //from w w w. j a va2 s. c o m * @param basePkg * @return * @throws ClassNotFoundException */ public static Collection<Class<?>> findEntityClasses(String basePkg) throws ClassNotFoundException { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider( false); provider.addIncludeFilter(new TypeFilter() { @Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { AnnotationMetadata aMeta = metadataReader.getAnnotationMetadata(); return aMeta.hasAnnotation(HzMapConfig.class.getName()); } }); //consider the finder class to be in the root package Set<BeanDefinition> beans = null; try { beans = provider.findCandidateComponents(StringUtils.hasText(basePkg) ? basePkg : EntityFinder.class.getName().substring(0, EntityFinder.class.getName().lastIndexOf("."))); } catch (Exception e) { throw new IllegalArgumentException("Unable to scan for entities under base package", e); } Set<Class<?>> classes = new HashSet<>(); if (beans != null && !beans.isEmpty()) { classes = new HashSet<>(beans.size()); for (BeanDefinition bd : beans) { classes.add(Class.forName(bd.getBeanClassName())); } } else { log.warn(">> Did not find any key value entities under the given base scan package [" + basePkg + "]"); } return classes; }