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:br.com.suricattus.surispring.spring.security.util.SecurityUtil.java
/** * List user authorities.//from w ww . ja v a 2 s. c o m * * @return user authorities */ @SuppressWarnings("unchecked") public static Set<String> getUserAuthorities() { if (SecurityContextHolder.getContext() == null) return Collections.EMPTY_SET; Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); if (currentUser == null) return Collections.EMPTY_SET; Collection<? extends GrantedAuthority> grantedAauthorities = currentUser.getAuthorities(); if (grantedAauthorities == null || grantedAauthorities.isEmpty()) return Collections.EMPTY_SET; Set<String> authorities = new TreeSet<String>(); for (GrantedAuthority ga : grantedAauthorities) authorities.add(ga.getAuthority()); return authorities; }
From source file:org.polymap.rhei.field.PicklistFormField.java
public Control createControl(Composite parent, IFormToolkit toolkit) { int comboStyle = SWT.DROP_DOWN; comboStyle = !textEditable ? comboStyle | SWT.READ_ONLY : comboStyle & ~SWT.READ_ONLY; combo = toolkit.createCombo(parent, Collections.EMPTY_SET, comboStyle | SWT.MULTI); ///* www.ja v a 2 s . c om*/ for (ModifyListener l : modifyListeners) { combo.addModifyListener(l); } // add values fillCombo(); // modify listener combo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent ev) { Object value = getValue(); log.debug("modifyEvent(): combo= " + combo.getText() + ", value= " + value); if (forceTextMatch && combo.getText().length() > 0 && value == null) { site.setErrorMessage("Wert entspricht keiner der Vorgaben: " + combo.getText()); } else { site.setErrorMessage(null); } // null ist not allowed as text of the combo, so if the loadedValue was null, // then map "" value to null; otherwise the world would see that value as changed if (value != null && value.equals("") && loadedValue == null) { value = null; } site.fireEvent(PicklistFormField.this, IFormFieldListener.VALUE_CHANGE, value); } }); // selection listener combo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent ev) { log.debug("widgetSelected(): selectionIndex= " + combo.getSelectionIndex()); int i = 0; for (String label : values.get().keySet()) { if (i++ == combo.getSelectionIndex()) { combo.setText(label); break; } } Object value = values.get().get(combo.getText()); site.fireEvent(PicklistFormField.this, IFormFieldListener.VALUE_CHANGE, value); } public void widgetDefaultSelected(SelectionEvent ev) { } }); // focus listener combo.addFocusListener(new FocusListener() { public void focusLost(FocusEvent event) { // combo.setBackground( FormEditorToolkit.textBackground ); site.fireEvent(this, IFormFieldListener.FOCUS_LOST, combo.getText()); } public void focusGained(FocusEvent event) { // combo.setBackground( FormEditorToolkit.textBackgroundFocused ); site.fireEvent(this, IFormFieldListener.FOCUS_GAINED, combo.getText()); } }); return combo; }
From source file:br.ufal.cideei.soot.instrument.FeatureModelInstrumentorTransformer.java
@Override protected void internalTransform(Body body, String phase, Map options) { preTransform(body);// w w w. ja v a2s . c om // #ifdef METRICS long startTransform = System.nanoTime(); // #endif /* * Iterate over all units, look up for their colors and add a new FeatureTag to each of them, and also compute * all the colors found in the whole body. Units with no colors receive an empty FeatureTag. */ Iterator<Unit> unitIt = body.getUnits().iterator(); /* * After the following loop, allPresentFeatures will hold all the colors found in the body. Used to calculate a * "local" power set. */ Set<String> allPresentFeatures = new HashSet<String>(); /* * The set of features are represented as bits, for a more compact representation. The mapping between a feature * and it's ID is stored in the FeatureTag of the body. * * This is necessary so that clients, such as r.d. analysis, can safely iterate over all configurations without * explicitly invoking Set operations like containsAll(); * * TODO: check redundancy between allPresentFeatures & allPresentFeaturesId */ // String->Integer BidiMap allPresentFeaturesId = new DualHashBidiMap(); FeatureTag emptyFeatureTag; // #ifdef LAZY BitVectorFeatureRep emptyBitVectorRep = new BitVectorFeatureRep(Collections.EMPTY_SET, allPresentFeaturesId); emptyFeatureTag = new FeatureTag(emptyBitVectorRep); // #else //@ emptyFeatureTag = new FeatureTag(new BitFeatureRep(Collections.EMPTY_SET, allPresentFeaturesId)); //@ // #endif // #ifdef LAZY /* * in the lazy approach, the representation can only be consolidate after all features have been discovery. All * IFeatureRep will stored so that it is possible to consolidate later. */ List<BitVectorFeatureRep> generateVectorLater = new ArrayList<BitVectorFeatureRep>(); // #endif int idGen = 1; while (unitIt.hasNext()) { Unit nextUnit = unitIt.next(); SourceLnPosTag lineTag = (SourceLnPosTag) nextUnit.getTag("SourceLnPosTag"); if (lineTag == null) { nextUnit.addTag(emptyFeatureTag); } else { int unitLine = lineTag.startLn(); Set<String> nextUnitColors = currentColorMap.get(unitLine); if (nextUnitColors != null) { for (String color : nextUnitColors) { if (!allPresentFeaturesId.containsKey(color)) { allPresentFeaturesId.put(color, idGen); idGen = idGen << 1; } } /* * increment local powerset with new found colors. */ allPresentFeatures.addAll(nextUnitColors); IFeatureRep featRep; FeatureTag featureTag; // #ifdef LAZY featRep = new BitVectorFeatureRep(nextUnitColors, allPresentFeaturesId); generateVectorLater.add((BitVectorFeatureRep) featRep); featureTag = new FeatureTag(featRep); nextUnit.addTag(featureTag); // #else //@ //@ featRep = new BitFeatureRep(nextUnitColors, allPresentFeaturesId); //@ // #endif featureTag = new FeatureTag(featRep); nextUnit.addTag(featureTag); } else { nextUnit.addTag(emptyFeatureTag); } } } UnmodifiableBidiMap unmodAllPresentFeaturesId = (UnmodifiableBidiMap) UnmodifiableBidiMap .decorate(allPresentFeaturesId); // #ifdef LAZY /* * generate vectors */ for (BitVectorFeatureRep featureRep : generateVectorLater) { featureRep.generateBitVector(idGen); } // #endif // #ifdef METRICS long transformationDelta = System.nanoTime() - startTransform; if (sink != null) { sink.flow(body, FeatureModelInstrumentorTransformer.INSTRUMENTATION, transformationDelta); } FeatureModelInstrumentorTransformer.transformationTime += transformationDelta; // #endif ConfigTag configTag; // #ifdef LAZY BitVectorConfigRep localConfigurations = BitVectorConfigRep.localConfigurations(idGen, unmodAllPresentFeaturesId // #ifdef FEATUREMODEL //@ , checker // #endif ); emptyBitVectorRep.generateBitVector(idGen); Set<IConfigRep> lazyConfig = new HashSet<IConfigRep>(); lazyConfig.add(localConfigurations); configTag = new ConfigTag(lazyConfig); body.addTag(configTag); // #else //@ //@ configTag = new ConfigTag(BitConfigRep.localConfigurations(idGen, unmodAllPresentFeaturesId // #ifdef FEATUREMODEL //@ , checker // #endif //@ ).getConfigs()); //@ body.addTag(configTag); //@ // #endif }
From source file:org.apache.james.protocols.pop3.core.UidlCmdHandler.java
/** * @see org.apache.james.pop3server.core.CapaCapability#getImplementedCapabilities(org.apache.james.pop3server.POP3Session) *//*from w w w . ja va2s . c om*/ @SuppressWarnings("unchecked") public Set<String> getImplementedCapabilities(POP3Session session) { if (session.getHandlerState() == POP3Session.TRANSACTION) { return CAPS; } else { return Collections.EMPTY_SET; } }
From source file:org.mule.module.pubsubhubbub.data.DataStore.java
private synchronized void removeFromSet(final Serializable key, final Serializable value, final String domain) { // not atomic :( @SuppressWarnings("unchecked") final Set<Serializable> values = (Set<Serializable>) retrieve(key, domain, (Serializable) Collections.EMPTY_SET); if (values.isEmpty()) { return;/*from www . ja v a 2 s .c om*/ } values.remove(value); store(key, (Serializable) values, domain); }
From source file:com.adobe.ags.curly.test.ErrorBehaviorTest.java
@Test public void testHalt() throws IOException, ParseException { ApplicationState.getInstance().errorBehaviorProperty().set(ErrorBehavior.HALT); Action fail1 = failureAction(); Action fail2 = failureAction(); List<Action> actions = Arrays.asList(fail1, fail2); ActionGroupRunner runner = new ActionGroupRunner("Action Halt Test", ignore -> client, actions, Collections.EMPTY_MAP, Collections.EMPTY_SET); runner.run();//from ww w . ja v a 2s .c om assertResults(runner.getResult(), false, false); assertFalse(ApplicationState.getInstance().runningProperty().get()); }
From source file:org.xcmis.search.query.content.AbstractQueryTest.java
/** * Set-up the configuration values used for the test. Per default retrieves a * session, configures testRoot, and nodetype and checks if the query * language for the current language is available.<br> */// w w w. j a v a 2 s .c o m @Before public void setUp() throws Exception { tempDir = new File(System.getProperty("java.io.tmpdir"), "search-service"); if (tempDir.exists()) { assertThat(FileUtils.deleteQuietly(tempDir), is(true)); } assertThat(tempDir.mkdirs(), is(true)); Builder schemaBuilder = InMemorySchema.createBuilder(); schema = schemaBuilder.addTable(rootNodeType, propertyName1, propertyName2) .addTable(testNodeType, new String[] { propertyName4 }) .addColumn(testNodeType, propertyName1, PropertyType.STRING, true, Operator.ALL) .addColumn(testNodeType, propertyName2, PropertyType.STRING, true, Operator.ALL) .addTable(testNodeType2, propertyName4).build(); qf = new QueryBuilder(mock(CastSystem.class)); testRootNode = new Node(null, "", new String[] { rootNodeType }, UUID.randomUUID().toString(), new String[] { Node.ROOT_PARENT_UUID }, new Property[0]); //testRoot = testRootNode.getPath(); //value NameConverter<String> nameConverter = new ToStringNameConverter(); SchemaTableResolver tableResolver = new SchemaTableResolver(nameConverter, schema); //index configuration IndexConfiguration indexConfuration = new IndexConfiguration(testRootNode.getParentIdentifiers()[0], testRootNode.getIdentifier()); //search service configuration SearchServiceConfiguration configuration = new SearchServiceConfiguration(schema, tableResolver, mock(ContentReaderInterceptor.class), indexConfuration); searchService = new SearchService(configuration); searchService.start(); List<ContentEntry> contentEntries = new ArrayList<ContentEntry>(); contentEntries.add(testRootNode); searchService.update(contentEntries, Collections.EMPTY_SET); }
From source file:org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy.java
@SuppressWarnings("unchecked") @VisibleForTesting//ww w . j a v a 2s . c o m public ProportionalCapacityPreemptionPolicy(RMContext context, CapacityScheduler scheduler, Clock clock) { init(context.getYarnConfiguration(), context, scheduler); this.clock = clock; allPartitions = Collections.EMPTY_SET; leafQueueNames = Collections.EMPTY_SET; preemptableQueues = Collections.EMPTY_MAP; }
From source file:org.talend.dataquality.statistics.datetime.CustomDateTimePatternManagerTest.java
@Test public void testInvalidTimeNotMatchingCustomPattern() { assertFalse(CustomDateTimePatternManager.isTime("21?30", Collections.<String>singletonList("H-m"))); assertEquals(Collections.EMPTY_SET, CustomDateTimePatternManager.replaceByDateTimePattern("21?30", "H-m")); }
From source file:SessionMap.java
/** * @see java.util.Map#entrySet()/*from w w w . j av a2 s .c om*/ */ public Set entrySet() { if (session != null) { Set entrySet = new HashSet(); Enumeration enumeration = session.getAttributeNames(); while (enumeration.hasMoreElements()) { String name = enumeration.nextElement().toString(); Object value = session.getAttribute(name); entrySet.add(value); } return entrySet; } else { return Collections.EMPTY_SET; } }