javadoc polish; added errors() to BindingResults
This commit is contained in:
parent
e6b6743c44
commit
4ed3924e6f
|
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||
* Bind to fields of a model object.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
* @see #bind(Map)
|
||||
* @param <M> The type of model this binder binds to
|
||||
*/
|
||||
public interface Binder<M> {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.springframework.model.alert.Alert;
|
|||
* The result of a bind operation.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
* @see Binder#bind(java.util.Map)
|
||||
* @see Binder#bind(java.util.Map, Object)
|
||||
*/
|
||||
public interface BindingResult {
|
||||
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@
|
|||
*/
|
||||
package org.springframework.model.binder;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.model.alert.Severity;
|
||||
|
||||
/**
|
||||
* The results of a bind operation.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
* @see Binder#bind(UserValues)
|
||||
* @see Binder#bind(java.util.Map, Object)
|
||||
*/
|
||||
public interface BindingResults extends Iterable<BindingResult> {
|
||||
|
||||
|
|
@ -30,17 +30,22 @@ public interface BindingResults extends Iterable<BindingResult> {
|
|||
*/
|
||||
BindingResults successes();
|
||||
|
||||
/**
|
||||
* If there is at least one failed BindingResult.
|
||||
* @see BindingResult#isFailure()
|
||||
*/
|
||||
boolean hasFailures();
|
||||
|
||||
/**
|
||||
* The subset of BindingResults that failed.
|
||||
*/
|
||||
BindingResults failures();
|
||||
|
||||
|
||||
/**
|
||||
* If there is at least one failure with a Severity equal to or greater than {@link Severity#ERROR}.
|
||||
* @see BindingResults#failures()
|
||||
*/
|
||||
boolean hasErrors();
|
||||
|
||||
/**
|
||||
* The subset of BindingResults that failed with {@link Severity#ERROR} or greater.
|
||||
*/
|
||||
BindingResults errors();
|
||||
|
||||
/**
|
||||
* The total number of results.
|
||||
*/
|
||||
|
|
@ -52,9 +57,4 @@ public interface BindingResults extends Iterable<BindingResult> {
|
|||
*/
|
||||
BindingResult get(int index);
|
||||
|
||||
/**
|
||||
* The ordered list of properties for which a {@link BindingResult} was returned.
|
||||
*/
|
||||
List<String> properties();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
* Indicates a client configuration error.
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
* @see Binder#bind(java.util.Map)
|
||||
* @see Binder#bind(Map, Object)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MissingFieldException extends RuntimeException {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ import org.springframework.util.Assert;
|
|||
* @since 3.0
|
||||
* @see #setRequiredFields(String[])
|
||||
* @see #setMessageSource(MessageSource)
|
||||
* @see #bind(Map, Object)
|
||||
* @see #createBindTemplate()
|
||||
* @see #bind(Map, Object)
|
||||
*/
|
||||
public abstract class AbstractBinder<M> implements Binder<M> {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.model.alert.Severity;
|
||||
import org.springframework.model.binder.BindingResult;
|
||||
import org.springframework.model.binder.BindingResults;
|
||||
|
||||
|
|
@ -56,10 +57,6 @@ class ArrayListBindingResults implements BindingResults {
|
|||
return results;
|
||||
}
|
||||
|
||||
public boolean hasFailures() {
|
||||
return failures().size() > 0;
|
||||
}
|
||||
|
||||
public BindingResults failures() {
|
||||
ArrayListBindingResults results = new ArrayListBindingResults();
|
||||
for (BindingResult result : this) {
|
||||
|
|
@ -70,16 +67,22 @@ class ArrayListBindingResults implements BindingResults {
|
|||
return results;
|
||||
}
|
||||
|
||||
public BindingResult get(int index) {
|
||||
return results.get(index);
|
||||
public boolean hasErrors() {
|
||||
return errors().size() > 0;
|
||||
}
|
||||
|
||||
public BindingResults errors() {
|
||||
ArrayListBindingResults results = new ArrayListBindingResults();
|
||||
for (BindingResult result : this) {
|
||||
if (result.isFailure() && result.getAlert().getSeverity().compareTo(Severity.ERROR) >= 0) {
|
||||
results.add(result);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public List<String> properties() {
|
||||
List<String> properties = new ArrayList<String>(results.size());
|
||||
for (BindingResult result : this) {
|
||||
properties.add(result.getFieldName());
|
||||
}
|
||||
return properties;
|
||||
public BindingResult get(int index) {
|
||||
return results.get(index);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue