List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.opengamma.bbg.test.BloombergTestUtils.java
/** * Gets an example equity option ticker directly from Bloomberg reference data. * /*from ww w . j a v a 2 s. c om*/ * @return the ticker, not null */ public static String getSampleEquityOptionTicker() { BloombergReferenceDataProvider rdp = new BloombergReferenceDataProvider(getBloombergConnector()); rdp.start(); Set<ExternalId> options = BloombergDataUtils.getOptionChain(rdp, "AAPL US Equity"); assertEquals(false, options.isEmpty()); ExternalId aaplOptionId = options.iterator().next(); rdp.stop(); return aaplOptionId.getValue(); }
From source file:keepinchecker.utility.EmailUtilities.java
private static String generateBodyText(String senderName) throws Exception { StringBuilder bodyText = new StringBuilder(); bodyText.append("Hello,\n\nOn behalf of " + senderName + ", you have received this" + " email with the following data,\n\n"); Set<KeepInCheckerPacket> packets = packetManager.getPackets(); if (!packets.isEmpty()) { StringBuilder packetData = new StringBuilder(); for (KeepInCheckerPacket packet : packets) { packetData.append("\n" + new Date(packet.getTimestamp()).toString() + " " + packet.getTimezone() + " " + packet.getGetValue() + " " + packet.getHostValue() + " " + packet.getRefererValue()); }//w w w .ja v a2 s.c o m bodyText.append(packets.size() + " questionable sites were visted:\n"); bodyText.append(packetData.toString()); } else { bodyText.append("0 questionable sites were visited."); } bodyText.append("\n\nKeep staying accountable!\n\nSincerely,\nKeepInChecker"); return bodyText.toString(); }
From source file:at.molindo.utils.reflect.ClassUtils.java
/** * @return <code>true</code> if <code>cls</code> is assignable to at least * one class in <code>classes</code> *///from w ww.j av a 2s .c o m public static boolean isAssignable(Class<?> cls, Set<Class<?>> classes) { if (cls == null || classes.isEmpty()) { return false; } for (Class<?> c : classes) { if (c.isAssignableFrom(cls)) { return true; } } return false; }
From source file:net.sourceforge.vulcan.spring.jdbc.HistoryQueryBuilder.java
static void buildQuery(String selectClause, BuildOutcomeQueryDto dto, BuilderQuery query) { final Set<String> projectNames = dto.getProjectNames(); if (projectNames == null || projectNames.isEmpty()) { throw new IllegalArgumentException("Must query for at least one project name"); }// w w w. j av a 2 s. com final List<? super Object> params = new ArrayList<Object>(); final StringBuilder sb = new StringBuilder(); sb.append("where project_names.name"); query.declareParameter(new SqlParameter(Types.VARCHAR)); if (projectNames.size() == 1) { sb.append("=?"); params.addAll(projectNames); } else { sb.append(" in (?"); for (int i = 1; i < projectNames.size(); i++) { sb.append(",?"); query.declareParameter(new SqlParameter(Types.VARCHAR)); } sb.append(")"); final List<String> sorted = new ArrayList<String>(projectNames); Collections.sort(sorted); params.addAll(sorted); } if (dto.getMinDate() != null) { sb.append(" and completion_date>=?"); params.add(dto.getMinDate()); query.declareParameter(new SqlParameter(Types.TIMESTAMP)); } if (dto.getMaxDate() != null) { sb.append(" and completion_date<?"); params.add(dto.getMaxDate()); query.declareParameter(new SqlParameter(Types.TIMESTAMP)); } if (dto.getMinBuildNumber() != null) { sb.append(" and build_number>=?"); params.add(dto.getMinBuildNumber()); query.declareParameter(new SqlParameter(Types.INTEGER)); } if (dto.getMaxBuildNumber() != null) { sb.append(" and build_number<=?"); params.add(dto.getMaxBuildNumber()); query.declareParameter(new SqlParameter(Types.INTEGER)); } final Set<Status> statuses = dto.getStatuses(); if (statuses != null && !statuses.isEmpty()) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and status in (?"); for (int i = 1; i < statuses.size(); i++) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(",?"); } sb.append(")"); params.addAll(statuses); } if (dto.getUpdateType() != null) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and update_type=?"); params.add(dto.getUpdateType().name()); } if (isNotBlank(dto.getRequestedBy())) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and requested_by=?"); params.add(dto.getRequestedBy()); } query.setParameterValues(params.toArray()); query.setSql(selectClause + sb.toString()); }
From source file:eu.openanalytics.rsb.config.ConfigurationFactory.java
private static void validateConfiguration(final PersistedConfigurationAdapter pca) throws IOException { if (BooleanUtils.toBoolean(System.getProperty(ConfigurationFactory.class.getName() + ".skipValidation"))) { LOGGER.info("Skipped validation of: " + pca); return;/*from w w w .j ava2 s . c o m*/ } final Set<String> validationErrors = validate(pca); Validate.isTrue(validationErrors.isEmpty(), "Validation error(s):\n" + StringUtils.join(validationErrors, "\n") + "\nfound in configuration:\n" + pca); LOGGER.info("Successfully validated: " + pca.exportAsJson()); }
From source file:com.springer.omelet.driver.DriverUtility.java
/*** * Switching between windows.//from w w w. j a v a 2 s .c o m * * @param driver * @param sString * :Target window Title * @return:True if window switched */ public static boolean switchToWindow(WebDriver driver, String sString) { String currentHandle = driver.getWindowHandle(); Set<String> handles = driver.getWindowHandles(); if (!handles.isEmpty()) { for (String handle : handles) { LOGGER.debug("Switching to other window"); driver.switchTo().window(handle); if (driver.getTitle().contains(sString)) { LOGGER.info("switched to window with title:" + sString); return true; } } driver.switchTo().window(currentHandle); LOGGER.info("Window with title:" + sString + " Not present,Not able to switch"); return false; } else { LOGGER.info("There is only one window handle :" + currentHandle); return false; } }
From source file:zipkin.sparkstreaming.job.ZipkinSparkStreamingConfiguration.java
/** * This assumes everything is in the uber-jar except perhaps the adjusters (which are themselves * self-contained jars).//from w w w. j av a 2s . c om */ static List<String> pathToJars(Class<?> entryPoint, List<Adjuster> adjusters) { Set<String> jars = new LinkedHashSet<>(); jars.add(pathToJar(entryPoint)); for (Adjuster adjuster : adjusters) { jars.add(pathToJar(adjuster.getClass())); } jars.remove(null); return jars.isEmpty() ? null : new ArrayList<>(jars); }
From source file:br.com.suricattus.surispring.spring.security.util.SecurityUtil.java
/** * Method that checks if the user holds <b>any</b> of the given roles. * Returns <code>true, when the first match is found, <code>false</code> if * no match is found and also <code>false</code> if no roles are given * /*from w w w. ja v a 2s .c o m*/ * @param grantedRoles a comma seperated list of roles * @return true if any of the given roles are granted to the current user, false otherwise */ public static boolean hasAnyRole(final String grantedRoles) { Set<String> parsedAuthorities = parseAuthorities(grantedRoles); if (parsedAuthorities.isEmpty()) return false; Set<String> userAuthorities = getUserAuthorities(); for (String ga : parsedAuthorities) { if (userAuthorities.contains(ga)) return true; } return false; }
From source file:net.sf.jasperreports.samples.wizards.SampleNewWizard.java
private static void addSourceFolders(Set<String> cpaths, IJavaProject project, IProgressMonitor monitor) { if (cpaths.isEmpty()) return;/* w w w .j ava 2 s .com*/ try { IClasspathEntry[] cpentries = project.getRawClasspath(); IClasspathEntry[] newEntries = new IClasspathEntry[cpentries.length + cpaths.size()]; System.arraycopy(cpentries, 0, newEntries, 0, cpentries.length); int i = cpentries.length; for (String cp : cpaths) { newEntries[i] = JavaCore.newSourceEntry(project.getProject().getFile(cp).getFullPath()); i++; if (monitor.isCanceled()) return; } project.setRawClasspath(newEntries, monitor); } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:net.sf.jasperreports.samples.wizards.SampleNewWizard.java
private static void addLibraries(Set<String> lpaths, IJavaProject project, IProgressMonitor monitor) { if (lpaths.isEmpty()) return;/*w w w.j ava 2 s . co m*/ try { IClasspathEntry[] cpentries = project.getRawClasspath(); IClasspathEntry[] newEntries = new IClasspathEntry[cpentries.length + lpaths.size()]; System.arraycopy(cpentries, 0, newEntries, 0, cpentries.length); int i = cpentries.length; for (String cp : lpaths) { newEntries[i] = JavaCore.newLibraryEntry(project.getProject().getFile(cp).getFullPath(), null, null); i++; if (monitor.isCanceled()) return; } project.setRawClasspath(newEntries, monitor); } catch (JavaModelException e) { e.printStackTrace(); } }