diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index 0212eaa8bd..0431def134 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -64,8 +64,6 @@ public class MethodParameter { /** Map from Integer level to Integer type index */ Map typeIndexesPerLevel; - private int hash = 0; - /** * Create a new MethodParameter for the given method, with nesting level 1. @@ -137,7 +135,6 @@ public class MethodParameter { this.parameterName = original.parameterName; this.nestingLevel = original.nestingLevel; this.typeIndexesPerLevel = original.typeIndexesPerLevel; - this.hash = original.hash; } @@ -450,29 +447,14 @@ public class MethodParameter { } if (obj != null && obj instanceof MethodParameter) { MethodParameter other = (MethodParameter) obj; - - if (this.parameterIndex != other.parameterIndex) { - return false; - } - else if (this.getMember().equals(other.getMember())) { - return true; - } - else { - return false; - } + return (this.parameterIndex == other.parameterIndex && getMember().equals(other.getMember())); } return false; } @Override public int hashCode() { - int result = this.hash; - if (result == 0) { - result = getMember().hashCode(); - result = 31 * result + this.parameterIndex; - this.hash = result; - } - return result; + return (getMember().hashCode() * 31 + this.parameterIndex); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageMappingInfo.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageMappingInfo.java index 06d0a7c4ec..4ca89f9754 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageMappingInfo.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageMappingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -36,8 +36,6 @@ public class SimpMessageMappingInfo implements MessageCondition{@link HeadersRequestCondition} *
  • {@link ConsumesRequestCondition} *
  • {@link ProducesRequestCondition} - *
  • {@code RequestCondition} (optional, custom request condition) + *
  • {@code RequestCondition} (optional, custom request condition) * * * @author Arjen Poutsma @@ -59,24 +59,20 @@ public final class RequestMappingInfo implements RequestCondition custom) { - this.patternsCondition = patterns != null ? patterns : new PatternsRequestCondition(); - this.methodsCondition = methods != null ? methods : new RequestMethodsRequestCondition(); - this.paramsCondition = params != null ? params : new ParamsRequestCondition(); - this.headersCondition = headers != null ? headers : new HeadersRequestCondition(); - this.consumesCondition = consumes != null ? consumes : new ConsumesRequestCondition(); - this.producesCondition = produces != null ? produces : new ProducesRequestCondition(); + public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods, + ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes, + ProducesRequestCondition produces, RequestCondition custom) { + + this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition()); + this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition()); + this.paramsCondition = (params != null ? params : new ParamsRequestCondition()); + this.headersCondition = (headers != null ? headers : new HeadersRequestCondition()); + this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition()); + this.producesCondition = (produces != null ? produces : new ProducesRequestCondition()); this.customConditionHolder = new RequestConditionHolder(custom); } @@ -88,61 +84,63 @@ public final class RequestMappingInfo implements RequestCondition getCustomCondition() { - return customConditionHolder.getCondition(); + return this.customConditionHolder.getCondition(); } + /** * Combines "this" request mapping info (i.e. the current instance) with another request mapping info instance. *

    Example: combine type- and method-level request mappings. @@ -170,22 +168,22 @@ public final class RequestMappingInfo implements RequestConditionNote: it is assumed both instances have been obtained via + *

    Note: It is assumed both instances have been obtained via * {@link #getMatchingCondition(HttpServletRequest)} to ensure they have conditions with * content relevant to current request. */ @Override public int compareTo(RequestMappingInfo other, HttpServletRequest request) { - int result = patternsCondition.compareTo(other.getPatternsCondition(), request); + int result = this.patternsCondition.compareTo(other.getPatternsCondition(), request); if (result != 0) { return result; } - result = paramsCondition.compareTo(other.getParamsCondition(), request); + result = this.paramsCondition.compareTo(other.getParamsCondition(), request); if (result != 0) { return result; } - result = headersCondition.compareTo(other.getHeadersCondition(), request); + result = this.headersCondition.compareTo(other.getHeadersCondition(), request); if (result != 0) { return result; } - result = consumesCondition.compareTo(other.getConsumesCondition(), request); + result = this.consumesCondition.compareTo(other.getConsumesCondition(), request); if (result != 0) { return result; } - result = producesCondition.compareTo(other.getProducesCondition(), request); + result = this.producesCondition.compareTo(other.getProducesCondition(), request); if (result != 0) { return result; } - result = methodsCondition.compareTo(other.getMethodsCondition(), request); + result = this.methodsCondition.compareTo(other.getMethodsCondition(), request); if (result != 0) { return result; } - result = customConditionHolder.compareTo(other.customConditionHolder, request); + result = this.customConditionHolder.compareTo(other.customConditionHolder, request); if (result != 0) { return result; } @@ -252,30 +251,22 @@ public final class RequestMappingInfo implements RequestCondition