List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:com.netflix.nicobar.core.archive.PathScriptArchiveTest.java
@Test public void testLoadWithModuleSpec() throws Exception { URL rootPathUrl = getClass().getClassLoader().getResource(TEST_MODULE_SPEC_PATH.getResourcePath()); Path rootPath = Paths.get(rootPathUrl.toURI()).toAbsolutePath(); // if the module spec isn't provided, it should be discovered in the path PathScriptArchive scriptArchive = new PathScriptArchive.Builder(rootPath).build(); ScriptModuleSpec moduleSpec = scriptArchive.getModuleSpec(); assertEquals(moduleSpec.getModuleId(), TEST_MODULE_SPEC_PATH.getModuleId()); assertEquals(moduleSpec.getModuleDependencies(), Collections.emptySet()); Map<String, Object> expectedMetadata = new HashMap<String, Object>(); Map<String, String> expectedMetadata1 = new HashMap<String, String>(); expectedMetadata1.put("nestedKey1", "metadataValue1"); expectedMetadata1.put("nestedKey2", "metadataValue2"); expectedMetadata.put("metadataName1", expectedMetadata1); expectedMetadata.put("metadataName2", 2.0); expectedMetadata.put("metadataName3", Arrays.asList(1.0, 2.0, 3.0)); Map<String, Object> somedata = moduleSpec.getMetadata(); assertEquals(somedata, expectedMetadata); }
From source file:th.co.geniustree.dental.model.Employee.java
@Override public Collection<? extends GrantedAuthority> getAuthorities() { // return roles; return Collections.emptySet(); }
From source file:io.apicurio.hub.core.beans.ApiDesignResourceInfoTest.java
/** * Test method for {@link io.apicurio.hub.core.beans.ApiDesignResourceInfo#fromContent(java.lang.String)}. *//*from www .j a va 2 s . c om*/ @Test public void testFromContent_20_Json() throws Exception { String content = IOUtils.toString( ApiDesignResourceInfoTest.class.getResourceAsStream("ApiDesignResourceInfoTest_2.0.json")); ApiDesignResourceInfo info = ApiDesignResourceInfo.fromContent(content); Assert.assertNotNull(info); Assert.assertEquals(FormatType.JSON, info.getFormat()); Assert.assertEquals("Rate Limiter API", info.getName()); Assert.assertEquals("A REST API used by clients to access the standalone Rate Limiter micro-service.", info.getDescription()); Assert.assertEquals(Collections.emptySet(), info.getTags()); }
From source file:com.navercorp.pinpoint.web.dao.hbase.HbaseHostApplicationMapDao.java
@Override public Set<AcceptApplication> findAcceptApplicationName(Application fromApplication, Range range) { if (fromApplication == null) { throw new NullPointerException("fromApplication must not be null"); }/* w ww . ja v a 2 s . c om*/ final Scan scan = createScan(fromApplication, range); TableName hostApplicationMapTableName = tableNameProvider .getTableName(HbaseTable.HOST_APPLICATION_MAP_VER2); final List<List<AcceptApplication>> result = hbaseOperations2.findParallel(hostApplicationMapTableName, scan, acceptApplicationRowKeyDistributor, hostApplicationMapperVer2, HOST_APPLICATION_MAP_VER2_NUM_PARTITIONS); if (CollectionUtils.isNotEmpty(result)) { final Set<AcceptApplication> resultSet = new HashSet<>(); for (List<AcceptApplication> resultList : result) { resultSet.addAll(resultList); } logger.debug("findAcceptApplicationName result:{}", resultSet); return resultSet; } else { return Collections.emptySet(); } }
From source file:com.streamsets.lib.security.http.SSOUserAuthenticator.java
String getRequestUrl(HttpServletRequest request) {
return getRequestUrl(request, Collections.emptySet()).toString();
}
From source file:com.devicehive.resource.impl.DeviceNotificationResourceImpl.java
/** * {@inheritDoc}//from w ww . j a v a 2 s. co m */ @Override public void query(String guid, String startTs, String endTs, String notification, String sortField, String sortOrderSt, Integer take, Integer skip, @Suspended final AsyncResponse asyncResponse) { logger.debug("Device notification query requested for device {}", guid); final Date timestampSt = TimestampQueryParamParser.parse(startTs); final Date timestampEnd = TimestampQueryParamParser.parse(endTs); DeviceVO byGuidWithPermissionsCheck = deviceService.getDeviceWithNetworkAndDeviceClass(guid); if (byGuidWithPermissionsCheck == null) { ErrorResponse errorCode = new ErrorResponse(NOT_FOUND.getStatusCode(), String.format(Messages.DEVICE_NOT_FOUND, guid)); Response response = ResponseFactory.response(NOT_FOUND, errorCode); asyncResponse.resume(response); } else { Set<String> notificationNames = StringUtils.isNoneEmpty(notification) ? Collections.singleton(notification) : Collections.emptySet(); notificationService.find(Collections.singleton(guid), notificationNames, timestampSt, timestampEnd) .thenApply(notifications -> { final Comparator<DeviceNotification> comparator = CommandResponseFilterAndSort .buildDeviceNotificationComparator(sortField); final Boolean reverse = sortOrderSt == null ? null : "desc".equalsIgnoreCase(sortOrderSt); final List<DeviceNotification> sortedDeviceNotifications = CommandResponseFilterAndSort .orderAndLimit(notifications, comparator, reverse, skip, take); return ResponseFactory.response(OK, sortedDeviceNotifications, JsonPolicyDef.Policy.NOTIFICATION_TO_CLIENT); }).thenAccept(asyncResponse::resume); } }
From source file:io.seldon.recommendation.baseline.MostPopularInSessionRecommender.java
/** * Note this recommender does not respect any dimensions passed in *//*from www . ja va 2 s. c o m*/ @Override public ItemRecommendationResultSet recommend(String client, Long user, Set<Integer> dimensions, int maxRecsCount, RecommendationContext ctxt, List<Long> recentItemInteractions) { RecommendationContext.OptionsHolder options = ctxt.getOptsHolder(); DimPopularityStore store = itemsManager.getClientStore(client, options); if (store == null) { if (logger.isDebugEnabled()) logger.debug("Failed to find popular session data for client " + client); return new ItemRecommendationResultSet( Collections.<ItemRecommendationResultSet.ItemRecommendationResult>emptyList(), name); } String attrs = options.getStringOption(ATTRS_PROPERTY_NAME); int maxDepth = options.getIntegerOption(DEPTH_PROPERTY_NAME); ConsumerBean c = new ConsumerBean(client); String[] attrNames = attrs.split(","); Set<Long> exclusions = Collections.emptySet(); if (ctxt.getMode() == RecommendationContext.MODE.EXCLUSION) { exclusions = ctxt.getContextItems(); } if (logger.isDebugEnabled()) { logger.debug("user " + user + " recentItems:" + recentItemInteractions.toString() + " depth:" + maxDepth + " attrs " + attrs); } Map<Long, Double> scores = new HashMap<>(); for (int depth = 0; depth < maxDepth; depth++) { if (recentItemInteractions.size() <= depth) break; long recentItem = recentItemInteractions.get(depth); Map<String, Integer> attrDims = itemService.getDimensionIdsForItem(c, recentItem); double lowestScore = 1.0; if (logger.isDebugEnabled()) logger.debug("Looking at item " + recentItem + " has attrDim size " + attrDims.size()); for (String attr : attrNames) { Integer dim = attrDims.get(attr); if (dim != null) { List<ItemCount> counts = store.getTopItemsForDimension(dim); if (counts != null) { double maxCount = 0; double lowScore = 1.0; for (ItemCount ic : counts) { if (!exclusions.contains(ic.item)) { Map<String, Integer> attrDimsCandidate = itemService.getDimensionIdsForItem(c, ic.item); if (CollectionUtils.containsAny(dimensions, attrDimsCandidate.values()) || dimensions.contains(Constants.DEFAULT_DIMENSION)) { if (logger.isDebugEnabled()) logger.debug("Adding item " + ic.item + " from dimension " + attr); if (maxCount == 0) maxCount = ic.count; double normCount = (ic.count / maxCount) * lowestScore; //scale to be a score lower than previous values if any if (scores.containsKey(ic.item)) scores.put(ic.item, scores.get(ic.item) + normCount); else scores.put(ic.item, normCount); lowScore = normCount; if (scores.size() >= maxRecsCount) break; } else { if (logger.isDebugEnabled()) logger.debug("Ignoring prospective item " + ic.item + " as not in dimensions " + dimensions.toString()); } } else { if (logger.isDebugEnabled()) logger.debug("Excluding item " + ic.item); } } lowestScore = lowScore;//update lowest from this loop } else { if (logger.isDebugEnabled()) logger.debug("No counts for dimension " + dim + " attribute name " + attr); } } else { logger.warn("Failed to find attr " + attr + " for item " + recentItem); } if (scores.size() >= maxRecsCount) break; } } Map<Long, Double> scaledScores = RecommendationUtils.rescaleScoresToOne(scores, maxRecsCount); List<ItemRecommendationResultSet.ItemRecommendationResult> results = new ArrayList<>(); for (Map.Entry<Long, Double> e : scaledScores.entrySet()) { results.add(new ItemRecommendationResultSet.ItemRecommendationResult(e.getKey(), e.getValue().floatValue())); } if (logger.isDebugEnabled()) logger.debug("Returning " + results.size() + " recommendations"); return new ItemRecommendationResultSet(results, name); }
From source file:bjerne.gallery.service.impl.VideoConversionServiceImpl.java
@Override public Collection<String> getAvailableVideoModes() { Set<String> conversionModeNames = conversionModes != null ? new HashSet<>(conversionModes.keySet()) : Collections.emptySet(); LOG.debug("Returning conversion modes: {}", conversionModeNames); return conversionModeNames; }
From source file:ddf.catalog.transformer.csv.CsvQueryResponseTransformer.java
/** * @param upstreamResponse the SourceResponse to be converted. * @param arguments this transformer accepts 3 parameters in the 'arguments' map. 1) key: * 'hiddenFields' value: a java.util.Set containing Attribute names (as Strings) to be * excluded from the output. 2) key: 'attributeOrder' value: a java.utilList containing * Attribute name (as Strings) to identify the order that the columns will appear in the * output. 3) key: 'aliases' value: a java.util.Map whose keys are attribute names and values * are the how that attribute column should be aliased in the output. For example, if the key * is 'title' and the value is 'Product' then the resulting CSV will have a column name of * 'Product' instead of 'title'.//w w w. ja va 2s . c om * @return a BinaryContent object that contains an InputStream with the CSV content. * @throws CatalogTransformerException during processing, the CSV output is written to an * Appendable, whose 'append()' method signature declares that it throws IOException. When * that Appendable throws IOException, this class will theoretically convert that into a * CatalogTransformerException and raise that. Because this implementation uses a * StringBuilder which doesn't throw IOException, this will never occur. */ @Override public BinaryContent transform(SourceResponse upstreamResponse, Map<String, Serializable> arguments) throws CatalogTransformerException { Set<String> hiddenFields = Optional.ofNullable((Set<String>) arguments.get(HIDDEN_FIELDS_KEY)) .orElse(Collections.emptySet()); List<String> attributeOrder = Optional.ofNullable((List<String>) arguments.get(COLUMN_ORDER_KEY)) .orElse(Collections.emptyList()); Map<String, String> columnAliasMap = Optional .ofNullable((Map<String, String>) arguments.get(COLUMN_ALIAS_KEY)).orElse(Collections.emptyMap()); Set<AttributeDescriptor> allAttributeDescriptors = getAllRequestedAttributes(upstreamResponse.getResults(), hiddenFields); List<AttributeDescriptor> sortedAttributeDescriptors = sortAttributes(allAttributeDescriptors, attributeOrder); Appendable csv = writeSearchResultsToCsv(upstreamResponse, columnAliasMap, sortedAttributeDescriptors); return createResponse(csv); }
From source file:com.opengamma.engine.depgraph.ResolutionState.java
public ResolutionState(final ValueRequirement valueRequirement, final ValueSpecification valueSpecification, final ParameterizedFunction parameterizedFunction, final DependencyNode dependencyNode) { this(valueRequirement); final Node node = new Node(valueSpecification, parameterizedFunction, dependencyNode); node._inputStates = Collections.emptySet(); _nodes.add(node);//from w ww . ja v a 2 s .c o m }