List of usage examples for java.util Set size
int size();
From source file:com.intuit.autumn.web.WebServices.java
/** * Http services configuration utility./* www .j a v a2 s . c o m*/ * * @return collection of enabled http services. */ public static Set<Class<? extends Service>> getEnabledWebServices() { LOGGER.debug("getting enabled web services"); Properties properties = create(PROPERTY_NAME, WebModule.class); Set<Class<? extends Service>> webServices = newHashSet(); loadIfEnabled(properties, webServices, "application.http.enabled"); loadIfEnabled(properties, webServices, "application.https.enabled"); LOGGER.debug("got enabled web services count: {}", webServices.size()); return webServices; }
From source file:net.officefloor.plugin.web.http.security.store.PasswordFileCredentialStoreTest.java
/** * Asserts the set of roles.// w w w.j a va 2s.c om * * @param actualRoles * Actual roles. * @param expectedRoles * Expected roles. */ private static void assertRoles(Set<String> actualRoles, String... expectedRoles) { assertEquals("Incorrect number of roles", expectedRoles.length, actualRoles.size()); for (String role : expectedRoles) { assertTrue("Expected to have role: '" + role + "'", actualRoles.contains(role)); } }
From source file:Main.java
/** * set convert to string//from w ww .ja v a2s . c om */ public static String setConvertToString(Set<String> values, String separate) { if (values == null) { return null; } if (values.isEmpty()) { return ""; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; StringBuilder sb = new StringBuilder(64); int _size = values.size() - 1; int count = 0; for (String value : values) { sb.append(value); if (count != _size) { sb.append(sp); } count++; } return sb.toString(); }
From source file:com.yunrang.hadoop.app.utils.CustomizedUtil.java
/** * Returns a classpath string built from the content of the "tmpjars" value * in {@code conf}. Also exposed to shell scripts via `bin/hbase mapredcp`. *//*from w w w. j a v a 2 s .c om*/ public static String buildDependencyClasspath(Configuration conf) { if (conf == null) { throw new IllegalArgumentException("Must provide a configuration object."); } Set<String> paths = new HashSet<String>(conf.getStringCollection("tmpjars")); if (paths.size() == 0) { throw new IllegalArgumentException("Configuration contains no tmpjars."); } StringBuilder sb = new StringBuilder(); for (String s : paths) { // entries can take the form 'file:/path/to/file.jar'. int idx = s.indexOf(":"); if (idx != -1) s = s.substring(idx + 1); if (sb.length() > 0) sb.append(File.pathSeparator); sb.append(s); } return sb.toString(); }
From source file:gov.nih.nci.firebird.web.common.RegistrationJsonConverter.java
/** * convert registrations for consumption by inviteDialog.tag. * * @param action action to help with formated strings * @param registrations the registrations to show in table * @return JSON table data of registration * @throws JSONException error//from w w w . j ava2 s . c o m */ public static String convertToJson(ActionSupport action, Set<? extends AbstractProtocolRegistration> registrations) throws JSONException { Row[] rows = new Row[registrations.size()]; int i = 0; for (AbstractProtocolRegistration reg : registrations) { rows[i++] = new Row(action, reg); } Arrays.sort(rows); return JSONUtil.serialize(rows, Lists.newArrayList(Pattern.compile(".*\\.byteDataSource")), null, false, true, false); }
From source file:Main.java
public static double calcStrSetSimilarity(final Set<String> strASet1, final Set<String> strASet2) { int containsCount = 0; final Iterator<String> iter = strASet2.iterator(); while (iter.hasNext()) { if (strASet1.contains(iter.next())) { containsCount++;//from w w w . ja v a 2 s. c o m } } return (double) containsCount / (double) strASet1.size(); }
From source file:com.adaptris.core.XStreamMarshallerTest.java
public static void adapterInstanceFieldChecks(Adapter fromXML) { assertNotNull(fromXML);//from w w w . j a v a 2 s . co m assertEquals("SimpleAdapterTest", fromXML.getUniqueId()); assertTrue(fromXML.logHandler() instanceof NullLogHandler); assertTrue(fromXML.getEventHandler() instanceof DefaultEventHandler); assertTrue(((DefaultEventHandler) fromXML.getEventHandler()).getConnection() instanceof NullConnection); assertTrue(((DefaultEventHandler) fromXML.getEventHandler()).getProducer() instanceof NullMessageProducer); // ShutdownWaitSeconds is now null. assertNull(((DefaultEventHandler) fromXML.getEventHandler()).getShutdownWaitSeconds()); assertTrue(fromXML.getMessageErrorHandler() instanceof NullProcessingExceptionHandler); Channel channel = fromXML.getChannelList().get(0); assertTrue(channel.getConsumeConnection() instanceof NullConnection); assertTrue(channel.getProduceConnection() instanceof NullConnection); // Check workflow WorkflowList workflowList = channel.getWorkflowList(); assertNotNull(workflowList); assertEquals(1, workflowList.size()); // test workflow StandardWorkflow standardWorkflow = (StandardWorkflow) workflowList.get(0); assertNotNull(standardWorkflow); assertEquals("workflow1", standardWorkflow.getUniqueId()); // test workflow consumer AdaptrisMessageConsumer consumer = standardWorkflow.getConsumer(); assertNotNull(consumer); ConsumeDestination destination = consumer.getDestination(); assertNotNull(destination); assertTrue(destination instanceof ConfiguredConsumeDestination); assertEquals("dummy", destination.getDestination()); // test services ServiceCollection serviceCollection = standardWorkflow.getServiceCollection(); assertNotNull(serviceCollection); assertEquals("serviceListID1", serviceCollection.getUniqueId()); assertEquals(3, serviceCollection.size()); assertTrue(serviceCollection instanceof ServiceList); // test service 1 Service service1 = serviceCollection.get(0); assertEquals("serviceID1", service1.getUniqueId()); assertTrue(service1 instanceof AddMetadataService); Set<MetadataElement> metadataElements = ((AddMetadataService) service1).getMetadataElements(); assertEquals(1, metadataElements.size()); for (Iterator<MetadataElement> iterator = metadataElements.iterator(); iterator.hasNext();) { MetadataElement metadataElement = (MetadataElement) iterator.next(); assertEquals("key1", metadataElement.getKey()); assertEquals("val1", metadataElement.getValue()); break; } // test service 2 Service service2 = serviceCollection.get(1); assertEquals("serviceID2", service2.getUniqueId()); assertTrue(service2 instanceof XpathMetadataService); List<XpathQuery> xpathQueries = ((XpathMetadataService) service2).getXpathQueries(); assertEquals(1, xpathQueries.size()); assertEquals(ConfiguredXpathQuery.class, xpathQueries.get(0).getClass()); assertEquals("/a/b/c", ((ConfiguredXpathQuery) xpathQueries.get(0)).getXpathQuery()); // Test service3 Service service3 = serviceCollection.get(2); assertEquals("serviceID3", service3.getUniqueId()); assertTrue(service3 instanceof LogMessageService); assertTrue(StringUtils.isBlank(((LogMessageService) service3).getLogPrefix())); assertFalse(((LogMessageService) service3).getIncludeEvents()); assertTrue(((LogMessageService) service3).getIncludePayload()); }
From source file:Main.java
/** * set convert to byte[]//from ww w .j ava2 s. c om */ public static byte[] setConvertToByte(Set<String> values, String separate) { if (values == null) { return null; } if (values.isEmpty()) { return new byte[0]; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; StringBuilder sb = new StringBuilder(64); int _size = values.size() - 1; int count = 0; for (String value : values) { sb.append(value); if (count != _size) { sb.append(sp); } count++; } return sb.toString().getBytes(); }
From source file:com.cyberway.issue.crawler.datamodel.credential.Rfc2617Credential.java
/** * Convenience method that does look up on passed set using realm for key. * * @param rfc2617Credentials Set of Rfc2617 credentials. If passed set is * not pure Rfc2617Credentials then will be ClassCastExceptions. * @param realm Realm to find in passed set. * @param context Context to use when searching the realm. * @return Credential of passed realm name else null. If more than one * credential w/ passed realm name, and there shouldn't be, we return first * found./* w w w . j a v a2 s . co m*/ */ public static Rfc2617Credential getByRealm(Set rfc2617Credentials, String realm, CrawlURI context) { Rfc2617Credential result = null; if (rfc2617Credentials == null || rfc2617Credentials.size() <= 0) { return result; } if (rfc2617Credentials != null && rfc2617Credentials.size() > 0) { for (Iterator i = rfc2617Credentials.iterator(); i.hasNext();) { Rfc2617Credential c = (Rfc2617Credential) i.next(); try { if (c.getRealm(context).equals(realm)) { result = c; break; } } catch (AttributeNotFoundException e) { logger.severe("Failed look up by realm " + realm + " " + e); } } } return result; }
From source file:cop.raml.utils.Utils.java
/** * Converts enum constants as set {@code anEnum} to enum string without any duplication. * * @param anEnum set of enum constants/*from w w w .j av a 2 s.c o m*/ * @return {@code null} or not empty enum string (e.g. [one,two]) */ public static String toEnumStr(Set<String> anEnum) { return CollectionUtils.isNotEmpty(anEnum) ? toEnumStr(anEnum.toArray(new String[anEnum.size()])) : null; }