Merge pull request #1451 from diguage:lambda-map
* pr/1451: Polish "Refact iterator of Map with Java 8 forEach" Refact iterator of Map with Java 8 forEach
This commit is contained in:
commit
ca1e682dc4
|
|
@ -87,9 +87,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||||
// There is no replacement of existing property values.
|
// There is no replacement of existing property values.
|
||||||
if (original != null) {
|
if (original != null) {
|
||||||
this.propertyValueList = new ArrayList<>(original.size());
|
this.propertyValueList = new ArrayList<>(original.size());
|
||||||
for (Map.Entry<?, ?> entry : original.entrySet()) {
|
original.forEach((attrName, attrValue) -> this.propertyValueList.add(
|
||||||
this.propertyValueList.add(new PropertyValue(entry.getKey().toString(), entry.getValue()));
|
new PropertyValue(attrName.toString(), attrValue)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.propertyValueList = new ArrayList<>(0);
|
this.propertyValueList = new ArrayList<>(0);
|
||||||
|
|
@ -151,9 +150,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||||
*/
|
*/
|
||||||
public MutablePropertyValues addPropertyValues(@Nullable Map<?, ?> other) {
|
public MutablePropertyValues addPropertyValues(@Nullable Map<?, ?> other) {
|
||||||
if (other != null) {
|
if (other != null) {
|
||||||
for (Map.Entry<?, ?> entry : other.entrySet()) {
|
other.forEach((attrName, attrValue) -> addPropertyValue(
|
||||||
addPropertyValue(new PropertyValue(entry.getKey().toString(), entry.getValue()));
|
new PropertyValue(attrName.toString(), attrValue)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -457,9 +457,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||||
String actualPropertyName =
|
String actualPropertyName =
|
||||||
(nestedProperty != null ? PropertyAccessorUtils.getPropertyName(nestedProperty) : null);
|
(nestedProperty != null ? PropertyAccessorUtils.getPropertyName(nestedProperty) : null);
|
||||||
if (this.customEditors != null) {
|
if (this.customEditors != null) {
|
||||||
for (Map.Entry<Class<?>, PropertyEditor> entry : this.customEditors.entrySet()) {
|
this.customEditors.forEach(target::registerCustomEditor);
|
||||||
target.registerCustomEditor(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.customEditorsForPath != null) {
|
if (this.customEditorsForPath != null) {
|
||||||
for (Map.Entry<String, CustomEditorHolder> entry : this.customEditorsForPath.entrySet()) {
|
for (Map.Entry<String, CustomEditorHolder> entry : this.customEditorsForPath.entrySet()) {
|
||||||
|
|
|
||||||
|
|
@ -72,14 +72,12 @@ public class ConstructorArgumentValues {
|
||||||
*/
|
*/
|
||||||
public void addArgumentValues(@Nullable ConstructorArgumentValues other) {
|
public void addArgumentValues(@Nullable ConstructorArgumentValues other) {
|
||||||
if (other != null) {
|
if (other != null) {
|
||||||
for (Map.Entry<Integer, ValueHolder> entry : other.indexedArgumentValues.entrySet()) {
|
other.indexedArgumentValues.forEach(
|
||||||
addOrMergeIndexedArgumentValue(entry.getKey(), entry.getValue().copy());
|
(index, argValue) -> addOrMergeIndexedArgumentValue(index, argValue.copy())
|
||||||
}
|
);
|
||||||
for (ValueHolder valueHolder : other.genericArgumentValues) {
|
other.genericArgumentValues.stream()
|
||||||
if (!this.genericArgumentValues.contains(valueHolder)) {
|
.filter(valueHolder -> !this.genericArgumentValues.contains(valueHolder))
|
||||||
addOrMergeGenericArgumentValue(valueHolder.copy());
|
.forEach(valueHolder -> addOrMergeGenericArgumentValue(valueHolder.copy()));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -145,11 +145,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.customEditors != null) {
|
if (this.customEditors != null) {
|
||||||
for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
|
this.customEditors.forEach(beanFactory::registerCustomEditor);
|
||||||
Class<?> requiredType = entry.getKey();
|
|
||||||
Class<? extends PropertyEditor> propertyEditorClass = entry.getValue();
|
|
||||||
beanFactory.registerCustomEditor(requiredType, propertyEditorClass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -18,7 +18,6 @@ package org.springframework.beans.factory.config;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
@ -123,9 +122,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean<Map
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
private void merge(Map<String, Object> output, Map<String, Object> map) {
|
private void merge(Map<String, Object> output, Map<String, Object> map) {
|
||||||
for (Entry<String, Object> entry : map.entrySet()) {
|
map.forEach((key, value) -> {
|
||||||
String key = entry.getKey();
|
|
||||||
Object value = entry.getValue();
|
|
||||||
Object existing = output.get(key);
|
Object existing = output.get(key);
|
||||||
if (value instanceof Map && existing instanceof Map) {
|
if (value instanceof Map && existing instanceof Map) {
|
||||||
// Inner cast required by Eclipse IDE.
|
// Inner cast required by Eclipse IDE.
|
||||||
|
|
@ -136,7 +133,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean<Map
|
||||||
else {
|
else {
|
||||||
output.put(key, value);
|
output.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -202,12 +202,10 @@ public abstract class YamlProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Object, Object> map = (Map<Object, Object>) object;
|
Map<Object, Object> map = (Map<Object, Object>) object;
|
||||||
for (Entry<Object, Object> entry : map.entrySet()) {
|
map.forEach((key, value) -> {
|
||||||
Object value = entry.getValue();
|
|
||||||
if (value instanceof Map) {
|
if (value instanceof Map) {
|
||||||
value = asMap(value);
|
value = asMap(value);
|
||||||
}
|
}
|
||||||
Object key = entry.getKey();
|
|
||||||
if (key instanceof CharSequence) {
|
if (key instanceof CharSequence) {
|
||||||
result.put(key.toString(), value);
|
result.put(key.toString(), value);
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +213,7 @@ public abstract class YamlProcessor {
|
||||||
// It has to be a map key in this case
|
// It has to be a map key in this case
|
||||||
result.put("[" + key.toString() + "]", value);
|
result.put("[" + key.toString() + "]", value);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,9 +169,7 @@ class BeanDefinitionValueResolver {
|
||||||
else if (value instanceof ManagedProperties) {
|
else if (value instanceof ManagedProperties) {
|
||||||
Properties original = (Properties) value;
|
Properties original = (Properties) value;
|
||||||
Properties copy = new Properties();
|
Properties copy = new Properties();
|
||||||
for (Map.Entry<Object, Object> propEntry : original.entrySet()) {
|
original.forEach((propKey, propValue) -> {
|
||||||
Object propKey = propEntry.getKey();
|
|
||||||
Object propValue = propEntry.getValue();
|
|
||||||
if (propKey instanceof TypedStringValue) {
|
if (propKey instanceof TypedStringValue) {
|
||||||
propKey = evaluate((TypedStringValue) propKey);
|
propKey = evaluate((TypedStringValue) propKey);
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +182,7 @@ class BeanDefinitionValueResolver {
|
||||||
"Error converting Properties key/value pair for " + argName + ": resolved to null");
|
"Error converting Properties key/value pair for " + argName + ": resolved to null");
|
||||||
}
|
}
|
||||||
copy.put(propKey, propValue);
|
copy.put(propKey, propValue);
|
||||||
}
|
});
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
else if (value instanceof TypedStringValue) {
|
else if (value instanceof TypedStringValue) {
|
||||||
|
|
|
||||||
|
|
@ -1225,9 +1225,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
|
|
||||||
private FactoryAwareOrderSourceProvider createFactoryAwareOrderSourceProvider(Map<String, Object> beans) {
|
private FactoryAwareOrderSourceProvider createFactoryAwareOrderSourceProvider(Map<String, Object> beans) {
|
||||||
IdentityHashMap<Object, String> instancesToBeanNames = new IdentityHashMap<>();
|
IdentityHashMap<Object, String> instancesToBeanNames = new IdentityHashMap<>();
|
||||||
for (Map.Entry<String, Object> entry : beans.entrySet()) {
|
beans.forEach((beanName, instance) -> instancesToBeanNames.put(instance, beanName));
|
||||||
instancesToBeanNames.put(entry.getValue(), entry.getKey());
|
|
||||||
}
|
|
||||||
return new FactoryAwareOrderSourceProvider(instancesToBeanNames);
|
return new FactoryAwareOrderSourceProvider(instancesToBeanNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,7 @@ public class CustomMapEditor extends PropertyEditorSupport {
|
||||||
// Convert Map elements.
|
// Convert Map elements.
|
||||||
Map<?, ?> source = (Map<?, ?>) value;
|
Map<?, ?> source = (Map<?, ?>) value;
|
||||||
Map<Object, Object> target = createMap(this.mapType, source.size());
|
Map<Object, Object> target = createMap(this.mapType, source.size());
|
||||||
for (Map.Entry<?, ?> entry : source.entrySet()) {
|
source.forEach((key, val) -> target.put(convertKey(key), convertValue(val)));
|
||||||
target.put(convertKey(entry.getKey()), convertValue(entry.getValue()));
|
|
||||||
}
|
|
||||||
super.setValue(target);
|
super.setValue(target);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -57,9 +57,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
|
||||||
* @see CacheOperation
|
* @see CacheOperation
|
||||||
*/
|
*/
|
||||||
public void setNameMap(Map<String, Collection<CacheOperation>> nameMap) {
|
public void setNameMap(Map<String, Collection<CacheOperation>> nameMap) {
|
||||||
for (Map.Entry<String, Collection<CacheOperation>> entry : nameMap.entrySet()) {
|
nameMap.forEach(this::addCacheMethod);
|
||||||
addCacheMethod(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -351,9 +351,8 @@ class ConfigurationClassBeanDefinitionReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBeanDefinitionsFromRegistrars(Map<ImportBeanDefinitionRegistrar, AnnotationMetadata> registrars) {
|
private void loadBeanDefinitionsFromRegistrars(Map<ImportBeanDefinitionRegistrar, AnnotationMetadata> registrars) {
|
||||||
for (Map.Entry<ImportBeanDefinitionRegistrar, AnnotationMetadata> entry : registrars.entrySet()) {
|
registrars.forEach((registrar, metadata) ->
|
||||||
entry.getKey().registerBeanDefinitions(entry.getValue(), this.registry);
|
registrar.registerBeanDefinitions(metadata, this.registry));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,13 +75,12 @@ public class CandidateComponentsIndex {
|
||||||
private static MultiValueMap<String, String> parseIndex(List<Properties> content) {
|
private static MultiValueMap<String, String> parseIndex(List<Properties> content) {
|
||||||
MultiValueMap<String, String> index = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> index = new LinkedMultiValueMap<>();
|
||||||
for (Properties entry : content) {
|
for (Properties entry : content) {
|
||||||
for (Map.Entry<Object, Object> entries : entry.entrySet()) {
|
entry.forEach((type, values) -> {
|
||||||
String type = (String) entries.getKey();
|
String[] stereotypes = ((String) values).split(",");
|
||||||
String[] stereotypes = ((String) entries.getValue()).split(",");
|
|
||||||
for (String stereotype : stereotypes) {
|
for (String stereotype : stereotypes) {
|
||||||
index.add(stereotype, type);
|
index.add(stereotype, (String) type);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||||
private void startBeans(boolean autoStartupOnly) {
|
private void startBeans(boolean autoStartupOnly) {
|
||||||
Map<String, Lifecycle> lifecycleBeans = getLifecycleBeans();
|
Map<String, Lifecycle> lifecycleBeans = getLifecycleBeans();
|
||||||
Map<Integer, LifecycleGroup> phases = new HashMap<>();
|
Map<Integer, LifecycleGroup> phases = new HashMap<>();
|
||||||
for (Map.Entry<String, ? extends Lifecycle> entry : lifecycleBeans.entrySet()) {
|
lifecycleBeans.forEach((beanName, bean) -> {
|
||||||
Lifecycle bean = entry.getValue();
|
|
||||||
if (!autoStartupOnly || (bean instanceof SmartLifecycle && ((SmartLifecycle) bean).isAutoStartup())) {
|
if (!autoStartupOnly || (bean instanceof SmartLifecycle && ((SmartLifecycle) bean).isAutoStartup())) {
|
||||||
int phase = getPhase(bean);
|
int phase = getPhase(bean);
|
||||||
LifecycleGroup group = phases.get(phase);
|
LifecycleGroup group = phases.get(phase);
|
||||||
|
|
@ -141,9 +140,9 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||||
group = new LifecycleGroup(phase, this.timeoutPerShutdownPhase, lifecycleBeans, autoStartupOnly);
|
group = new LifecycleGroup(phase, this.timeoutPerShutdownPhase, lifecycleBeans, autoStartupOnly);
|
||||||
phases.put(phase, group);
|
phases.put(phase, group);
|
||||||
}
|
}
|
||||||
group.add(entry.getKey(), bean);
|
group.add(beanName, bean);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (!phases.isEmpty()) {
|
if (!phases.isEmpty()) {
|
||||||
List<Integer> keys = new ArrayList<>(phases.keySet());
|
List<Integer> keys = new ArrayList<>(phases.keySet());
|
||||||
Collections.sort(keys);
|
Collections.sort(keys);
|
||||||
|
|
@ -187,16 +186,15 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||||
private void stopBeans() {
|
private void stopBeans() {
|
||||||
Map<String, Lifecycle> lifecycleBeans = getLifecycleBeans();
|
Map<String, Lifecycle> lifecycleBeans = getLifecycleBeans();
|
||||||
Map<Integer, LifecycleGroup> phases = new HashMap<>();
|
Map<Integer, LifecycleGroup> phases = new HashMap<>();
|
||||||
for (Map.Entry<String, Lifecycle> entry : lifecycleBeans.entrySet()) {
|
lifecycleBeans.forEach((beanName, bean) -> {
|
||||||
Lifecycle bean = entry.getValue();
|
|
||||||
int shutdownOrder = getPhase(bean);
|
int shutdownOrder = getPhase(bean);
|
||||||
LifecycleGroup group = phases.get(shutdownOrder);
|
LifecycleGroup group = phases.get(shutdownOrder);
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
group = new LifecycleGroup(shutdownOrder, this.timeoutPerShutdownPhase, lifecycleBeans, false);
|
group = new LifecycleGroup(shutdownOrder, this.timeoutPerShutdownPhase, lifecycleBeans, false);
|
||||||
phases.put(shutdownOrder, group);
|
phases.put(shutdownOrder, group);
|
||||||
}
|
}
|
||||||
group.add(entry.getKey(), bean);
|
group.add(beanName, bean);
|
||||||
}
|
});
|
||||||
if (!phases.isEmpty()) {
|
if (!phases.isEmpty()) {
|
||||||
List<Integer> keys = new ArrayList<>(phases.keySet());
|
List<Integer> keys = new ArrayList<>(phases.keySet());
|
||||||
Collections.sort(keys, Collections.reverseOrder());
|
Collections.sort(keys, Collections.reverseOrder());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -87,9 +87,7 @@ public class StaticMessageSource extends AbstractMessageSource {
|
||||||
*/
|
*/
|
||||||
public void addMessages(Map<String, String> messages, Locale locale) {
|
public void addMessages(Map<String, String> messages, Locale locale) {
|
||||||
Assert.notNull(messages, "Messages Map must not be null");
|
Assert.notNull(messages, "Messages Map must not be null");
|
||||||
for (Map.Entry<String, String> entry : messages.entrySet()) {
|
messages.forEach((code, msg) -> addMessage(code, locale, msg));
|
||||||
addMessage(entry.getKey(), locale, entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -367,17 +367,16 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||||
List<NotificationListenerBean> notificationListeners =
|
List<NotificationListenerBean> notificationListeners =
|
||||||
new ArrayList<>(listeners.size());
|
new ArrayList<>(listeners.size());
|
||||||
|
|
||||||
for (Map.Entry<?, ? extends NotificationListener> entry : listeners.entrySet()) {
|
listeners.forEach((key, listener) -> {
|
||||||
// Get the listener from the map value.
|
// Get the listener from the map value.
|
||||||
NotificationListenerBean bean = new NotificationListenerBean(entry.getValue());
|
NotificationListenerBean bean = new NotificationListenerBean(listener);
|
||||||
// Get the ObjectName from the map key.
|
// Get the ObjectName from the map key.
|
||||||
Object key = entry.getKey();
|
|
||||||
if (key != null && !WILDCARD.equals(key)) {
|
if (key != null && !WILDCARD.equals(key)) {
|
||||||
// This listener is mapped to a specific ObjectName.
|
// This listener is mapped to a specific ObjectName.
|
||||||
bean.setMappedObjectName(entry.getKey());
|
bean.setMappedObjectName(key);
|
||||||
}
|
}
|
||||||
notificationListeners.add(bean);
|
notificationListeners.add(bean);
|
||||||
}
|
});
|
||||||
|
|
||||||
this.notificationListeners =
|
this.notificationListeners =
|
||||||
notificationListeners.toArray(new NotificationListenerBean[notificationListeners.size()]);
|
notificationListeners.toArray(new NotificationListenerBean[notificationListeners.size()]);
|
||||||
|
|
@ -545,9 +544,8 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.beans.isEmpty()) {
|
if (!this.beans.isEmpty()) {
|
||||||
for (Map.Entry<String, Object> entry : this.beans.entrySet()) {
|
this.beans.forEach((beanName, instance) ->
|
||||||
registerBeanNameOrInstance(entry.getValue(), entry.getKey());
|
registerBeanNameOrInstance(instance, beanName));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1008,9 +1006,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||||
* from the {@link MBeanServer}.
|
* from the {@link MBeanServer}.
|
||||||
*/
|
*/
|
||||||
private void unregisterNotificationListeners() {
|
private void unregisterNotificationListeners() {
|
||||||
for (Map.Entry<NotificationListenerBean, ObjectName[]> entry : this.registeredNotificationListeners.entrySet()) {
|
this.registeredNotificationListeners.forEach((bean, mappedObjectNames) -> {
|
||||||
NotificationListenerBean bean = entry.getKey();
|
|
||||||
ObjectName[] mappedObjectNames = entry.getValue();
|
|
||||||
for (ObjectName mappedObjectName : mappedObjectNames) {
|
for (ObjectName mappedObjectName : mappedObjectNames) {
|
||||||
try {
|
try {
|
||||||
this.server.removeNotificationListener(mappedObjectName, bean.getNotificationListener(),
|
this.server.removeNotificationListener(mappedObjectName, bean.getNotificationListener(),
|
||||||
|
|
@ -1022,7 +1018,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
this.registeredNotificationListeners.clear();
|
this.registeredNotificationListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -53,9 +53,8 @@ public abstract class AbstractConfigurableMBeanInfoAssembler extends AbstractRef
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotificationInfoMappings(Map<String, Object> notificationInfoMappings) {
|
public void setNotificationInfoMappings(Map<String, Object> notificationInfoMappings) {
|
||||||
for (Map.Entry<String, Object> entry : notificationInfoMappings.entrySet()) {
|
notificationInfoMappings.forEach((beanKey, result) ->
|
||||||
this.notificationInfoMappings.put(entry.getKey(), extractNotificationMetadata(entry.getValue()));
|
this.notificationInfoMappings.put(beanKey, extractNotificationMetadata(result)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -315,12 +315,8 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Non-empty set of methods
|
// Non-empty set of methods
|
||||||
for (Map.Entry<Method, Set<Scheduled>> entry : annotatedMethods.entrySet()) {
|
annotatedMethods.forEach((method, scheduledMethods) ->
|
||||||
Method method = entry.getKey();
|
scheduledMethods.forEach(scheduled -> processScheduled(scheduled, method, bean)));
|
||||||
for (Scheduled scheduled : entry.getValue()) {
|
|
||||||
processScheduled(scheduled, method, bean);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(annotatedMethods.size() + " @Scheduled methods processed on bean '" + beanName +
|
logger.debug(annotatedMethods.size() + " @Scheduled methods processed on bean '" + beanName +
|
||||||
"': " + annotatedMethods);
|
"': " + annotatedMethods);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-201 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -114,9 +114,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
||||||
*/
|
*/
|
||||||
public void setTriggerTasks(Map<Runnable, Trigger> triggerTasks) {
|
public void setTriggerTasks(Map<Runnable, Trigger> triggerTasks) {
|
||||||
this.triggerTasks = new ArrayList<>();
|
this.triggerTasks = new ArrayList<>();
|
||||||
for (Map.Entry<Runnable, Trigger> task : triggerTasks.entrySet()) {
|
triggerTasks.forEach((task, trigger) -> addTriggerTask(new TriggerTask(task, trigger)));
|
||||||
addTriggerTask(new TriggerTask(task.getKey(), task.getValue()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,9 +143,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
||||||
*/
|
*/
|
||||||
public void setCronTasks(Map<Runnable, String> cronTasks) {
|
public void setCronTasks(Map<Runnable, String> cronTasks) {
|
||||||
this.cronTasks = new ArrayList<>();
|
this.cronTasks = new ArrayList<>();
|
||||||
for (Map.Entry<Runnable, String> task : cronTasks.entrySet()) {
|
cronTasks.forEach(this::addCronTask);
|
||||||
addCronTask(task.getKey(), task.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -176,9 +172,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
||||||
*/
|
*/
|
||||||
public void setFixedRateTasks(Map<Runnable, Long> fixedRateTasks) {
|
public void setFixedRateTasks(Map<Runnable, Long> fixedRateTasks) {
|
||||||
this.fixedRateTasks = new ArrayList<>();
|
this.fixedRateTasks = new ArrayList<>();
|
||||||
for (Map.Entry<Runnable, Long> task : fixedRateTasks.entrySet()) {
|
fixedRateTasks.forEach(this::addFixedRateTask);
|
||||||
addFixedRateTask(task.getKey(), task.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -207,9 +201,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
|
||||||
*/
|
*/
|
||||||
public void setFixedDelayTasks(Map<Runnable, Long> fixedDelayTasks) {
|
public void setFixedDelayTasks(Map<Runnable, Long> fixedDelayTasks) {
|
||||||
this.fixedDelayTasks = new ArrayList<>();
|
this.fixedDelayTasks = new ArrayList<>();
|
||||||
for (Map.Entry<Runnable, Long> task : fixedDelayTasks.entrySet()) {
|
fixedDelayTasks.forEach(this::addFixedDelayTask);
|
||||||
addFixedDelayTask(task.getKey(), task.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -126,12 +126,11 @@ public class ConcurrentModel extends ConcurrentHashMap<String, Object> implement
|
||||||
*/
|
*/
|
||||||
public ConcurrentModel mergeAttributes(@Nullable Map<String, ?> attributes) {
|
public ConcurrentModel mergeAttributes(@Nullable Map<String, ?> attributes) {
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (Map.Entry<String, ?> entry : attributes.entrySet()) {
|
attributes.forEach((key, value) -> {
|
||||||
String key = entry.getKey();
|
|
||||||
if (!containsKey(key)) {
|
if (!containsKey(key)) {
|
||||||
put(key, entry.getValue());
|
put(key, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,12 +126,11 @@ public class ModelMap extends LinkedHashMap<String, Object> {
|
||||||
*/
|
*/
|
||||||
public ModelMap mergeAttributes(@Nullable Map<String, ?> attributes) {
|
public ModelMap mergeAttributes(@Nullable Map<String, ?> attributes) {
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (Map.Entry<String, ?> entry : attributes.entrySet()) {
|
attributes.forEach((key, value) -> {
|
||||||
String key = entry.getKey();
|
|
||||||
if (!containsKey(key)) {
|
if (!containsKey(key)) {
|
||||||
put(key, entry.getValue());
|
put(key, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,9 +287,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
|
this.validationPropertyMap.forEach(configuration::addProperty);
|
||||||
configuration.addProperty(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow for custom post-processing before we actually build the ValidatorFactory.
|
// Allow for custom post-processing before we actually build the ValidatorFactory.
|
||||||
postProcessConfiguration(configuration);
|
postProcessConfiguration(configuration);
|
||||||
|
|
|
||||||
|
|
@ -215,16 +215,14 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||||
arguments.add(getResolvableField(objectName, field));
|
arguments.add(getResolvableField(objectName, field));
|
||||||
// Using a TreeMap for alphabetical ordering of attribute names
|
// Using a TreeMap for alphabetical ordering of attribute names
|
||||||
Map<String, Object> attributesToExpose = new TreeMap<>();
|
Map<String, Object> attributesToExpose = new TreeMap<>();
|
||||||
for (Map.Entry<String, Object> entry : descriptor.getAttributes().entrySet()) {
|
descriptor.getAttributes().forEach((attributeName, attributeValue) -> {
|
||||||
String attributeName = entry.getKey();
|
|
||||||
Object attributeValue = entry.getValue();
|
|
||||||
if (!internalAnnotationAttributes.contains(attributeName)) {
|
if (!internalAnnotationAttributes.contains(attributeName)) {
|
||||||
if (attributeValue instanceof String) {
|
if (attributeValue instanceof String) {
|
||||||
attributeValue = new ResolvableAttribute(attributeValue.toString());
|
attributeValue = new ResolvableAttribute(attributeValue.toString());
|
||||||
}
|
}
|
||||||
attributesToExpose.put(attributeName, attributeValue);
|
attributesToExpose.put(attributeName, attributeValue);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
arguments.addAll(attributesToExpose.values());
|
arguments.addAll(attributesToExpose.values());
|
||||||
return arguments.toArray(new Object[arguments.size()]);
|
return arguments.toArray(new Object[arguments.size()]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -46,9 +46,7 @@ public class BindingAwareModelMap extends ExtendedModelMap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(Map<? extends String, ?> map) {
|
public void putAll(Map<? extends String, ?> map) {
|
||||||
for (Map.Entry<? extends String, ?> entry : map.entrySet()) {
|
map.forEach(this::removeBindingResultIfNecessary);
|
||||||
removeBindingResultIfNecessary(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
super.putAll(map);
|
super.putAll(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -118,14 +118,12 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||||
* @param result the resulting aliases list
|
* @param result the resulting aliases list
|
||||||
*/
|
*/
|
||||||
private void retrieveAliases(String name, List<String> result) {
|
private void retrieveAliases(String name, List<String> result) {
|
||||||
for (Map.Entry<String, String> entry : this.aliasMap.entrySet()) {
|
this.aliasMap.forEach((alias, registeredName) -> {
|
||||||
String registeredName = entry.getValue();
|
|
||||||
if (registeredName.equals(name)) {
|
if (registeredName.equals(name)) {
|
||||||
String alias = entry.getKey();
|
|
||||||
result.add(alias);
|
result.add(alias);
|
||||||
retrieveAliases(alias, result);
|
retrieveAliases(alias, result);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -580,9 +580,7 @@ public class AnnotatedElementUtils {
|
||||||
public Object process(@Nullable AnnotatedElement annotatedElement, Annotation annotation, int metaDepth) {
|
public Object process(@Nullable AnnotatedElement annotatedElement, Annotation annotation, int metaDepth) {
|
||||||
AnnotationAttributes annotationAttributes = AnnotationUtils.getAnnotationAttributes(
|
AnnotationAttributes annotationAttributes = AnnotationUtils.getAnnotationAttributes(
|
||||||
annotation, classValuesAsString, nestedAnnotationsAsMap);
|
annotation, classValuesAsString, nestedAnnotationsAsMap);
|
||||||
for (Map.Entry<String, Object> entry : annotationAttributes.entrySet()) {
|
annotationAttributes.forEach(attributesMap::add);
|
||||||
attributesMap.add(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,7 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
|
||||||
for (AnnotationAttributes annotationAttributes : attributesList) {
|
for (AnnotationAttributes annotationAttributes : attributesList) {
|
||||||
AnnotationAttributes convertedAttributes = AnnotationReadingVisitorUtils.convertClassValues(
|
AnnotationAttributes convertedAttributes = AnnotationReadingVisitorUtils.convertClassValues(
|
||||||
"method '" + getMethodName() + "'", this.classLoader, annotationAttributes, classValuesAsString);
|
"method '" + getMethodName() + "'", this.classLoader, annotationAttributes, classValuesAsString);
|
||||||
for (Map.Entry<String, Object> entry : convertedAttributes.entrySet()) {
|
convertedAttributes.forEach(allAttributes::add);
|
||||||
allAttributes.add(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allAttributes;
|
return allAttributes;
|
||||||
|
|
|
||||||
|
|
@ -175,12 +175,10 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
|
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
|
||||||
if (!CollectionUtils.isEmpty(parameters)) {
|
if (!CollectionUtils.isEmpty(parameters)) {
|
||||||
Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
|
Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
parameters.forEach((attribute, value) -> {
|
||||||
String attribute = entry.getKey();
|
|
||||||
String value = entry.getValue();
|
|
||||||
checkParameters(attribute, value);
|
checkParameters(attribute, value);
|
||||||
map.put(attribute, value);
|
map.put(attribute, value);
|
||||||
}
|
});
|
||||||
this.parameters = Collections.unmodifiableMap(map);
|
this.parameters = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -456,12 +454,12 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendTo(Map<String, String> map, StringBuilder builder) {
|
private void appendTo(Map<String, String> map, StringBuilder builder) {
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
map.forEach((key, val) -> {
|
||||||
builder.append(';');
|
builder.append(';');
|
||||||
builder.append(entry.getKey());
|
builder.append(key);
|
||||||
builder.append('=');
|
builder.append('=');
|
||||||
builder.append(entry.getValue());
|
builder.append(val);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,7 @@ public class SimpleNamespaceContext implements NamespaceContext {
|
||||||
* The supplied map must consist of string key value pairs.
|
* The supplied map must consist of string key value pairs.
|
||||||
*/
|
*/
|
||||||
public void setBindings(Map<String, String> bindings) {
|
public void setBindings(Map<String, String> bindings) {
|
||||||
for (Map.Entry<String, String> entry : bindings.entrySet()) {
|
bindings.forEach(this::bindNamespaceUri);
|
||||||
bindNamespaceUri(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,8 @@ class StaxEventHandler extends AbstractStaxHandler {
|
||||||
|
|
||||||
private List<Namespace> getNamespaces(Map<String, String> namespaceMapping) {
|
private List<Namespace> getNamespaces(Map<String, String> namespaceMapping) {
|
||||||
List<Namespace> result = new ArrayList<>();
|
List<Namespace> result = new ArrayList<>();
|
||||||
for (Map.Entry<String, String> entry : namespaceMapping.entrySet()) {
|
namespaceMapping.forEach((prefix, namespaceUri) ->
|
||||||
String prefix = entry.getKey();
|
result.add(this.eventFactory.createNamespace(prefix, namespaceUri)));
|
||||||
String namespaceUri = entry.getValue();
|
|
||||||
result.add(this.eventFactory.createNamespace(prefix, namespaceUri));
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -369,9 +369,7 @@ public class GenericConversionServiceTests {
|
||||||
watch.start("convert 4,000,000 manually");
|
watch.start("convert 4,000,000 manually");
|
||||||
for (int i = 0; i < 4000000; i++) {
|
for (int i = 0; i < 4000000; i++) {
|
||||||
Map<String, Integer> target = new HashMap<>(source.size());
|
Map<String, Integer> target = new HashMap<>(source.size());
|
||||||
for (Map.Entry<String, String> entry : source.entrySet()) {
|
source.forEach((k, v) -> target.put(k, Integer.valueOf(v)));
|
||||||
target.put(entry.getKey(), Integer.valueOf(entry.getValue()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
watch.stop();
|
watch.stop();
|
||||||
// System.out.println(watch.prettyPrint());
|
// System.out.println(watch.prettyPrint());
|
||||||
|
|
|
||||||
|
|
@ -66,17 +66,17 @@ public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
|
||||||
String attr = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
|
String attr = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
|
||||||
Map<String, String> uriVars = (Map<String, String>) request.getAttribute(attr);
|
Map<String, String> uriVars = (Map<String, String>) request.getAttribute(attr);
|
||||||
if (uriVars != null) {
|
if (uriVars != null) {
|
||||||
for (Entry<String, String> entry : uriVars.entrySet()) {
|
uriVars.forEach((name, value) -> {
|
||||||
if (mpvs.contains(entry.getKey())) {
|
if (mpvs.contains(name)) {
|
||||||
if (logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn("Skipping URI variable '" + entry.getKey() +
|
logger.warn("Skipping URI variable '" + name +
|
||||||
"' since the request contains a bind value with the same name.");
|
"' since the request contains a bind value with the same name.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mpvs.addPropertyValue(entry.getKey(), entry.getValue());
|
mpvs.addPropertyValue(name, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,11 +187,11 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!entityHeaders.isEmpty()) {
|
if (!entityHeaders.isEmpty()) {
|
||||||
for (Map.Entry<String, List<String>> entry : entityHeaders.entrySet()) {
|
entityHeaders.forEach((key, value) -> {
|
||||||
if (!outputHeaders.containsKey(entry.getKey())) {
|
if (!outputHeaders.containsKey(key)) {
|
||||||
outputHeaders.put(entry.getKey(), entry.getValue());
|
outputHeaders.put(key, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseEntity instanceof ResponseEntity) {
|
if (responseEntity instanceof ResponseEntity) {
|
||||||
|
|
|
||||||
|
|
@ -889,14 +889,14 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||||
}
|
}
|
||||||
List<InvocableHandlerMethod> attrMethods = new ArrayList<>();
|
List<InvocableHandlerMethod> attrMethods = new ArrayList<>();
|
||||||
// Global methods first
|
// Global methods first
|
||||||
for (Entry<ControllerAdviceBean, Set<Method>> entry : this.modelAttributeAdviceCache.entrySet()) {
|
this.modelAttributeAdviceCache.forEach((clazz, methodSet) -> {
|
||||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
if (clazz.isApplicableToBeanType(handlerType)) {
|
||||||
Object bean = entry.getKey().resolveBean();
|
Object bean = clazz.resolveBean();
|
||||||
for (Method method : entry.getValue()) {
|
for (Method method : methodSet) {
|
||||||
attrMethods.add(createModelAttributeMethod(binderFactory, bean, method));
|
attrMethods.add(createModelAttributeMethod(binderFactory, bean, method));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
Object bean = handlerMethod.getBean();
|
Object bean = handlerMethod.getBean();
|
||||||
attrMethods.add(createModelAttributeMethod(binderFactory, bean, method));
|
attrMethods.add(createModelAttributeMethod(binderFactory, bean, method));
|
||||||
|
|
@ -921,14 +921,14 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||||
}
|
}
|
||||||
List<InvocableHandlerMethod> initBinderMethods = new ArrayList<>();
|
List<InvocableHandlerMethod> initBinderMethods = new ArrayList<>();
|
||||||
// Global methods first
|
// Global methods first
|
||||||
for (Entry<ControllerAdviceBean, Set<Method>> entry : this.initBinderAdviceCache.entrySet()) {
|
this.initBinderAdviceCache.forEach((clazz, methodSet) -> {
|
||||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
if (clazz.isApplicableToBeanType(handlerType)) {
|
||||||
Object bean = entry.getKey().resolveBean();
|
Object bean = clazz.resolveBean();
|
||||||
for (Method method : entry.getValue()) {
|
for (Method method : methodSet) {
|
||||||
initBinderMethods.add(createInitBinderMethod(bean, method));
|
initBinderMethods.add(createInitBinderMethod(bean, method));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
Object bean = handlerMethod.getBean();
|
Object bean = handlerMethod.getBean();
|
||||||
initBinderMethods.add(createInitBinderMethod(bean, method));
|
initBinderMethods.add(createInitBinderMethod(bean, method));
|
||||||
|
|
|
||||||
|
|
@ -196,9 +196,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||||
*/
|
*/
|
||||||
public void setAttributesMap(@Nullable Map<String, ?> attributes) {
|
public void setAttributesMap(@Nullable Map<String, ?> attributes) {
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
for (Map.Entry<String, ?> entry : attributes.entrySet()) {
|
attributes.forEach(this::addStaticAttribute);
|
||||||
addStaticAttribute(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,9 +427,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||||
* @param request current HTTP request
|
* @param request current HTTP request
|
||||||
*/
|
*/
|
||||||
protected void exposeModelAsRequestAttributes(Map<String, Object> model, HttpServletRequest request) throws Exception {
|
protected void exposeModelAsRequestAttributes(Map<String, Object> model, HttpServletRequest request) throws Exception {
|
||||||
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
model.forEach((modelName, modelValue) -> {
|
||||||
String modelName = entry.getKey();
|
|
||||||
Object modelValue = entry.getValue();
|
|
||||||
if (modelValue != null) {
|
if (modelValue != null) {
|
||||||
request.setAttribute(modelName, modelValue);
|
request.setAttribute(modelName, modelValue);
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|
@ -446,7 +442,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||||
"' from request in view with name '" + getBeanName() + "'");
|
"' from request in view with name '" + getBeanName() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -487,11 +487,11 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> queryProperties(Map<String, Object> model) {
|
protected Map<String, Object> queryProperties(Map<String, Object> model) {
|
||||||
Map<String, Object> result = new LinkedHashMap<>();
|
Map<String, Object> result = new LinkedHashMap<>();
|
||||||
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
model.forEach((name, value) -> {
|
||||||
if (isEligibleProperty(entry.getKey(), entry.getValue())) {
|
if (isEligibleProperty(name, value)) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(name, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -217,13 +217,13 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||||
protected Object filterModel(Map<String, Object> model) {
|
protected Object filterModel(Map<String, Object> model) {
|
||||||
Map<String, Object> result = new HashMap<>(model.size());
|
Map<String, Object> result = new HashMap<>(model.size());
|
||||||
Set<String> modelKeys = (!CollectionUtils.isEmpty(this.modelKeys) ? this.modelKeys : model.keySet());
|
Set<String> modelKeys = (!CollectionUtils.isEmpty(this.modelKeys) ? this.modelKeys : model.keySet());
|
||||||
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
model.forEach((clazz, value) -> {
|
||||||
if (!(entry.getValue() instanceof BindingResult) && modelKeys.contains(entry.getKey()) &&
|
if (!(value instanceof BindingResult) && modelKeys.contains(clazz) &&
|
||||||
!entry.getKey().equals(JsonView.class.getName()) &&
|
!clazz.equals(JsonView.class.getName()) &&
|
||||||
!entry.getKey().equals(FilterProvider.class.getName())) {
|
!clazz.equals(FilterProvider.class.getName())) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(clazz, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return (this.extractValueFromSingleKeyModel && result.size() == 1 ? result.values().iterator().next() : result);
|
return (this.extractValueFromSingleKeyModel && result.size() == 1 ? result.values().iterator().next() : result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -380,9 +380,7 @@ public class XsltView extends AbstractUrlBasedView {
|
||||||
* @param transformer the target transformer
|
* @param transformer the target transformer
|
||||||
*/
|
*/
|
||||||
protected final void copyModelParameters(Map<String, Object> model, Transformer transformer) {
|
protected final void copyModelParameters(Map<String, Object> model, Transformer transformer) {
|
||||||
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
model.forEach(transformer::setParameter);
|
||||||
transformer.setParameter(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue