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:org.mule.module.management.support.SimplePasswordJmxAuthenticator.java
public Subject authenticate(Object authToken) { if (authToken == null) { throw new SecurityException("No authentication token available"); }//from ww w.ja v a2s . com if (!(authToken instanceof String[]) || ((String[]) authToken).length != 2) { throw new SecurityException("Unsupported credentials format"); } String[] authentication = (String[]) authToken; String username = StringUtils.defaultString(authentication[0]); String password = StringUtils.defaultString(authentication[1]); if (!credentials.containsKey(username)) { throw new SecurityException("Unauthenticated user: " + username); } Object pass = credentials.get(username); if (!password.equals(pass == null ? "" : pass.toString())) { throw new SecurityException("Invalid password"); } Set<Principal> principals = new HashSet<Principal>(); principals.add(new JMXPrincipal(username)); return new Subject(true, principals, Collections.EMPTY_SET, Collections.EMPTY_SET); }
From source file:org.seasar.struts.bean.SuppressPropertyUtilsBean.java
/** * ?????????//from www. j av a2 s . c o m * * @param suppressedBeanClasses * ???? */ public SuppressPropertyUtilsBean(Collection suppressedBeanClasses) { if (suppressedBeanClasses == null) { this.suppressedBeanClasses = Collections.EMPTY_SET; } else { this.suppressedBeanClasses = Collections.unmodifiableSet(new HashSet(suppressedBeanClasses)); } descriptorsCache = new FastHashMap(); descriptorsCache.setFast(true); }
From source file:org.mule.module.pubsubhubbub.data.DataStore.java
@SuppressWarnings("unchecked") public Set<TopicSubscription> getTopicSubscriptions(final URI topicUrl) { final Set<TopicSubscription> result = new HashSet<TopicSubscription>(); for (final TopicSubscription topicSubscription : (Set<TopicSubscription>) retrieve(topicUrl, TOPIC_SUBSCRIPTION_CALLBACKS_PARTITION, (Serializable) Collections.EMPTY_SET)) { if (topicSubscription.isExpired()) { removeTopicSubscription(topicSubscription); } else {/*from ww w .ja va 2 s.c o m*/ result.add(topicSubscription); } } return result; }
From source file:org.apache.jackrabbit.core.util.EmptyLinkedMap.java
/** * Returns an unmodifiable empty set. * * @return an unmodifiable empty set. */ public Set keySet() { return Collections.EMPTY_SET; }
From source file:hr.fer.zemris.vhdllab.service.workspace.WorkspaceTest.java
@SuppressWarnings("unchecked") @Before//from w w w .ja v a 2 s.c o m public void initObject() { projectMetadata = new HashMap<Project, ProjectMetadata>(3); firstProject = new Project("userId", "project1"); Hierarchy hierarchy = new Hierarchy(firstProject, new ArrayList<HierarchyNode>()); projectMetadata.put(firstProject, new ProjectMetadata(hierarchy, Collections.EMPTY_SET)); secondProject = new Project("userId", "project2"); hierarchy = new Hierarchy(secondProject, new ArrayList<HierarchyNode>()); projectMetadata.put(secondProject, new ProjectMetadata(hierarchy, Collections.EMPTY_SET)); thirdProject = new Project("userId", "project3"); projectMetadata.put(thirdProject, null); predefinedFiles = new HashSet<File>(1); predefinedFiles.add(new File("predefined", null, "data")); preferencesFiles = new ArrayList<PreferencesFile>(2); preferencesFiles.add(new PreferencesFile("preferences1", "data")); preferencesFiles.add(new PreferencesFile("preferences2", "data2")); workspace = new Workspace(projectMetadata, predefinedFiles, preferencesFiles); }
From source file:org.eclipse.m2e.importer.tests.MavenImporterTest.java
@Test public void test() throws Exception { Set<IProject> newProjects = null; SmartImportJob job = new SmartImportJob(projectDirectory, Collections.EMPTY_SET, true, true); Map<File, List<ProjectConfigurator>> proposals = job.getImportProposals(monitor); Assert.assertEquals("Expected 2 projects to import", 2, proposals.size()); //$NON-NLS-1$ boolean thymConfiguratorFound = false; for (ProjectConfigurator configurator : proposals.values().iterator().next()) { if (configurator instanceof MavenProjectConfigurator) { thymConfiguratorFound = true; }// w w w . j av a2 s .com } Assert.assertTrue("Maven configurator not found while checking directory", thymConfiguratorFound); //$NON-NLS-1$ // accept proposals job.setDirectoriesToImport(proposals.keySet()); IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); Set<IProject> beforeImport = new HashSet<>(Arrays.asList(wsRoot.getProjects())); job.run(monitor); job.join(); newProjects = new HashSet<>(Arrays.asList(wsRoot.getProjects())); newProjects.removeAll(beforeImport); Assert.assertEquals("Expected only 2 new projects", 2, newProjects.size()); //$NON-NLS-1$ JobHelpers.waitForJobs(new IJobMatcher() { public boolean matches(Job job) { return MavenProjectConfigurator.UPDATE_MAVEN_CONFIGURATION_JOB_NAME.equals(job.getName()); } }, 30_000); for (IProject project : newProjects) { Assert.assertTrue(project.getLocation().toFile().getCanonicalPath() .startsWith(projectDirectory.getCanonicalPath())); IMavenProjectFacade mavenProject = MavenPlugin.getMavenProjectRegistry().getProject(project); Assert.assertNotNull("Project not configured as Maven", mavenProject); //$NON-NLS-1$ } }
From source file:io.cfp.model.User.java
public Set<String> getRoles() { return roles != null ? roles : Collections.EMPTY_SET; }
From source file:org.polymap.core.security.DummyAuthorizationModule.java
@Override public Set<Principal> rolesOf(Subject subject) { Set<DummyUserPrincipal> dummyPrincipals = subject.getPrincipals(DummyUserPrincipal.class); assert dummyPrincipals.size() <= 1; // DummyUserPrincipal found if (!dummyPrincipals.isEmpty()) { return getOnlyElement(dummyPrincipals).getRoles(); }// www .j ava 2s . co m // else { Set<UserPrincipal> users = subject.getPrincipals(UserPrincipal.class); assert users.size() == 1 : "Too many/less UserPrincipals in subject: " + users; DummyUserPrincipal dummyUser = delegateLoginModule.userForName(getOnlyElement(users).getName()); return dummyUser != null ? dummyUser.getRoles() : Collections.EMPTY_SET; } }
From source file:org.apache.flume.channel.file.Serialization.java
/** * Deletes all files in given directory. * @param checkpointDir - The directory whose files are to be deleted * @param excludes - Names of files which should not be deleted from this * directory./*from ww w . ja v a 2 s . co m*/ * @return - true if all files were successfully deleted, false otherwise. */ static boolean deleteAllFiles(File checkpointDir, @Nullable Set<String> excludes) { if (!checkpointDir.isDirectory()) { return false; } File[] files = checkpointDir.listFiles(); if (files == null) { return false; } StringBuilder builder; if (files.length == 0) { return true; } else { builder = new StringBuilder("Deleted the following files: "); } if (excludes == null) { excludes = Collections.EMPTY_SET; } for (File file : files) { if (excludes.contains(file.getName())) { LOG.info("Skipping " + file.getName() + " because it is in excludes " + "set"); continue; } if (!FileUtils.deleteQuietly(file)) { LOG.info(builder.toString()); LOG.error("Error while attempting to delete: " + file.getAbsolutePath()); return false; } builder.append(", ").append(file.getName()); } builder.append("."); LOG.info(builder.toString()); return true; }
From source file:org.onecmdb.core.internal.reference.ReferenceService.java
/** * Retrive all reference ci that are linked to the ci. */// ww w .j a v a 2s. c o m public Set<IReference> getReferrers(ICi ci) { if (this.daoReader == null) { log.fatal("No daoReader set on refrence service."); return (Collections.EMPTY_SET); } if (ci == null) { return (Collections.EMPTY_SET); } List<IAttribute> refs = daoReader.getTargetReference(ci); if (refs == null) { return (Collections.EMPTY_SET); } Set<IReference> references = new HashSet<IReference>(); for (IAttribute refAttribute : refs) { ICi refCi = refAttribute.getOwner(); if (isReferenceCi(refCi)) { references.add(new ReferenceItem(refCi)); } } return (references); }