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:de.hybris.platform.product.impl.DefaultVariantsService.java
/** * {@inheritDoc}//from w ww . j a va2 s .com * */ @Override public Set<String> getVariantAttributes(final String variantProductType) { final ComposedTypeModel composedTypeModel = typeService.getComposedTypeForCode(variantProductType); if (composedTypeModel instanceof VariantTypeModel) { final VariantTypeModel variantTypeModel = (VariantTypeModel) composedTypeModel; final Collection<VariantAttributeDescriptorModel> variantAttributtes = getVariantAttributesForVariantType( variantTypeModel); if (CollectionUtils.isEmpty(variantAttributtes)) { return Collections.EMPTY_SET; } else { final Set<String> ret = new HashSet<String>(variantAttributtes.size()); for (final VariantAttributeDescriptorModel vad : variantAttributtes) { ret.add(vad.getQualifier()); } return ret; } } else { throw new IllegalArgumentException( "there is no variant type '" + variantProductType + "'" + (composedTypeModel == null ? "" : " - found composed type (" + composedTypeModel + ") instead")); } }
From source file:org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties.java
@Override protected Set<PropertyPathConnector> getAllSchemaPropertiesConnectors(boolean isOutputConnection) { if (isOutputConnection) { return Collections.singleton(MAIN_CONNECTOR); } else {/*from w w w . ja va2 s . co m*/ return Collections.EMPTY_SET; } }
From source file:com.espertech.esper.core.service.StatementVariableRefImpl.java
public Set<String> getStatementNamesForVar(String variableName) { mapLock.acquireReadLock();/* ww w . j a va 2 s .c om*/ try { Set<String> variables = variableToStmt.get(variableName); if (variables == null) { return Collections.EMPTY_SET; } return Collections.unmodifiableSet(variables); } finally { mapLock.releaseReadLock(); } }
From source file:org.forgerock.openam.authentication.modules.deviceprint.DevicePrintModule.java
/** * Gets the user's AMIdentity from LDAP. * * @param userName The user's name./*from w ww . j a v a2 s. com*/ * @return The AMIdentity for the user. */ public AMIdentity getIdentity(String userName) { AMIdentity amIdentity = null; AMIdentityRepository amIdRepo = getAMIdentityRepository(getRequestOrg()); IdSearchControl idsc = new IdSearchControl(); idsc.setAllReturnAttributes(true); Set<AMIdentity> results = Collections.EMPTY_SET; try { idsc.setMaxResults(0); IdSearchResults searchResults = amIdRepo.searchIdentities(IdType.USER, userName, idsc); if (searchResults != null) { results = searchResults.getSearchResults(); } if (results == null || results.size() != 1) { throw new IdRepoException("getIdentity : More than one user found"); } amIdentity = results.iterator().next(); } catch (IdRepoException e) { DEBUG.error("Error searching Identities with username : " + userName, e); } catch (SSOException e) { DEBUG.error("Module exception : ", e); } return amIdentity; }
From source file:pt.ist.expenditureTrackingSystem.domain.announcements.SearchAnnouncementProcess.java
@Override public Set<AnnouncementProcess> search() { try {//from w w w. j a v a 2 s.c o m return hasAnyCriteria() ? new SearchAnnouncementResult(GenericProcess.getAllProcesses(AnnouncementProcess.class)) : Collections.EMPTY_SET; } catch (Exception ex) { ex.printStackTrace(); throw new Error(ex); } }
From source file:org.aika.experiments.CorpusIndividualWordTrainingTest.java
@Test public void testTraining() throws IOException { Node.minFrequency = 3;/* ww w . j ava 2 s . c o m*/ String[] files = new String[] { "Aschenputtel" /* "BruederchenUndSchwesterchen", "DasTapfereSchneiderlein", "DerFroschkoenig", "DerGestiefelteKater", "DerGoldeneSchluessel", "DerSuesseBrei", "DerTeufelMitDenDreiGoldenenHaaren", "DerWolfUndDieSiebenJungenGeisslein", "DieBremerStadtmusikanten", "DieDreiFedern", "DieSterntaler", "DieWeisseSchlange", "DieZwoelfBrueder", "Dornroeschen", "FrauHolle", "HaenselUndGretel", "HansImGlueck", "JorindeUndJoringel", "KatzeUndMausInGesellschaft", "MaerchenVonEinemDerAuszogDasFuerchtenZuLernen", "Marienkind", "Rapunzel", "Rotkaeppchen", "Rumpelstilzchen", "SchneeweisschenUndRosenrot", "Schneewitchen", "TischleinDeckDich", "VonDemFischerUndSeinerFrau"*/ }; TreeSet<Document> inputs = new TreeSet<>(); for (String fn : files) { File f = new File("./src/test/resources/text/maerchen/" + fn + ".txt"); InputStream is = new FileInputStream(f); StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); String txt = writer.toString(); txt = txt.replace("\"", ""); txt = txt.replace(",", ""); txt = txt.replace(".", ""); txt = txt.replace("\n", " "); txt = txt.replace("", " "); txt = txt.replace("", " "); txt = txt.replace("?", " "); txt = txt.replace("!", " "); txt = txt.replace(":", " "); txt = txt.replace(";", " "); txt = txt.replace("-", " "); txt = txt.replace(" ", " "); int i = 0; for (String w : txt.split(" ")) { Document doc = new Document(f + "-" + (i++)); doc.setContent(" " + w + " "); PrepareSimpleCharacterProperties.run(doc); inputs.add(doc); // if(i == 2) break; } } PredefinedRules pr = new PredefinedRules(); pr.addRules(); Neuron.createOrNeuron(pr.lateSE, Collections.EMPTY_SET); Network.run(inputs); }
From source file:org.hyperledger.fabric.sdk.NetworkConfig.java
/** * Names of Peers found//w w w. j av a 2 s . c o m * * @return Collection of peer names found. */ public Collection<String> getPeerNames() { if (peers == null) { return Collections.EMPTY_SET; } else { return new HashSet<>(peers.keySet()); } }
From source file:org.codehaus.mojo.mrm.impl.maven.MemoryArtifactStore.java
/** * {@inheritDoc}// www . j a v a2 s . c o m */ public synchronized Set getArtifactIds(String groupId) { Map artifactMap = (Map) contents.get(groupId); return new TreeSet(artifactMap == null ? Collections.EMPTY_SET : artifactMap.keySet()); }
From source file:org.stockwatcher.web.StockController.java
@RequestMapping(value = "/{symbol}", method = RequestMethod.GET) public String displayStockDetail(@PathVariable String symbol, Model model, HttpServletRequest request) { model.addAttribute("stock", dao.getStockBySymbol(symbol)); Date tradeDate = applicationProps.getLastTradeDate(); SortedSet<Trade> trades = dao.getTradesBySymbolAndDate(symbol, tradeDate); model.addAttribute("trades", getUniqueTrades(trades)); long elapsedTime = trades.size() == 0 ? 0 : getElapsedTime(trades.first().getTimestamp(), trades.last().getTimestamp()); User user = (User) request.getSession().getAttribute("user"); model.addAttribute("watchLists", user == null ? Collections.EMPTY_SET : watchListDao.getWatchListsByUserId(user.getId())); model.addAttribute("lastClosePrice", dao.getLastClosePriceForSymbol(symbol)); model.addAttribute("elapsedTime", elapsedTime); model.addAttribute("liveTrading", applicationProps.isTradingLive()); model.addAttribute("watchCount", watchListDao.getWatchCount(symbol)); dao.incrementStockViewCount(symbol); return "stock"; }
From source file:org.flite.cach3.aop.LogicalCacheImplTest.java
@Test public void testWarnings() { final String prefix = "testWarnings-"; final Set<String> putIds = new HashSet<String>(); final Map<String, Object> data = new HashMap<String, Object>(); final Set<String> missIds = new HashSet<String>(); final List<Duration> allDurations = new ArrayList<Duration>(LogicalCacheImpl.DURATION_SET); Collections.shuffle(allDurations); final Duration target = allDurations.get(0); for (int ix = 0; ix < 10; ix++) { final String key = prefix + RandomStringUtils.randomAlphanumeric(10 + ix); putIds.add(key);/*w w w . ja v a 2 s . c om*/ data.put(key, RandomStringUtils.randomAlphabetic(12 + ix)); missIds.add(prefix + RandomStringUtils.randomAlphanumeric(10 + ix)); } // To start with, NONE should be in the list, so they should all miss. for (final Duration duration : LogicalCacheImpl.DURATION_SET) { AssertJUnit.assertEquals(0, impl.checkIdsForDuplication(putIds, duration).size()); AssertJUnit.assertEquals(0, impl.checkIdsForDuplication(missIds, duration).size()); AssertJUnit.assertNull(impl.warnOfDuplication(putIds, duration)); AssertJUnit.assertNull(impl.warnOfDuplication(missIds, duration)); } // Put the data in the list for the first time impl.setBulk(data, target); // Check for misses. for (final Duration duration : LogicalCacheImpl.DURATION_SET) { if (duration == target) { continue; } AssertJUnit.assertEquals(0, impl.checkIdsForDuplication(missIds, duration).size()); AssertJUnit.assertNull(impl.warnOfDuplication(missIds, duration)); } // Check for expected duplication warnings. for (final Duration duration : LogicalCacheImpl.DURATION_SET) { if (duration == target) { continue; } final Set<String> notifyIds = impl.checkIdsForDuplication(putIds, duration); AssertJUnit.assertNotNull(notifyIds); // System.out.println(notifyIds); AssertJUnit.assertEquals(putIds.size(), notifyIds.size()); final String warningText = impl.warnOfDuplication(putIds, duration); // System.out.println(warningText); AssertJUnit.assertNotNull(warningText); for (final String id : putIds) { AssertJUnit.assertTrue(warningText.contains(id)); } } // And test the last little pre-expectations AssertJUnit.assertEquals(0, impl.checkIdsForDuplication(null, Duration.ONE_MINUTE).size()); AssertJUnit.assertEquals(0, impl.checkIdsForDuplication(Collections.EMPTY_SET, Duration.ONE_MINUTE).size()); AssertJUnit.assertNull(impl.warnOfDuplication(null, Duration.FIVE_MINUTES)); AssertJUnit.assertNull(impl.warnOfDuplication(Collections.EMPTY_LIST, Duration.FIVE_MINUTES)); }