Refine search
/** * Specify mappings from type ids to Java classes, if desired. * This allows for synthetic ids in the type id message property, * instead of transferring Java class names. * <p>Default is no custom mappings, i.e. transferring raw Java class names. * @param typeIdMappings a Map with type id values as keys and Java classes as values */ public void setTypeIdMappings(Map<String, Class<?>> typeIdMappings) { this.idClassMappings = new HashMap<>(); typeIdMappings.forEach((id, clazz) -> { this.idClassMappings.put(id, clazz); this.classIdMappings.put(clazz, id); }); }
private StompHeaders(Map<String, List<String>> headers, boolean readOnly) { Assert.notNull(headers, "'headers' must not be null"); if (readOnly) { Map<String, List<String>> map = new LinkedMultiValueMap<>(headers.size()); headers.forEach((key, value) -> map.put(key, Collections.unmodifiableList(value))); this.headers = Collections.unmodifiableMap(map); } else { this.headers = headers; } }
@SuppressWarnings({"unchecked", "rawtypes"}) private void merge(Map<String, Object> output, Map<String, Object> map) { map.forEach((key, value) -> { Object existing = output.get(key); if (value instanceof Map && existing instanceof Map) { // Inner cast required by Eclipse IDE. Map<String, Object> result = new LinkedHashMap<>((Map<String, Object>) existing); merge(result, (Map) value); output.put(key, result); } else { output.put(key, value); } }); }
/** * Create an instance with the given map of file extensions and media types. */ public MappingMediaTypeFileExtensionResolver(@Nullable Map<String, MediaType> mediaTypes) { if (mediaTypes != null) { mediaTypes.forEach((extension, mediaType) -> { String lowerCaseExtension = extension.toLowerCase(Locale.ENGLISH); this.mediaTypes.put(lowerCaseExtension, mediaType); this.fileExtensions.add(mediaType, lowerCaseExtension); this.allFileExtensions.add(lowerCaseExtension); }); } }
private WebDataBinderFactory getDataBinderFactory(HandlerMethod handlerMethod) throws Exception { Class<?> handlerType = handlerMethod.getBeanType(); Set<Method> methods = this.initBinderCache.get(handlerType); if (methods == null) { methods = MethodIntrospector.selectMethods(handlerType, INIT_BINDER_METHODS); this.initBinderCache.put(handlerType, methods); } List<InvocableHandlerMethod> initBinderMethods = new ArrayList<>(); // Global methods first this.initBinderAdviceCache.forEach((clazz, methodSet) -> { if (clazz.isApplicableToBeanType(handlerType)) { Object bean = clazz.resolveBean(); for (Method method : methodSet) { initBinderMethods.add(createInitBinderMethod(bean, method)); } } }); for (Method method : methods) { Object bean = handlerMethod.getBean(); initBinderMethods.add(createInitBinderMethod(bean, method)); } return createDataBinderFactory(initBinderMethods); }
String parameterNameToMatch = provider.parameterNameToUse(parameterName); if (parameterNameToMatch != null) { callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName); Map<String, Object> matchedParameters = new HashMap<>(inParameters.size()); inParameters.forEach((parameterName, parameterValue) -> { String parameterNameToMatch = provider.parameterNameToUse(parameterName); String callParameterName = callParameterNames.get(lowerCase(parameterNameToMatch)); if (callParameterName == null) { if (logger.isDebugEnabled()) { matchedParameters.put(callParameterName, parameterValue); if (matchedParameters.size() < callParameterNames.size()) { for (String parameterName : callParameterNames.keySet()) { String parameterNameToMatch = provider.parameterNameToUse(parameterName); String callParameterName = callParameterNames.get(lowerCase(parameterNameToMatch)); if (!matchedParameters.containsKey(callParameterName) && logger.isInfoEnabled()) { logger.info("Unable to locate the corresponding parameter value for '" + parameterName +
public synchronized MemoryPoolInfo getInfo() { Map<QueryId, List<MemoryAllocation>> memoryAllocations = new HashMap<>(); for (Entry<QueryId, Map<String, Long>> entry : taggedMemoryAllocations.entrySet()) { List<MemoryAllocation> allocations = new ArrayList<>(); if (entry.getValue() != null) { entry.getValue().forEach((tag, allocation) -> allocations.add(new MemoryAllocation(tag, allocation))); } memoryAllocations.put(entry.getKey(), allocations); } return new MemoryPoolInfo(maxBytes, reservedBytes, reservedRevocableBytes, queryMemoryReservations, memoryAllocations, queryMemoryRevocableReservations); }
public List<String> getCurrentlyProcessingSegmentsAndHosts(String tier) { Map<SegmentId, String> segments = currentlyProcessingSegments.get(tier); List<String> retVal = new ArrayList<>(); segments.forEach((segmentId, serverId) -> retVal.add(StringUtils.format("%s ON %s", segmentId, serverId))); return retVal; } }
protected final MultiValueMap<String, String> getParamsMultiValueMap(MockHttpServletRequest request) { Map<String, String[]> params = request.getParameterMap(); MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); params.forEach((name, values) -> { if (params.get(name) != null) { for (String value : values) { multiValueMap.add(name, value); } } }); return multiValueMap; }
private static Map<String, Map<ColumnStatisticType, Block>> createColumnToComputedStatisticsMap(Map<ColumnStatisticMetadata, Block> computedStatistics) { Map<String, Map<ColumnStatisticType, Block>> result = new HashMap<>(); computedStatistics.forEach((metadata, block) -> { Map<ColumnStatisticType, Block> columnStatistics = result.computeIfAbsent(metadata.getColumnName(), key -> new HashMap<>()); columnStatistics.put(metadata.getStatisticType(), block); }); return result.entrySet() .stream() .collect(toImmutableMap(Entry::getKey, entry -> ImmutableMap.copyOf(entry.getValue()))); }
@Test public void enrichAndValidateAttributesWithSingleElementThatOverridesAnArray() { Map<String, Object> attributes = new HashMap<String, Object>() {{ // Intentionally storing 'value' as a single String instead of an array. // put("value", asArray("/foo")); put("value", "/foo"); put("name", "test"); }}; Map<String, Object> expected = new HashMap<String, Object>() {{ put("value", asArray("/foo")); put("path", asArray("/foo")); put("name", "test"); put("method", new RequestMethod[0]); }}; MapAnnotationAttributeExtractor extractor = new MapAnnotationAttributeExtractor(attributes, WebMapping.class, null); Map<String, Object> enriched = extractor.getSource(); assertEquals("attribute map size", expected.size(), enriched.size()); expected.forEach((attr, expectedValue) -> assertThat("for attribute '" + attr + "'", enriched.get(attr), is(expectedValue))); }
private void addTallyMaps(Map<String, long[]> tallyMap, Map<String, long[]> incrementMap) { incrementMap.forEach((key, increments) -> { long[] tallies = tallyMap.get(key); if (tallies == null) { tallyMap.put(key, increments); } else { for (int i = 0; i < INTERVALS.length; i++) { tallies[i] += increments[i]; } } }); }
/** * Transitively retrieve all aliases for the given name. * @param name the target name to find aliases for * @param result the resulting aliases list */ private void retrieveAliases(String name, List<String> result) { this.aliasMap.forEach((alias, registeredName) -> { if (registeredName.equals(name)) { result.add(alias); retrieveAliases(alias, result); } }); }
private ModelFactory getModelFactory(HandlerMethod handlerMethod, WebDataBinderFactory binderFactory) { SessionAttributesHandler sessionAttrHandler = getSessionAttributesHandler(handlerMethod); Class<?> handlerType = handlerMethod.getBeanType(); Set<Method> methods = this.modelAttributeCache.get(handlerType); if (methods == null) { methods = MethodIntrospector.selectMethods(handlerType, MODEL_ATTRIBUTE_METHODS); this.modelAttributeCache.put(handlerType, methods); } List<InvocableHandlerMethod> attrMethods = new ArrayList<>(); // Global methods first this.modelAttributeAdviceCache.forEach((clazz, methodSet) -> { if (clazz.isApplicableToBeanType(handlerType)) { Object bean = clazz.resolveBean(); for (Method method : methodSet) { attrMethods.add(createModelAttributeMethod(binderFactory, bean, method)); } } }); for (Method method : methods) { Object bean = handlerMethod.getBean(); attrMethods.add(createModelAttributeMethod(binderFactory, bean, method)); } return new ModelFactory(attrMethods, binderFactory, sessionAttrHandler); }
/** * Copy constructor which allows for ignoring certain entries. * Used for serialization without non-serializable entries. * @param original the MessageHeaders to copy * @param keysToIgnore the keys of the entries to ignore */ private MessageHeaders(MessageHeaders original, Set<String> keysToIgnore) { this.headers = new HashMap<>(original.headers.size()); original.headers.forEach((key, value) -> { if (!keysToIgnore.contains(key)) { this.headers.put(key, value); } }); }
/** * Construct a new MutablePropertyValues object from a Map. * @param original a Map with property values keyed by property name Strings * @see #addPropertyValues(Map) */ public MutablePropertyValues(@Nullable Map<?, ?> original) { // We can optimize this because it's all new: // There is no replacement of existing property values. if (original != null) { this.propertyValueList = new ArrayList<>(original.size()); original.forEach((attrName, attrValue) -> this.propertyValueList.add( new PropertyValue(attrName.toString(), attrValue))); } else { this.propertyValueList = new ArrayList<>(0); } }