List of usage examples for java.util Collections EMPTY_SET
Set EMPTY_SET
To view the source code for java.util Collections EMPTY_SET.
Click Source Link
From source file:com.acc.controller.ProductsController.java
protected List<String> validateAndSplitCatalog(final String catalog) throws IllegalArgumentException { final List<String> catalogInfo = new ArrayList<>(); if (StringUtils.isNotEmpty(catalog)) { catalogInfo// ww w.jav a 2s.co m .addAll(Lists.newArrayList(Splitter.on(':').trimResults().omitEmptyStrings().split(catalog))); if (catalogInfo.size() == 2) { catalogFacade.getProductCatalogVersionForTheCurrentSite(catalogInfo.get(CATALOG_ID_POS), catalogInfo.get(CATALOG_VERSION_POS), Collections.EMPTY_SET); } else if (!catalogInfo.isEmpty()) { throw new IllegalArgumentException( "You have to provide both catalog and catalogVersion parameters or none of them."); } } return catalogInfo; }
From source file:org.apache.myfaces.custom.picklist.HtmlPicklistRenderer.java
private void encodeSelect(FacesContext facesContext, UIComponent uiComponent, String clientId, boolean disabled, int size, List selectItemsToDisplay, Converter converter) throws IOException { ResponseWriter writer = facesContext.getResponseWriter(); writer.startElement(HTML.SELECT_ELEM, uiComponent); writer.writeAttribute(HTML.ID_ATTR, clientId, JSFAttr.ID_ATTR); writer.writeAttribute(HTML.NAME_ATTR, clientId, null); writer.writeAttribute(HTML.MULTIPLE_ATTR, "true", null); if (size == 0) { //No size given (Listbox) --> size is number of select items writer.writeAttribute(HTML.SIZE_ATTR, Integer.toString(selectItemsToDisplay.size()), null); } else {/* ww w .j a v a 2s .co m*/ writer.writeAttribute(HTML.SIZE_ATTR, Integer.toString(size), null); } Map<String, List<ClientBehavior>> behaviors = null; if (uiComponent instanceof ClientBehaviorHolder) { behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors(); } if (behaviors != null && !behaviors.isEmpty()) { HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors); HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors); HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, uiComponent, behaviors); HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS); } else { HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED); } if (disabled) { writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null); } HtmlRendererUtils.renderSelectOptions(facesContext, uiComponent, converter, Collections.EMPTY_SET, selectItemsToDisplay); // bug #970747: force separate end tag writer.writeText("", null); writer.endElement(HTML.SELECT_ELEM); }
From source file:io.stallion.dataAccess.LocalMemoryStash.java
@Override public List<T> listForKey(String keyName, Object value) { onPreRead();//from ww w . j a v a2 s . c o m Set<T> things = this.keyNameToKeyToValue.get(keyName).getOrDefault(value, Collections.EMPTY_SET); return new ArrayList<T>(things); }
From source file:org.tanaguru.webapp.controller.ForgottenOrChangePasswordController.java
/** * This method gets data from a property file to fill-in the inscription * e-mail//from ww w .j a v a 2 s.c o m * @param user */ private void sendResetEmail(User user, Locale locale) { ResourceBundle resourceBundle = ResourceBundle.getBundle(TgolKeyStore.FORGOTTEN_PASSWD_BUNDLE_NAME, locale); String emailFrom = resourceBundle.getString(TgolKeyStore.FORGOTTEN_PASSWD_EMAIL_FROM_KEY); Set<String> emailToSet = new HashSet(); emailToSet.add(user.getEmail1()); String emailSubject = resourceBundle.getString(TgolKeyStore.FORGOTTEN_PASSWD_EMAIL_SUBJECT_KEY); String emailContentPattern = resourceBundle.getString(TgolKeyStore.FORGOTTEN_PASSWD_EMAIL_CONTENT_KEY); String emailContent = MessageFormat.format(emailContentPattern, user.getEmail1(), computeReturnedUrl(user)); emailSender.sendEmail(emailFrom, emailToSet, Collections.EMPTY_SET, StringUtils.EMPTY, emailSubject, emailContent); }
From source file:org.apache.geode.cache.lucene.internal.filesystem.FileSystemJUnitTest.java
/** * Test what happens a file delete is aborted in the middle due to the a cache closed exception. * The next member that uses those files should be able to clean up after the partial rename. */// w w w . j av a 2 s.c o m @Test public void testPartialDelete() throws Exception { final CountOperations countOperations = new CountOperations(); // Create a couple of mock regions where we count the operations // that happen to them. We will then use this to abort the rename // in the middle. ConcurrentHashMap<String, File> spyFileRegion = mock(ConcurrentHashMap.class, new SpyWrapper(countOperations, fileRegion)); ConcurrentHashMap<ChunkKey, byte[]> spyChunkRegion = mock(ConcurrentHashMap.class, new SpyWrapper(countOperations, chunkRegion)); system = new FileSystem(spyFileRegion, spyChunkRegion, fileSystemStats); String name1 = "file1"; String name2 = "file2"; File file1 = system.createFile(name1); File file2 = system.createFile(name2); ByteArrayOutputStream expected = new ByteArrayOutputStream(); // Make sure the file has a lot of chunks for (int i = 0; i < 10; i++) { byte[] bytes = writeRandomBytes(file1); writeBytes(file2, bytes); expected.write(bytes); } countOperations.reset(); system.deleteFile(name1); assertTrue(2 <= countOperations.count); countOperations.after(countOperations.count / 2, new Runnable() { @Override public void run() { throw new CacheClosedException(); } }); countOperations.reset(); try { system.deleteFile(name2); fail("should have seen an error"); } catch (CacheClosedException expectedException) { } system = new FileSystem(fileRegion, chunkRegion, fileSystemStats); if (system.listFileNames().size() == 0) { // File was deleted, but shouldn't have any dangling chunks at this point assertEquals(Collections.EMPTY_SET, fileRegion.keySet()); // TODO - need to purge chunks of deleted files somehow. // assertIndexDetailsEquals(Collections.EMPTY_SET, chunkRegion.keySet()); } else { file2 = system.getFile(name2); assertContents(expected.toByteArray(), file2); } }
From source file:com.gemstone.gemfire.cache.lucene.internal.filesystem.FileSystemJUnitTest.java
/** * Test what happens a file delete is aborted in the middle * due to the a cache closed exception. The next member * that uses those files should be able to clean up after * the partial rename./*from w w w . jav a2 s. c o m*/ */ @Test public void testPartialDelete() throws Exception { final CountOperations countOperations = new CountOperations(); //Create a couple of mock regions where we count the operations //that happen to them. We will then use this to abort the rename //in the middle. ConcurrentHashMap<String, File> spyFileRegion = mock(ConcurrentHashMap.class, new SpyWrapper(countOperations, fileRegion)); ConcurrentHashMap<ChunkKey, byte[]> spyChunkRegion = mock(ConcurrentHashMap.class, new SpyWrapper(countOperations, chunkRegion)); system = new FileSystem(spyFileRegion, spyChunkRegion, fileSystemStats); String name1 = "file1"; String name2 = "file2"; File file1 = system.createFile(name1); File file2 = system.createFile(name2); ByteArrayOutputStream expected = new ByteArrayOutputStream(); //Make sure the file has a lot of chunks for (int i = 0; i < 10; i++) { byte[] bytes = writeRandomBytes(file1); writeBytes(file2, bytes); expected.write(bytes); } countOperations.reset(); system.deleteFile(name1); assertTrue(2 <= countOperations.count); countOperations.after(countOperations.count / 2, new Runnable() { @Override public void run() { throw new CacheClosedException(); } }); countOperations.reset(); try { system.deleteFile(name2); fail("should have seen an error"); } catch (CacheClosedException expectedException) { } system = new FileSystem(fileRegion, chunkRegion, fileSystemStats); if (system.listFileNames().size() == 0) { //File was deleted, but shouldn't have any dangling chunks at this point assertEquals(Collections.EMPTY_SET, fileRegion.keySet()); //TODO - need to purge chunks of deleted files somehow. // assertIndexDetailsEquals(Collections.EMPTY_SET, chunkRegion.keySet()); } else { file2 = system.getFile(name2); assertContents(expected.toByteArray(), file2); } }
From source file:org.jsecurity.realm.AuthorizingRealm.java
@SuppressWarnings({ "unchecked" }) private Collection<Permission> getPermissions(AuthorizationInfo info) { Set<Permission> permissions = new HashSet<Permission>(); if (info != null) { if (info.getObjectPermissions() != null) { permissions.addAll(info.getObjectPermissions()); }/*from w w w. ja v a2s. c om*/ if (info.getStringPermissions() != null) { for (String strPermission : info.getStringPermissions()) { Permission permission = getPermissionResolver().resolvePermission(strPermission); permissions.add(permission); } } } if (permissions.isEmpty()) { return Collections.EMPTY_SET; } else { return Collections.unmodifiableSet(permissions); } }
From source file:org.opens.tgol.controller.ForgottenOrChangePasswordController.java
/** * This method gets data from a property file to fill-in the inscription * e-mail/*from w w w . j a va 2 s . com*/ * @param user */ private void sendResetEmail(User user, Locale locale) { ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale); String emailFrom = resourceBundle.getString(EMAIL_FROM_KEY); Set<String> emailToSet = new HashSet<String>(); emailToSet.add(user.getEmail1()); String emailSubject = resourceBundle.getString(EMAIL_SUBJECT_KEY); String emailContentPattern = resourceBundle.getString(EMAIL_CONTENT_KEY); String emailContent = MessageFormat.format(emailContentPattern, user.getEmail1(), computeReturnedUrl(user)); emailSender.sendEmail(emailFrom, emailToSet, Collections.EMPTY_SET, StringUtils.EMPTY, emailSubject, emailContent); }
From source file:terrastore.server.impl.JsonHttpServerTest.java
@Test public void testRemoveByRangeWithComparator() throws Exception { UpdateService updateService = createMock(UpdateService.class); QueryService queryService = createMock(QueryService.class); BackupService backupService = createMock(BackupService.class); StatsService statsService = createMock(StatsService.class); Range range = new Range(new Key("aaaa"), new Key("ffff"), 0, "lexical-asc", 0); updateService.removeByRange("bucket", range, new Predicate(null)); expectLastCall().andReturn(new Keys(Collections.EMPTY_SET)).once(); replay(updateService, queryService, backupService, statsService); JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService); HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod( "http://localhost:8080/bucket/range?startKey=aaaa&endKey=ffff&comparator=lexical-asc"); client.executeMethod(method);/* w w w .j av a 2 s. c o m*/ assertEquals(HttpStatus.SC_OK, method.getStatusCode()); method.releaseConnection(); stopServer(server); verify(updateService, queryService, backupService, statsService); }
From source file:org.obm.domain.dao.UserDaoJdbcImpl.java
private ObmUser createUserFromResultSet(ObmDomain domain, ResultSet rs, ObmUser creator, ObmUser updator, Set<Group> groups) throws SQLException { try {//from w ww .ja va 2s . com String extId = rs.getString("userobm_ext_id"); int quota = rs.getInt("userobm_mail_quota"); return ObmUser.builder().uid(rs.getInt("userobm_id")) .login(UserLogin.valueOf(rs.getString("userobm_login"))) .admin(profileDao.isAdminProfile(rs.getString("userobm_perms"))).domain(domain) .identity(UserIdentity.builder().kind(rs.getString("userobm_kind")) .firstName(emptyToNull(rs.getString("userobm_firstname"))) .lastName(emptyToNull(rs.getString("userobm_lastname"))) .commonName(emptyToNull(rs.getString("userobm_commonname"))).build()) .publicFreeBusy(computePublicFreeBusy(rs)) .extId(extId != null ? UserExtId.builder().extId(extId).build() : null) .entityId(EntityId.valueOf(rs.getInt("userentity_entity_id"))) .password(Strings.emptyToNull(rs.getString("userobm_password"))) .profileName(ProfileName.builder().name(rs.getString("userobm_perms")).build()) .work(UserWork.builder().title(emptyToNull(rs.getString("userobm_title"))) .company(rs.getString("userobm_company")).service(rs.getString("userobm_service")) .direction(rs.getString("userobm_direction")).build()) .description(rs.getString("userobm_description")) .address(UserAddress.builder().addressPart(rs.getString("userobm_address1")) .addressPart(rs.getString("userobm_address2")) .addressPart(rs.getString("userobm_address3")).town(rs.getString("userobm_town")) .zipCode(rs.getString("userobm_zipcode")) .expressPostal(rs.getString("userobm_expresspostal")) .countryCode(rs.getString("userobm_country_iso3166")).build()) .phones(UserPhones.builder().addPhone(emptyToNull(rs.getString("userobm_phone"))) .addPhone(emptyToNull(rs.getString("userobm_phone2"))) .mobile(emptyToNull(rs.getString("userobm_mobile"))) .addFax(emptyToNull(rs.getString("userobm_fax"))) .addFax(emptyToNull(rs.getString("userobm_fax2"))).build()) .emails(UserEmails.builder().quota(quotaToNullable(quota)).server(hostFromCursor(rs)) .addresses(deserializeEmails(rs.getString("userobm_email"))).domain(domain).build()) .archived(rs.getBoolean("userobm_archive")).hidden(rs.getInt("userobm_hidden") == HIDDEN_TRUE) .timeCreate(JDBCUtils.getDate(rs, "userobm_timecreate")) .timeUpdate(JDBCUtils.getDate(rs, "userobm_timeupdate")) .uidNumber(JDBCUtils.getInteger(rs, "userobm_uid")) .gidNumber(JDBCUtils.getInteger(rs, "userobm_gid")).createdBy(creator).updatedBy(updator) .groups(Objects.firstNonNull(groups, Collections.EMPTY_SET)).build(); } catch (DaoException e) { throw new SQLException(e); } }