Predictable index position for BindingResult keys and parameter annotation convenience methods in MethodParameter
This commit is contained in:
parent
006cbb25c5
commit
3f11fbafaa
|
|
@ -19,8 +19,8 @@ package org.springframework.validation;
|
||||||
import java.beans.PropertyEditor;
|
import java.beans.PropertyEditor;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -270,11 +270,11 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
||||||
* @see org.springframework.web.servlet.mvc.SimpleFormController
|
* @see org.springframework.web.servlet.mvc.SimpleFormController
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getModel() {
|
public Map<String, Object> getModel() {
|
||||||
Map<String, Object> model = new HashMap<String, Object>(2);
|
Map<String, Object> model = new LinkedHashMap<String, Object>(2);
|
||||||
// Errors instance, even if no errors.
|
|
||||||
model.put(MODEL_KEY_PREFIX + getObjectName(), this);
|
|
||||||
// Mapping from name to target object.
|
// Mapping from name to target object.
|
||||||
model.put(getObjectName(), getTarget());
|
model.put(getObjectName(), getTarget());
|
||||||
|
// Errors instance, even if no errors.
|
||||||
|
model.put(MODEL_KEY_PREFIX + getObjectName(), this);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,20 @@ public class MethodParameter {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the parameter has at least one annotation, false if it has none.
|
||||||
|
*/
|
||||||
|
public boolean hasParameterAnnotations() {
|
||||||
|
return getParameterAnnotations().length != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the parameter has the given annotation type, and false if it doesn't.
|
||||||
|
*/
|
||||||
|
public <T extends Annotation> boolean hasParameterAnnotation(Class<T> annotationType) {
|
||||||
|
return getParameterAnnotation(annotationType) != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize parameter name discovery for this method parameter.
|
* Initialize parameter name discovery for this method parameter.
|
||||||
* <p>This method does not actually try to retrieve the parameter name at
|
* <p>This method does not actually try to retrieve the parameter name at
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue