
javax.mvc.binding.BindingResult Maven / Gradle / Ivy
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2018 JSR 371 expert group and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.mvc.binding;
import java.util.List;
import java.util.Set;
/**
* Describes the binding result of all controller fields and controller
* method parameters which are annotated with a binding annotation like
* {@link javax.ws.rs.FormParam}.
*
* A binding can fail because of type conversion issues or in case of validation
* errors. The former can for example happen if the binding annotation is placed on
* a numeric type but the value cannot be converted to that type. The latter may be
* caused by constraint violations detected during validation.
*
*
* Controller methods which declare a parameter of this type will be executed
* even if the binding for fields and method parameters fails.
*
* @author Christian Kaltepoth
* @since 1.0
*/
public interface BindingResult {
/**
* Returns true
if there is at least one parameter error.
*
* @return true
if there is at least one parameter error
*/
boolean isFailed();
/**
* Returns an immutable list of all messages representing both binding and
* validation errors. This method is a shortcut for:
*
*
* getAllErrors().stream().map(ParamError::getMessage).collect(Collectors.toList())
*
*
* @return A list of human-readable messages
*/
List getAllMessages();
/**
* Returns an immutable set of all binding and validation errors.
*
* @return All binding and validation errors.
*/
Set getAllErrors();
/**
* Returns an immutable set of all binding and validation errors for
* a specific parameter.
*
* @param param parameter name
* @return All binding and validation errors for the parameter.
*/
Set getErrors(String param);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy