diff --git a/spring-context-indexer/src/main/java/org/springframework/context/index/PropertiesMarshaller.java b/spring-context-indexer/src/main/java/org/springframework/context/index/PropertiesMarshaller.java index 3ee45cd75b2..7505963cd5f 100644 --- a/spring-context-indexer/src/main/java/org/springframework/context/index/PropertiesMarshaller.java +++ b/spring-context-indexer/src/main/java/org/springframework/context/index/PropertiesMarshaller.java @@ -21,7 +21,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.HashSet; -import java.util.Map; import java.util.Properties; import java.util.Set; @@ -43,11 +42,10 @@ abstract class PropertiesMarshaller { CandidateComponentsMetadata result = new CandidateComponentsMetadata(); Properties props = new Properties(); props.load(in); - for (Map.Entry entry : props.entrySet()) { - String type = (String) entry.getKey(); - Set candidates = new HashSet<>(Arrays.asList(((String) entry.getValue()).split(","))); - result.add(new ItemMetadata(type, candidates)); - } + props.forEach((type, value) -> { + Set candidates = new HashSet<>(Arrays.asList(((String) value).split(","))); + result.add(new ItemMetadata((String) type, candidates)); + }); return result; } diff --git a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java index f09322f6021..144ef388c79 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java index 88df516c582..a411557bc80 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -131,13 +131,12 @@ public class MapSqlParameterSource extends AbstractSqlParameterSource { */ public MapSqlParameterSource addValues(@Nullable Map values) { if (values != null) { - for (Map.Entry entry : values.entrySet()) { - this.values.put(entry.getKey(), entry.getValue()); - if (entry.getValue() instanceof SqlParameterValue) { - SqlParameterValue value = (SqlParameterValue) entry.getValue(); - registerSqlType(entry.getKey(), value.getSqlType()); + values.forEach((key, value) -> { + this.values.put(key, value); + if (value instanceof SqlParameterValue) { + registerSqlType(key, ((SqlParameterValue) value).getSqlType()); } - } + }); } return this; } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java index d68b8aa824a..f0983a3bd38 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java @@ -114,11 +114,11 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple throw new IllegalArgumentException("Property 'targetDataSources' is required"); } this.resolvedDataSources = new HashMap<>(this.targetDataSources.size()); - for (Map.Entry entry : this.targetDataSources.entrySet()) { - Object lookupKey = resolveSpecifiedLookupKey(entry.getKey()); - DataSource dataSource = resolveSpecifiedDataSource(entry.getValue()); + this.targetDataSources.forEach((key, value) -> { + Object lookupKey = resolveSpecifiedLookupKey(key); + DataSource dataSource = resolveSpecifiedDataSource(value); this.resolvedDataSources.put(lookupKey, dataSource); - } + }); if (this.defaultTargetDataSource != null) { this.resolvedDefaultDataSource = resolveSpecifiedDataSource(this.defaultTargetDataSource); } diff --git a/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java b/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java index e52c8dc0e76..0ca4e8c63d4 100644 --- a/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java +++ b/spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java @@ -225,12 +225,9 @@ public class JmsListenerAnnotationBeanPostProcessor } else { // Non-empty set of methods - for (Map.Entry> entry : annotatedMethods.entrySet()) { - Method method = entry.getKey(); - for (JmsListener listener : entry.getValue()) { - processJmsListener(listener, method, bean); - } - } + annotatedMethods.forEach((method, listeners) -> + listeners.forEach(listener -> + processJmsListener(listener, method, bean))); if (logger.isDebugEnabled()) { logger.debug(annotatedMethods.size() + " @JmsListener methods processed on bean '" + beanName + "': " + annotatedMethods); diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java index 50d8e649086..5f74a792a73 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java @@ -158,12 +158,10 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B */ public void setTypeIdMappings(Map> typeIdMappings) { this.idClassMappings = new HashMap<>(); - for (Map.Entry> entry : typeIdMappings.entrySet()) { - String id = entry.getKey(); - Class clazz = entry.getValue(); + typeIdMappings.forEach((id, clazz) -> { this.idClassMappings.put(id, clazz); this.classIdMappings.put(clazz, id); - } + }); } @Override diff --git a/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java b/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java index 449817b16c3..38e2bae9aff 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java @@ -149,11 +149,11 @@ public class MessageHeaders implements Map, Serializable { */ private MessageHeaders(MessageHeaders original, Set keysToIgnore) { this.headers = new HashMap<>(original.headers.size() - keysToIgnore.size()); - for (Map.Entry entry : original.headers.entrySet()) { - if (!keysToIgnore.contains(entry.getKey())) { - this.headers.put(entry.getKey(), entry.getValue()); + original.headers.forEach((key, value) -> { + if (!keysToIgnore.contains(key)) { + this.headers.put(key, value); } - } + }); } @@ -276,11 +276,11 @@ public class MessageHeaders implements Map, Serializable { private void writeObject(ObjectOutputStream out) throws IOException { Set keysToIgnore = new HashSet<>(); - for (Map.Entry entry : this.headers.entrySet()) { - if (!(entry.getValue() instanceof Serializable)) { - keysToIgnore.add(entry.getKey()); + this.headers.forEach((key, value) -> { + if (!(value instanceof Serializable)) { + keysToIgnore.add(key); } - } + }); if (keysToIgnore.isEmpty()) { // All entries are serializable -> serialize the regular MessageHeaders instance diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java index 9272d3e56fb..06f78968158 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java @@ -288,9 +288,7 @@ public abstract class AbstractMethodMessageHandler if (logger.isDebugEnabled()) { logger.debug(methods.size() + " message handler methods found on " + userType + ": " + methods); } - for (Map.Entry entry : methods.entrySet()) { - registerHandlerMethod(handler, entry.getKey(), entry.getValue()); - } + methods.forEach((key, value) -> registerHandlerMethod(handler, key, value)); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java index d02ba28b571..6c3cfe43b88 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java @@ -113,10 +113,7 @@ public class StompHeaders implements MultiValueMap, Serializable Assert.notNull(headers, "'headers' must not be null"); if (readOnly) { Map> map = new LinkedMultiValueMap<>(headers.size()); - for (Entry> entry : headers.entrySet()) { - List values = Collections.unmodifiableList(entry.getValue()); - map.put(entry.getKey(), values); - } + headers.forEach((key, value) -> map.put(key, Collections.unmodifiableList(value))); this.headers = Collections.unmodifiableMap(map); } else { @@ -424,9 +421,7 @@ public class StompHeaders implements MultiValueMap, Serializable @Override public void addAll(MultiValueMap values) { - for (Entry> entry : values.entrySet()) { - addAll(entry.getKey(), entry.getValue()); - } + values.forEach(this::addAll); } /** @@ -446,17 +441,13 @@ public class StompHeaders implements MultiValueMap, Serializable @Override public void setAll(Map values) { - for (Entry entry : values.entrySet()) { - set(entry.getKey(), entry.getValue()); - } + values.forEach(this::set); } @Override public Map toSingleValueMap() { LinkedHashMap singleValueMap = new LinkedHashMap<>(this.headers.size()); - for (Entry> entry : headers.entrySet()) { - singleValueMap.put(entry.getKey(), entry.getValue().get(0)); - } + headers.forEach((key, value) -> singleValueMap.put(key, value.get(0))); return singleValueMap; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java index e595f2dad5e..0a764f1a48d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java @@ -387,11 +387,11 @@ public class MessageHeaderAccessor { */ public void copyHeaders(@Nullable Map headersToCopy) { if (headersToCopy != null) { - for (Map.Entry entry : headersToCopy.entrySet()) { - if (!isReadOnly(entry.getKey())) { - setHeader(entry.getKey(), entry.getValue()); + headersToCopy.forEach((key, value) -> { + if (!isReadOnly(key)) { + setHeader(key, value); } - } + }); } } @@ -401,11 +401,11 @@ public class MessageHeaderAccessor { */ public void copyHeadersIfAbsent(@Nullable Map headersToCopy) { if (headersToCopy != null) { - for (Map.Entry entry : headersToCopy.entrySet()) { - if (!isReadOnly(entry.getKey())) { - setHeaderIfAbsent(entry.getKey(), entry.getValue()); + headersToCopy.forEach((key, value) -> { + if (!isReadOnly(key)) { + setHeaderIfAbsent(key, value); } - } + }); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java index a068fa0ef4d..3049f07c15b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java @@ -197,11 +197,8 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { if (headers == null) { return; } - for (Map.Entry> headerEntry : headers.entrySet()) { - for (String value : headerEntry.getValue()) { - addNativeHeader(headerEntry.getKey(), value); - } - } + headers.forEach((key, values) -> + values.forEach(value -> addNativeHeader(key, value))); } @Nullable diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java index dc5bf08f15a..69117cdd226 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java @@ -325,11 +325,11 @@ public abstract class AbstractEntityManagerFactoryBean implements } Map vendorPropertyMap = this.jpaVendorAdapter.getJpaPropertyMap(); if (vendorPropertyMap != null) { - for (Map.Entry entry : vendorPropertyMap.entrySet()) { - if (!this.jpaPropertyMap.containsKey(entry.getKey())) { - this.jpaPropertyMap.put(entry.getKey(), entry.getValue()); + vendorPropertyMap.forEach((key, value) -> { + if (!this.jpaPropertyMap.containsKey(key)) { + this.jpaPropertyMap.put(key, value); } - } + }); } if (this.entityManagerFactoryInterface == null) { this.entityManagerFactoryInterface = this.jpaVendorAdapter.getEntityManagerFactoryInterface(); diff --git a/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java index d2848bd1edf..9aed389b638 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -474,9 +474,7 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing context.addPackages(targetPackages); } if (this.castorProperties != null) { - for (Map.Entry property : this.castorProperties.entrySet()) { - context.setProperty(property.getKey(), property.getValue()); - } + this.castorProperties.forEach(context::setProperty); } return context; } @@ -563,19 +561,13 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing marshaller.setSchemaLocation(this.schemaLocation); marshaller.setUseXSITypeAtRoot(this.useXSITypeAtRoot); if (this.doctypes != null) { - for (Map.Entry doctype : this.doctypes.entrySet()) { - marshaller.setDoctype(doctype.getKey(), doctype.getValue()); - } + this.doctypes.forEach(marshaller::setDoctype); } if (this.processingInstructions != null) { - for (Map.Entry processingInstruction : this.processingInstructions.entrySet()) { - marshaller.addProcessingInstruction(processingInstruction.getKey(), processingInstruction.getValue()); - } + this.processingInstructions.forEach(marshaller::addProcessingInstruction); } if (this.namespaceMappings != null) { - for (Map.Entry entry : this.namespaceMappings.entrySet()) { - marshaller.setNamespaceMapping(entry.getKey(), entry.getValue()); - } + this.namespaceMappings.forEach(marshaller::setNamespaceMapping); } } @@ -666,9 +658,7 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing unmarshaller.setReuseObjects(this.reuseObjects); unmarshaller.setClearCollections(this.clearCollections); if (this.namespaceToPackageMapping != null) { - for (Map.Entry mapping : this.namespaceToPackageMapping.entrySet()) { - unmarshaller.addNamespaceToPackageMapping(mapping.getKey(), mapping.getValue()); - } + this.namespaceToPackageMapping.forEach(unmarshaller::addNamespaceToPackageMapping); } if (this.entityResolver != null) { unmarshaller.setEntityResolver(this.entityResolver); diff --git a/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java index b2fb29717af..8e3531684dd 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java @@ -469,15 +469,11 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo try { if (this.aliases != null) { Map> classMap = toClassMap(this.aliases); - for (Map.Entry> entry : classMap.entrySet()) { - xstream.alias(entry.getKey(), entry.getValue()); - } + classMap.forEach(xstream::alias); } if (this.aliasesByType != null) { Map> classMap = toClassMap(this.aliasesByType); - for (Map.Entry> entry : classMap.entrySet()) { - xstream.aliasType(entry.getKey(), entry.getValue()); - } + classMap.forEach(xstream::aliasType); } if (this.fieldAliases != null) { for (Map.Entry entry : this.fieldAliases.entrySet()) { @@ -543,20 +539,20 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo } if (this.implicitCollections != null) { - for (Map.Entry, String> entry : this.implicitCollections.entrySet()) { - String[] collectionFields = StringUtils.commaDelimitedListToStringArray(entry.getValue()); + this.implicitCollections.forEach((key, fields) -> { + String[] collectionFields = StringUtils.commaDelimitedListToStringArray(fields); for (String collectionField : collectionFields) { - xstream.addImplicitCollection(entry.getKey(), collectionField); + xstream.addImplicitCollection(key, collectionField); } - } + }); } if (this.omittedFields != null) { - for (Map.Entry, String> entry : this.omittedFields.entrySet()) { - String[] fields = StringUtils.commaDelimitedListToStringArray(entry.getValue()); + this.omittedFields.forEach((key, value) -> { + String[] fields = StringUtils.commaDelimitedListToStringArray(value); for (String field : fields) { - xstream.omitField(entry.getKey(), field); + xstream.omitField(key, field); } - } + }); } if (this.annotatedClasses != null) { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java index 5ea6305b29c..52a796d1b6b 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java @@ -26,7 +26,6 @@ import java.util.Enumeration; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.StringTokenizer; import javax.servlet.ServletContext; @@ -182,11 +181,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable { // parameter Map parentParams = parentRequest.getParameterMap(); - for (Map.Entry parentParam : parentParams.entrySet()) { - String paramName = parentParam.getKey(); - String[] paramValues = parentParam.getValue(); - request.addParameter(paramName, paramValues); - } + parentParams.forEach(request::addParameter); // cookie Cookie[] parentCookies = parentRequest.getCookies(); @@ -314,9 +309,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable { } private void headers(MockHttpServletRequest request) { - for (Entry header : this.webRequest.getAdditionalHeaders().entrySet()) { - request.addHeader(header.getKey(), header.getValue()); - } + this.webRequest.getAdditionalHeaders().forEach(request::addHeader); } private MockHttpSession httpSession(MockHttpServletRequest request, final String sessionid) { @@ -359,14 +352,13 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable { } private void params(MockHttpServletRequest request, UriComponents uriComponents) { - for (Entry> entry : uriComponents.getQueryParams().entrySet()) { - String name = entry.getKey(); + uriComponents.getQueryParams().forEach((name, values) -> { String urlDecodedName = urlDecode(name); - for (String value : entry.getValue()) { + values.forEach(value -> { value = (value != null ? urlDecode(value) : ""); request.addParameter(urlDecodedName, value); - } - } + }); + }); for (NameValuePair param : this.webRequest.getRequestParameters()) { request.addParameter(param.getName(), param.getValue()); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 21271275380..d4a9d3d78a7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -28,7 +28,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; import javax.servlet.http.Cookie; @@ -310,9 +309,7 @@ public class MockHttpServletRequestBuilder * @param httpHeaders the headers and values to add */ public MockHttpServletRequestBuilder headers(HttpHeaders httpHeaders) { - for (Map.Entry> entry : httpHeaders.entrySet()) { - this.headers.addAll(entry.getKey(), entry.getValue()); - } + httpHeaders.forEach(this.headers::addAll); return this; } @@ -697,12 +694,10 @@ public class MockHttpServletRequestBuilder } private void addRequestParams(MockHttpServletRequest request, MultiValueMap map) { - for (Entry> entry : map.entrySet()) { - for (String value : entry.getValue()) { - value = (value != null ? UriUtils.decode(value, StandardCharsets.UTF_8) : null); - request.addParameter(UriUtils.decode(entry.getKey(), StandardCharsets.UTF_8), value); - } - } + map.forEach((key, values) -> values.forEach(value -> { + value = (value != null ? UriUtils.decode(value, StandardCharsets.UTF_8) : null); + request.addParameter(UriUtils.decode(key, StandardCharsets.UTF_8), value); + })); } private MultiValueMap parseFormData(final MediaType mediaType) { diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java index a994c8b48ce..d78ef28d940 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java @@ -106,9 +106,7 @@ public class MethodMapTransactionAttributeSource */ protected void initMethodMap(@Nullable Map methodMap) { if (methodMap != null) { - for (Map.Entry entry : methodMap.entrySet()) { - addTransactionalMethod(entry.getKey(), entry.getValue()); - } + methodMap.forEach(this::addTransactionalMethod); } } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java index 2efd477e243..9edc18d400a 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -61,9 +61,7 @@ public class NameMatchTransactionAttributeSource implements TransactionAttribute * @see TransactionAttributeEditor */ public void setNameMap(Map nameMap) { - for (Map.Entry entry : nameMap.entrySet()) { - addTransactionalMethod(entry.getKey(), entry.getValue()); - } + nameMap.forEach(this::addTransactionalMethod); } /**