List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:com.cloudera.oryx.app.serving.als.model.ALSServingModel.java
/** * @param user user to get known items for * @return set of known items for the user (immutable, but thread-safe) *//*ww w.j a v a2 s .co m*/ public Set<String> getKnownItems(String user) { ObjSet<String> knownItems = doGetKnownItems(user); if (knownItems == null) { return Collections.emptySet(); } synchronized (knownItems) { if (knownItems.isEmpty()) { return Collections.emptySet(); } // Must copy since the original object is synchronized return HashObjSets.newImmutableSet(knownItems); } }
From source file:se.uu.it.cs.recsys.service.resource.impl.RecommendationGenerator.java
Set<Integer> filterOnPlanYear(Set<Integer> courseId) { if (courseId.isEmpty()) { return Collections.emptySet(); }//from ww w . j a v a2 s . co m Set<se.uu.it.cs.recsys.persistence.entity.Course> filteredCourse = this.courseRepository .findByAutoGenIds(courseId).stream() .filter(ConstraintSolverPreferenceBuilder .inPlanYearPredicate(this.constraintPref.getIndexedScheduleInfo())) .sorted((se.uu.it.cs.recsys.persistence.entity.Course one, se.uu.it.cs.recsys.persistence.entity.Course two) -> Integer.compare(one.getAutoGenId(), two.getAutoGenId())) .collect(Collectors.toSet()); filteredCourse.forEach(course -> LOGGER.debug("Filtered course: {}", course)); return filteredCourse.stream().map(course -> course.getAutoGenId()).collect(Collectors.toSet()); }
From source file:com.orange.cepheus.cep.SubscriptionManagerTest.java
@Test public void testUnsubscribeOnProviderRemoval() { // Mock the task scheduler and capture the runnable ArgumentCaptor<Runnable> runnableArg = ArgumentCaptor.forClass(Runnable.class); when(taskScheduler.scheduleWithFixedDelay(runnableArg.capture(), anyLong())) .thenReturn(Mockito.mock(ScheduledFuture.class)); // Mock the response to the subsribeContext ArgumentCaptor<SuccessCallback> successArg = ArgumentCaptor.forClass(SuccessCallback.class); ListenableFuture<SubscribeContextResponse> responseFuture = Mockito.mock(ListenableFuture.class); doNothing().when(responseFuture).addCallback(successArg.capture(), any()); // Return the mocked future on subscription when(ngsiClient.subscribeContext(any(), any(), any())).thenReturn(responseFuture); Configuration configuration = getBasicConf(); subscriptionManager.setConfiguration(configuration); // Execute scheduled runnable runnableArg.getValue().run();//from w ww .jav a2s.c om // Return the SubscribeContextResponse callSuccessCallback(successArg); // Mock future for unsubscribeContext ListenableFuture<UnsubscribeContextResponse> responseFuture2 = Mockito.mock(ListenableFuture.class); doNothing().when(responseFuture2).addCallback(successArg.capture(), any()); when(ngsiClient.unsubscribeContext(eq("http://iotAgent"), eq(null), eq("12345678"))) .thenReturn(responseFuture2); // Reset conf should trigger unsubsribeContext Configuration emptyConfiguration = getBasicConf(); emptyConfiguration.getEventTypeIns().get(0).setProviders(Collections.emptySet()); subscriptionManager.setConfiguration(emptyConfiguration); // Check that unsubsribe is called Assert.notNull(successArg.getValue()); }
From source file:com.googlecode.fightinglayoutbugs.WebPage.java
@edu.umd.cs.findbugs.annotations.SuppressWarnings("SBSC") public Collection<RectangularRegion> getRectangularRegionsCoveredBy(Collection<String> jQuerySelectors) { if (jQuerySelectors.isEmpty()) { return Collections.emptySet(); }/*from w ww .j a va 2s. c o m*/ // 1.) Assemble JavaScript to select elements ... Iterator<String> i = jQuerySelectors.iterator(); String js = "jQuery('" + i.next().replace("'", "\\'"); while (i.hasNext()) { js += "').add('" + i.next().replace("'", "\\'"); } js += "').filter(':visible')"; // 2.) Assemble JavaScript function to fill an array with rectangular region of each selected element ... js = "function() { " + "var a = new Array(); " + js + ".each(function(i, e) { " + "var j = jQuery(e); " + "var o = j.offset(); " + "a.push({ top: o.top, left: o.left, width: j.width(), height: j.height() }); " + "}); " + "return a; " + "}"; // 3.) Execute JavaScript function ... @SuppressWarnings("unchecked") List<Map<String, Number>> list = (List<Map<String, Number>>) executeJavaScript("return (" + js + ")()"); // 4.) Convert JavaScript return value to Java return value ... if (list.isEmpty()) { return Collections.emptySet(); } Collection<RectangularRegion> result = new ArrayList<RectangularRegion>(list.size()); for (Map<String, Number> map : list) { double left = map.get("left").doubleValue(); double width = map.get("width").doubleValue(); double top = map.get("top").doubleValue(); double height = map.get("height").doubleValue(); if (height > 0 && width > 0) { int x1 = (int) left; int y1 = (int) top; int x2 = (int) Math.round(left + width - 0.5000001); int y2 = (int) Math.round(top + height - 0.5000001); if (x2 >= 0 && y2 >= 0) { if (x1 < 0) { x1 = 0; } if (y1 < 0) { y1 = 0; } if (x1 <= x2 && y1 <= y2) { result.add(new RectangularRegion(x1, y1, x2, y2)); } } } } return result; }
From source file:org.commonjava.indy.httprox.HttpProxyTest.java
@Before public void setup() throws Exception { contentMetadata.clear();//from w ww. j a v a 2s . co m core.initGalley(); final TransportManager transports = new TransportManagerImpl( new HttpClientTransport(new HttpImpl(new MemoryPasswordManager()))); core.withTransportManager(transports); core.initMissingComponents(); final HttproxConfig config = new HttproxConfig(); config.setEnabled(true); proxyPort = config.getPort(); final BootOptions bootOpts = new BootOptions(); bootOpts.setBind(HOST); storeManager = new MemoryStoreDataManager(true); final IndyObjectMapper mapper = new IndyObjectMapper(true); final DefaultIndyConfiguration indyConfig = new DefaultIndyConfiguration(); indyConfig.setNotFoundCacheTimeoutSeconds(1); final ExpiringMemoryNotFoundCache nfc = new ExpiringMemoryNotFoundCache(indyConfig); WeftExecutorService rescanService = new PoolWeftExecutorService("test-rescan-executor", (ThreadPoolExecutor) Executors.newCachedThreadPool(), 2, 10f, false, null, null); final DownloadManager downloadManager = new DefaultDownloadManager(storeManager, core.getTransferManager(), core.getLocationExpander(), new MockInstance<>(new MockContentAdvisor()), nfc, rescanService); WeftExecutorService contentAccessService = new PoolWeftExecutorService("test-content-access-executor", (ThreadPoolExecutor) Executors.newCachedThreadPool(), 2, 10f, false, null, null); DirectContentAccess dca = new DefaultDirectContentAccess(downloadManager, contentAccessService); ContentDigester contentDigester = new DefaultContentDigester(dca, new CacheHandle<>("content-metadata", contentMetadata)); final ContentManager contentManager = new DefaultContentManager(storeManager, downloadManager, mapper, new SpecialPathManagerImpl(), new MemoryNotFoundCache(), contentDigester, Collections.emptySet()); DataFileManager dfm = new DataFileManager(temp.newFolder(), new DataFileEventManager()); final TemplatingEngine templates = new TemplatingEngine(new GStringTemplateEngine(), dfm); final ContentController contentController = new ContentController(storeManager, contentManager, templates, mapper, new MimeTyper()); KeycloakConfig kcConfig = new KeycloakConfig(); kcConfig.setEnabled(false); final KeycloakProxyAuthenticator auth = new KeycloakProxyAuthenticator(kcConfig, config); ScriptEngine scriptEngine = new ScriptEngine(dfm); proxy = new HttpProxy(config, bootOpts, new ProxyAcceptHandler(config, storeManager, contentController, auth, core.getCache(), scriptEngine, new MDCManager(), null, null, new CacheProducer(null, cacheManager, null))); proxy.start(); }
From source file:com.android.email.Preferences.java
/** * @deprecated This has been moved to {@link com.android.mail.preferences.MailPrefs}, and is * only here for migration./*from ww w . j a va 2s. c o m*/ */ @Deprecated public Set<String> getWhitelistedSenderAddresses() { try { return parseEmailSet(mSharedPreferences.getString(TRUSTED_SENDERS, "")); } catch (JSONException e) { return Collections.emptySet(); } }
From source file:mitm.application.djigzo.james.mailets.AbstractAddAdditionalCertificates.java
private Set<X509Certificate> validateCertificates(final Set<X509Certificate> certificates) { Set<X509Certificate> validated = null; try {//w ww . j a v a 2s .c o m validated = actionExecutor.executeTransaction(new DatabaseAction<Set<X509Certificate>>() { @Override public Set<X509Certificate> doAction(Session session) throws DatabaseException { Session previousSession = sessionManager.getSession(); sessionManager.setSession(session); try { return validateCertificatesTransacted(certificates); } finally { sessionManager.setSession(previousSession); } } }); } catch (DatabaseException e) { getLogger().error("Error validating certificates.", e); } if (validated == null) { validated = Collections.emptySet(); } return validated; }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.AliasSet.java
/** * Creates a new instance of this class. *///from w ww. j ava 2s . c o m private AliasSet() { fieldMap = new HashMap<String, AliasSet>(); accessed = false; readyEntities = null; readThreads = new HashSet<Triple<InvokeStmt, SootMethod, SootClass>>(); writeThreads = new HashSet<Triple<InvokeStmt, SootMethod, SootClass>>(); readwriteEntities = null; writewriteEntities = null; sigsOfRWSharedFields = null; sigsOfWWSharedFields = null; lockEntities = null; intraThreadInterProcRefEntities = null; multiThreadAccessibility = false; readFields = Collections.emptySet(); writtenFields = Collections.emptySet(); }