List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:pl.edu.agh.samm.db.impl.ActionExecutionDAO.java
@Override public Set<String> loadAllActionsUris() { return new HashSet<String>( getSimpleJdbcTemplate().query(SQL_QUERY_ACTION_URIS, new ParameterizedRowMapper<String>() { @Override// w w w. j av a 2 s . c o m public String mapRow(ResultSet arg0, int arg1) throws SQLException { return arg0.getString(1); } }, Collections.emptyMap())); }
From source file:com.erudika.para.persistence.MockDAO.java
@Override @SuppressWarnings("unchecked") public <P extends ParaObject> Map<String, P> readAll(String appid, List<String> keys, boolean getAllColumns) { if (keys == null || StringUtils.isBlank(appid)) { return Collections.emptyMap(); }// w w w . j av a 2s.c om Map<String, P> results = new LinkedHashMap<String, P>(keys.size()); for (String key : keys) { if (getMap(appid).containsKey(key)) { results.put(key, (P) read(key)); } } logger.debug("DAO.readAll() {}", results.size()); return results; }
From source file:com.wso2telco.core.userprofile.permission.impl.WSO2PermissionBuilder.java
/** * This will build the permision tree using given users name *//*from w ww.j a v a 2s. c om*/ public Map<String, Object> build(final String userName) throws BusinessException { Map<String, Object> permisionTree = Collections.emptyMap(); RetunEntitiy retunItem = new RetunEntitiy(); try { UserRoleProsser userRoleRetriever = new UserRoleProsser(); UIPermissionNode uiPermissionTree = null; List<String> currentUserRoleList = userRoleRetriever.getRolesByUserName(userName); /** * None of the roles are assign for the user */ if (currentUserRoleList.isEmpty()) { throw new BusinessException("No roles assigned for user :" + userName); } for (Iterator<String> iterator = currentUserRoleList.iterator(); iterator.hasNext();) { String roleName = iterator.next(); UIPermissionNode rolePermissions = userAdminStub.getRolePermissions(roleName); /** * if the permission node is empty */ if (rolePermissions == null || rolePermissions.getNodeList() == null) { continue; } /** * filter out ui permission only */ Optional<UIPermissionNode> optNode = Arrays.stream(rolePermissions.getNodeList()) .filter(rowItem -> rowItem.getDisplayName() .equalsIgnoreCase(UserRolePermissionType.UI_PERMISSION.getTObject())) .findFirst(); /** * check for existence of node */ if (optNode.isPresent()) { uiPermissionTree = optNode.get(); if (uiPermissionTree.getNodeList() != null && uiPermissionTree.getNodeList().length > 0) { retunItem = popUserRolePermissions(uiPermissionTree.getNodeList()); if (retunItem.atLeastOneSelected) { break; } } else { /** * if the current role does not contain Ui permission then continue */ continue; } } } if (retunItem.returnMap.isEmpty()) { throw new BusinessException(UserRolePermissionType.UI_PERMISSION.getTObject() + " not assigned for the user :" + userName + " , assigned roles :[ " + StringUtils.join(currentUserRoleList, ",") + "]"); } } catch (RemoteException | UserAdminUserAdminException e) { log.error("UIPermission.build", e); throw new BusinessException(GenaralError.INTERNAL_SERVER_ERROR); } if (retunItem.returnMap.isEmpty()) { log.warn(" No ui permission tree found for " + userName); return Collections.emptyMap(); } else { return retunItem.returnMap; } }
From source file:io.cloudslang.lang.runtime.bindings.LoopsBindingTest.java
@Test public void whenExpressionIsEmptyThrowsException() throws Exception { Context context = mock(Context.class); when(scriptEvaluator.evalExpr(anyString(), anyMapOf(String.class, Value.class), eq(EMPTY_SET), eq(EMPTY_FUNCTION_SET))).thenReturn(ValueFactory.create(Lists.newArrayList())); Map<String, Value> langVars = Collections.emptyMap(); when(context.getImmutableViewOfLanguageVariables()).thenReturn(langVars); exception.expectMessage("expression is empty"); exception.expect(RuntimeException.class); loopsBinding.getOrCreateLoopCondition(createBasicForStatement(), context, EMPTY_SET, "node"); }
From source file:com.feilong.core.lang.ArrayUtilTemp.java
/** * <code>array</code> .//from www. j av a 2s .c o m * * <p> * {@link LinkedHashMap} ,key,value;key?? <code>array</code>??? * </p> * * <h3>:</h3> * <blockquote> * * <pre class="code"> * Integer[] array = { 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8 }; * Map{@code <Integer, List<Integer>>} group = ArrayUtil.group(array); * LOGGER.debug(JsonUtil.format(group)); * </pre> * * <b>:</b> * * <pre class="code"> { "1": [ 1, 1, 1 ], "2": [ 2, 2 ], "3": [3], "4": [4], "5": [ 5, 5 ], "6": [6], "7": [7], "8": [ 8, 8 ] } * </pre> * * </blockquote> * * @param <T> * the generic type * @param array * the array * @return <code>array</code> null, {@link Collections#emptyMap()}<br> * @since 1.0.8 */ public static <T> Map<T, List<T>> group(T[] array) { if (null == array) { return Collections.emptyMap(); } Map<T, List<T>> map = newLinkedHashMap(array.length); for (T t : array) { MapUtil.putMultiValue(map, t, t); } return map; }
From source file:org.elasticsearch.xpack.ml.integration.DatafeedJobsRestIT.java
private void setupUser(String user, List<String> roles) throws IOException { String password = new String(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING.getChars()); String json = "{" + " \"password\" : \"" + password + "\"," + " \"roles\" : [ " + roles.stream().map(unquoted -> "\"" + unquoted + "\"").collect(Collectors.joining(", ")) + " ]" + "}"; client().performRequest("put", "_xpack/security/user/" + user, Collections.emptyMap(), new StringEntity(json, ContentType.APPLICATION_JSON)); }
From source file:com.ikanow.aleph2.enrichment.utils.services.JsScriptEngineService.java
@Override public void onStageInitialize(IEnrichmentModuleContext context, DataBucketBean bucket, EnrichmentControlMetadataBean control, final Tuple2<ProcessingStage, ProcessingStage> previous_next, final Optional<List<String>> grouping_fields) { // This is currently fixed: java_api.set(true);// w ww. j a v a 2s. c o m final JsScriptEngineBean config_bean = BeanTemplateUtils .from(Optional.ofNullable(control.config()).orElse(Collections.emptyMap()), JsScriptEngineBean.class) .get(); _config.trySet(config_bean); _context.trySet(context); _control.trySet(control); // Initialize script engine: ScriptEngineManager manager = new ScriptEngineManager(); _engine.trySet(manager.getEngineByName("JavaScript")); _script_context.trySet(_engine.get().getContext()); // (actually not needed since we're compiling things) _bucket_logger.set(context.getLogger(Optional.of(bucket))); // Load globals: _engine.get().put("_a2_global_context", _context.get()); _engine.get().put("_a2_global_grouping_fields", grouping_fields.orElse(Collections.emptyList())); _engine.get().put("_a2_global_previous_stage", previous_next._1().toString()); _engine.get().put("_a2_global_next_stage", previous_next._2().toString()); _engine.get().put("_a2_global_bucket", bucket); _engine.get().put("_a2_global_config", BeanTemplateUtils.configureMapper(Optional.empty()) .convertValue(config_bean.config(), JsonNode.class)); _engine.get().put("_a2_global_mapper", BeanTemplateUtils.configureMapper(Optional.empty())); _engine.get().put("_a2_bucket_logger", _bucket_logger.optional().orElse(null)); _engine.get().put("_a2_enrichment_name", Optional.ofNullable(control.name()).orElse("no_name")); // Load the resources: Stream.concat(config_bean.imports().stream(), Stream.of("aleph2_js_globals_before.js", "", "aleph2_js_globals_after.js")) .flatMap(Lambdas.flatWrap_i(import_path -> { try { if (import_path.equals("")) { // also import the user script just before here return config_bean.script(); } else return IOUtils.toString( JsScriptEngineService.class.getClassLoader().getResourceAsStream(import_path), "UTF-8"); } catch (Throwable e) { _bucket_logger.optional().ifPresent(l -> l.log(Level.ERROR, ErrorUtils.lazyBuildMessage( false, () -> this.getClass().getSimpleName(), () -> Optional.ofNullable(control.name()).orElse("no_name") + ".onStageInitialize", () -> null, () -> ErrorUtils.get("Error initializing stage {0} (script {1}): {2}", Optional.ofNullable(control.name()).orElse("(no name)"), import_path, e.getMessage()), () -> ImmutableMap.<String, Object>of("full_error", ErrorUtils.getLongForm("{0}", e))))); _logger.error(ErrorUtils.getLongForm("onStageInitialize: {0}", e)); throw e; // ignored } })).forEach(Lambdas.wrap_consumer_i(script -> { try { _engine.get().eval(script); } catch (Throwable e) { _bucket_logger.optional().ifPresent(l -> l.log(Level.ERROR, ErrorUtils.lazyBuildMessage( false, () -> this.getClass().getSimpleName(), () -> Optional.ofNullable(control.name()).orElse("no_name") + ".onStageInitialize", () -> null, () -> ErrorUtils.get("Error initializing stage {0} (main script): {1}", Optional.ofNullable(control.name()).orElse("(no name)"), e.getMessage()), () -> ImmutableMap.<String, Object>of("full_error", ErrorUtils.getLongForm("{0}", e))))); _logger.error(ErrorUtils.getLongForm("onStageInitialize: {0}", e)); throw e; // ignored } })); ; }
From source file:com.liferay.wiki.util.WikiCacheHelper.java
public Map<String, Boolean> getOutgoingLinks(WikiPage page, WikiEngineRenderer wikiEngineRenderer) throws PageContentException { String key = _encodeKey(page.getNodeId(), page.getTitle(), _OUTGOING_LINKS); Map<String, Boolean> links = (Map<String, Boolean>) _portalCache.get(key); if (links == null) { WikiEngine wikiEngine = wikiEngineRenderer.fetchWikiEngine(page.getFormat()); if (wikiEngine != null) { links = wikiEngine.getOutgoingLinks(page); } else {//w ww .j a v a 2s. com links = Collections.emptyMap(); } PortalCacheHelperUtil.putWithoutReplicator(_portalCache, key, (Serializable) links); } return links; }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.KubernetesV2SearchProvider.java
@Override public SearchResultSet search(String query, List<String> types, Integer pageNumber, Integer pageSize) { return search(query, types, pageNumber, pageSize, Collections.emptyMap()); }
From source file:com.linkedin.pinot.broker.routing.builder.DefaultRealtimeRoutingTableBuilder.java
@Override public Map<String, List<String>> getRoutingTable(RoutingTableLookupRequest request) { boolean forceLLC = false; boolean forceHLC = false; for (String routingOption : request.getRoutingOptions()) { if (routingOption.equalsIgnoreCase("FORCE_HLC")) { forceHLC = true;/*w w w.j a va 2 s . com*/ } if (routingOption.equalsIgnoreCase("FORCE_LLC")) { forceLLC = true; } } if (forceHLC && forceLLC) { throw new RuntimeException("Trying to force routing to both HLC and LLC at the same time"); } if (forceLLC) { return _realtimeLLCRoutingTableBuilder.getRoutingTable(request); } else if (forceHLC) { return _realtimeHLCRoutingTableBuilder.getRoutingTable(request); } else { if (_hasLLC) { return _realtimeLLCRoutingTableBuilder.getRoutingTable(request); } else if (_hasHLC) { return _realtimeHLCRoutingTableBuilder.getRoutingTable(request); } else { return Collections.emptyMap(); } } }