Iteration over a map using EntrySet
This commit is contained in:
parent
785e8d8116
commit
9ca8681f79
|
@ -640,9 +640,10 @@ public abstract class AbstractMethodMessageHandler<T>
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
return new InvocableHandlerMethod(handlerMethod.getBean(), method);
|
return new InvocableHandlerMethod(handlerMethod.getBean(), method);
|
||||||
}
|
}
|
||||||
for (MessagingAdviceBean advice : this.exceptionHandlerAdviceCache.keySet()) {
|
for (Map.Entry<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
|
||||||
|
MessagingAdviceBean advice = entry.getKey();
|
||||||
if (advice.isApplicableToBeanType(beanType)) {
|
if (advice.isApplicableToBeanType(beanType)) {
|
||||||
resolver = this.exceptionHandlerAdviceCache.get(advice);
|
resolver = entry.getValue();
|
||||||
method = resolver.resolveMethod(exception);
|
method = resolver.resolveMethod(exception);
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
return new InvocableHandlerMethod(advice.resolveBean(), method);
|
return new InvocableHandlerMethod(advice.resolveBean(), method);
|
||||||
|
|
|
@ -155,9 +155,10 @@ class InvocableHelper {
|
||||||
exceptionHandlerMethod = new InvocableHandlerMethod(handlerMethod.getBean(), method);
|
exceptionHandlerMethod = new InvocableHandlerMethod(handlerMethod.getBean(), method);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (MessagingAdviceBean advice : this.exceptionHandlerAdviceCache.keySet()) {
|
for (Map.Entry<MessagingAdviceBean, AbstractExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
|
||||||
|
MessagingAdviceBean advice = entry.getKey();
|
||||||
if (advice.isApplicableToBeanType(beanType)) {
|
if (advice.isApplicableToBeanType(beanType)) {
|
||||||
resolver = this.exceptionHandlerAdviceCache.get(advice);
|
resolver = entry.getValue();
|
||||||
method = resolver.resolveMethod(ex);
|
method = resolver.resolveMethod(ex);
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
exceptionHandlerMethod = new InvocableHandlerMethod(advice.resolveBean(), method);
|
exceptionHandlerMethod = new InvocableHandlerMethod(advice.resolveBean(), method);
|
||||||
|
|
|
@ -759,8 +759,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
||||||
*/
|
*/
|
||||||
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
|
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
|
||||||
if (this.marshallerProperties != null) {
|
if (this.marshallerProperties != null) {
|
||||||
for (String name : this.marshallerProperties.keySet()) {
|
for (Map.Entry<String, ?> entry : this.marshallerProperties.entrySet()) {
|
||||||
marshaller.setProperty(name, this.marshallerProperties.get(name));
|
marshaller.setProperty(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.marshallerListener != null) {
|
if (this.marshallerListener != null) {
|
||||||
|
@ -913,8 +913,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
||||||
*/
|
*/
|
||||||
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
||||||
if (this.unmarshallerProperties != null) {
|
if (this.unmarshallerProperties != null) {
|
||||||
for (String name : this.unmarshallerProperties.keySet()) {
|
for (Map.Entry<String, ?> entry : this.unmarshallerProperties.entrySet()) {
|
||||||
unmarshaller.setProperty(name, this.unmarshallerProperties.get(name));
|
unmarshaller.setProperty(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.unmarshallerListener != null) {
|
if (this.unmarshallerListener != null) {
|
||||||
|
|
|
@ -95,9 +95,9 @@ class HeaderValueHolder {
|
||||||
@Nullable
|
@Nullable
|
||||||
public static HeaderValueHolder getByName(Map<String, HeaderValueHolder> headers, String name) {
|
public static HeaderValueHolder getByName(Map<String, HeaderValueHolder> headers, String name) {
|
||||||
Assert.notNull(name, "Header name must not be null");
|
Assert.notNull(name, "Header name must not be null");
|
||||||
for (String headerName : headers.keySet()) {
|
for (Map.Entry<String, HeaderValueHolder> entry : headers.entrySet()) {
|
||||||
if (headerName.equalsIgnoreCase(name)) {
|
if (entry.getKey().equalsIgnoreCase(name)) {
|
||||||
return headers.get(headerName);
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -530,14 +530,16 @@ public class MockHttpServletRequestBuilder
|
||||||
this.contentType = parentBuilder.contentType;
|
this.contentType = parentBuilder.contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String headerName : parentBuilder.headers.keySet()) {
|
for (Map.Entry<String, List<Object>> entry : parentBuilder.headers.entrySet()) {
|
||||||
|
String headerName = entry.getKey();
|
||||||
if (!this.headers.containsKey(headerName)) {
|
if (!this.headers.containsKey(headerName)) {
|
||||||
this.headers.put(headerName, parentBuilder.headers.get(headerName));
|
this.headers.put(headerName, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String paramName : parentBuilder.parameters.keySet()) {
|
for (Map.Entry<String, List<String>> entry : parentBuilder.parameters.entrySet()) {
|
||||||
|
String paramName = entry.getKey();
|
||||||
if (!this.parameters.containsKey(paramName)) {
|
if (!this.parameters.containsKey(paramName)) {
|
||||||
this.parameters.put(paramName, parentBuilder.parameters.get(paramName));
|
this.parameters.put(paramName, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Cookie cookie : parentBuilder.cookies) {
|
for (Cookie cookie : parentBuilder.cookies) {
|
||||||
|
@ -551,19 +553,22 @@ public class MockHttpServletRequestBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String attributeName : parentBuilder.requestAttributes.keySet()) {
|
for (Map.Entry<String, Object> entry : parentBuilder.requestAttributes.entrySet()) {
|
||||||
|
String attributeName = entry.getKey();
|
||||||
if (!this.requestAttributes.containsKey(attributeName)) {
|
if (!this.requestAttributes.containsKey(attributeName)) {
|
||||||
this.requestAttributes.put(attributeName, parentBuilder.requestAttributes.get(attributeName));
|
this.requestAttributes.put(attributeName, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String attributeName : parentBuilder.sessionAttributes.keySet()) {
|
for (Map.Entry<String, Object> entry : parentBuilder.sessionAttributes.entrySet()) {
|
||||||
|
String attributeName = entry.getKey();
|
||||||
if (!this.sessionAttributes.containsKey(attributeName)) {
|
if (!this.sessionAttributes.containsKey(attributeName)) {
|
||||||
this.sessionAttributes.put(attributeName, parentBuilder.sessionAttributes.get(attributeName));
|
this.sessionAttributes.put(attributeName, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String attributeName : parentBuilder.flashAttributes.keySet()) {
|
for (Map.Entry<String, Object> entry : parentBuilder.flashAttributes.entrySet()) {
|
||||||
|
String attributeName = entry.getKey();
|
||||||
if (!this.flashAttributes.containsKey(attributeName)) {
|
if (!this.flashAttributes.containsKey(attributeName)) {
|
||||||
this.flashAttributes.put(attributeName, parentBuilder.flashAttributes.get(attributeName));
|
this.flashAttributes.put(attributeName, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,10 +351,11 @@ class ControllerMethodResolver {
|
||||||
|
|
||||||
if (targetMethod == null) {
|
if (targetMethod == null) {
|
||||||
// Global exception handlers...
|
// Global exception handlers...
|
||||||
for (ControllerAdviceBean advice : this.exceptionHandlerAdviceCache.keySet()) {
|
for (Map.Entry<ControllerAdviceBean, ExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
|
||||||
|
ControllerAdviceBean advice = entry.getKey();
|
||||||
if (advice.isApplicableToBeanType(handlerType)) {
|
if (advice.isApplicableToBeanType(handlerType)) {
|
||||||
targetBean = advice.resolveBean();
|
targetBean = advice.resolveBean();
|
||||||
targetMethod = this.exceptionHandlerAdviceCache.get(advice).resolveMethodByThrowable(ex);
|
targetMethod = entry.getValue().resolveMethodByThrowable(ex);
|
||||||
if (targetMethod != null) {
|
if (targetMethod != null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,9 +213,9 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
|
||||||
return cacheControl;
|
return cacheControl;
|
||||||
}
|
}
|
||||||
// Pattern match?
|
// Pattern match?
|
||||||
for (String registeredPath : this.cacheControlMappings.keySet()) {
|
for (Map.Entry<String, CacheControl> entry : this.cacheControlMappings.entrySet()) {
|
||||||
if (this.pathMatcher.match(registeredPath, urlPath)) {
|
if (this.pathMatcher.match(entry.getKey(), urlPath)) {
|
||||||
return this.cacheControlMappings.get(registeredPath);
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -238,9 +238,9 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
|
||||||
return cacheSeconds;
|
return cacheSeconds;
|
||||||
}
|
}
|
||||||
// Pattern match?
|
// Pattern match?
|
||||||
for (String registeredPath : this.cacheMappings.keySet()) {
|
for (Map.Entry<String, Integer> entry : this.cacheMappings.entrySet()) {
|
||||||
if (this.pathMatcher.match(registeredPath, urlPath)) {
|
if (this.pathMatcher.match(entry.getKey(), urlPath)) {
|
||||||
return this.cacheMappings.get(registeredPath);
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.web.servlet.support;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -169,12 +170,12 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
|
||||||
}
|
}
|
||||||
MultiValueMap<String, String> actualParams = getOriginatingRequestParams(request);
|
MultiValueMap<String, String> actualParams = getOriginatingRequestParams(request);
|
||||||
MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
|
MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
|
||||||
for (String expectedName : expectedParams.keySet()) {
|
for (Map.Entry<String, List<String>> entry : expectedParams.entrySet()) {
|
||||||
List<String> actualValues = actualParams.get(expectedName);
|
List<String> actualValues = actualParams.get(entry.getKey());
|
||||||
if (actualValues == null) {
|
if (actualValues == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String expectedValue : expectedParams.get(expectedName)) {
|
for (String expectedValue : entry.getValue()) {
|
||||||
if (!actualValues.contains(expectedValue)) {
|
if (!actualValues.contains(expectedValue)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,8 +485,8 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
|
||||||
writeOptionalAttribute(tagWriter, ONKEYDOWN_ATTRIBUTE, getOnkeydown());
|
writeOptionalAttribute(tagWriter, ONKEYDOWN_ATTRIBUTE, getOnkeydown());
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(this.dynamicAttributes)) {
|
if (!CollectionUtils.isEmpty(this.dynamicAttributes)) {
|
||||||
for (String attr : this.dynamicAttributes.keySet()) {
|
for (Map.Entry<String, Object> entry : this.dynamicAttributes.entrySet()) {
|
||||||
tagWriter.writeOptionalAttributeValue(attr, getDisplayString(this.dynamicAttributes.get(attr)));
|
tagWriter.writeOptionalAttributeValue(entry.getKey(), getDisplayString(entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -704,9 +704,9 @@ public class FormTag extends AbstractHtmlElementTag {
|
||||||
if (!CollectionUtils.isEmpty(hiddenFields)) {
|
if (!CollectionUtils.isEmpty(hiddenFields)) {
|
||||||
Assert.state(this.tagWriter != null, "No TagWriter set");
|
Assert.state(this.tagWriter != null, "No TagWriter set");
|
||||||
this.tagWriter.appendValue("<div>\n");
|
this.tagWriter.appendValue("<div>\n");
|
||||||
for (String name : hiddenFields.keySet()) {
|
for (Map.Entry<String, String> entry : hiddenFields.entrySet()) {
|
||||||
this.tagWriter.appendValue("<input type=\"hidden\" ");
|
this.tagWriter.appendValue("<input type=\"hidden\" ");
|
||||||
this.tagWriter.appendValue("name=\"" + name + "\" value=\"" + hiddenFields.get(name) + "\" ");
|
this.tagWriter.appendValue("name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\" ");
|
||||||
this.tagWriter.appendValue("/>\n");
|
this.tagWriter.appendValue("/>\n");
|
||||||
}
|
}
|
||||||
this.tagWriter.appendValue("</div>");
|
this.tagWriter.appendValue("</div>");
|
||||||
|
|
Loading…
Reference in New Issue