Top Description Fields Constructors Methods
org.springframework.validation.method

public Class ParameterValidationResult

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.validation.method.ParameterErrors
Imports
java.util.Collection, .List, org.springframework.context.MessageSourceResolvable, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

Store and expose the results of method validation for a method parameter.

When the method parameter is a container such as a List, array, or java.util.Map, then a separate ParameterValidationResult is created for each element with errors. In that case, the properties container, containerIndex, and containerKey provide additional context.

Author
Rossen Stoyanchev
Since
6.1

Field Summary

Modifier and TypeField and Description
private final Object
private final Object
private final Integer
private final Object
private final MethodParameter
private final List<MessageSourceResolvable>

Constructor Summary

AccessConstructor and Description
public
ParameterValidationResult(MethodParameter param, Object arg, Collection<? extends MessageSourceResolvable> errors, Object container, Integer index, Object key)

Create a ParameterValidationResult.

public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Object
getArgument()

The method argument value that was validated.

public Object
getContainer()

When @Valid is declared on a container of elements such as java.util.Collection, java.util.Map, java.util.Optional, and others, this method returns the container of the validated argument, while getContainerIndex() and getContainerKey() provide information about the index or key if applicable.

public Integer
getContainerIndex()

When @Valid is declared on an indexed container of elements such as List or array, this method returns the index of the validated argument.

public Object
getContainerKey()

When @Valid is declared on a container of elements referenced by key such as java.util.Map, this method returns the key of the validated argument.

public MethodParameter
getMethodParameter()

The method parameter the validation results are for.

public List<MessageSourceResolvable>
getResolvableErrors()

List of MessageSourceResolvable representations adapted from the validation errors of the validation library.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

argumentback to summary
private final Object argument
Annotations
@Nullable
containerback to summary
private final Object container
Annotations
@Nullable
containerIndexback to summary
private final Integer containerIndex
Annotations
@Nullable
containerKeyback to summary
private final Object containerKey
Annotations
@Nullable
methodParameterback to summary
private final MethodParameter methodParameter
resolvableErrorsback to summary
private final List<MessageSourceResolvable> resolvableErrors

Constructor Detail

ParameterValidationResultback to summary
public ParameterValidationResult(MethodParameter param, Object arg, Collection<? extends MessageSourceResolvable> errors, Object container, Integer index, Object key)

Create a ParameterValidationResult.

ParameterValidationResultback to summary
public ParameterValidationResult(MethodParameter param, Object arg, Collection<? extends MessageSourceResolvable> errors)

Create a ParameterValidationResult.

Annotations
@Deprecated
since:6.1.3
forRemoval:true

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getArgumentback to summary
public Object getArgument()

The method argument value that was validated.

Annotations
@Nullable
getContainerback to summary
public Object getContainer()

When @Valid is declared on a container of elements such as java.util.Collection, java.util.Map, java.util.Optional, and others, this method returns the container of the validated argument, while getContainerIndex() and getContainerKey() provide information about the index or key if applicable.

Annotations
@Nullable
getContainerIndexback to summary
public Integer getContainerIndex()

When @Valid is declared on an indexed container of elements such as List or array, this method returns the index of the validated argument.

Annotations
@Nullable
getContainerKeyback to summary
public Object getContainerKey()

When @Valid is declared on a container of elements referenced by key such as java.util.Map, this method returns the key of the validated argument.

Annotations
@Nullable
getMethodParameterback to summary
public MethodParameter getMethodParameter()

The method parameter the validation results are for.

getResolvableErrorsback to summary
public List<MessageSourceResolvable> getResolvableErrors()

List of MessageSourceResolvable representations adapted from the validation errors of the validation library.

  • For a constraints directly on a method parameter, error codes are based on the names of the constraint annotation, the object, the method, the parameter, and parameter type, e.g. ["Max.myObject#myMethod.myParameter", "Max.myParameter", "Max.int", "Max"]. Arguments include the parameter itself as a MessageSourceResolvable, e.g. ["myObject#myMethod.myParameter", "myParameter"], followed by actual constraint annotation attributes (i.e. excluding "message", "groups" and "payload") in alphabetical order of attribute names.
  • For cascaded constraints via @Valid on a bean method parameter, this method returns field errors that you can also access more conveniently through methods of the ParameterErrors sub-class.
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override