com.baidu.unbiz.fluentvalidator
类 QuickValidator

java.lang.Object
  继承者 com.baidu.unbiz.fluentvalidator.QuickValidator

public class QuickValidator
extends Object

Quick validator for quickly executing template code like below:

 Result ret = FluentValidator.checkAll().configure(new SimpleRegistry())
         .on(car)
         .doValidate()
         .result(toSimple());
 

作者:
zhangxu

构造方法摘要
QuickValidator()
           
 
方法摘要
static ComplexResult doAndGetComplexResult(Decorator decorator)
          Execute validation by using a new FluentValidator instance without a shared context.
static ComplexResult doAndGetComplexResult(Decorator decorator, ValidatorContext context)
          Execute validation by using a new FluentValidator instance with a shared context.
static ComplexResult2 doAndGetComplexResult2(Decorator decorator)
          Execute validation by using a new FluentValidator instance and without a shared context.
static ComplexResult2 doAndGetComplexResult2(Decorator decorator, ValidatorContext context)
          Execute validation by using a new FluentValidator instance with a shared context.
static
<T extends GenericResult<ValidationError>>
T
validate(Decorator decorator, FluentValidator fluentValidator, ValidatorContext context, ResultCollector<T> resultCollector)
          Use the decorator to add or attach more functions the given fluentValidator instance.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

QuickValidator

public QuickValidator()
方法详细信息

doAndGetComplexResult

public static ComplexResult doAndGetComplexResult(Decorator decorator,
                                                  ValidatorContext context)
Execute validation by using a new FluentValidator instance with a shared context. The result type is ComplexResult

参数:
decorator - Same as decorator design pattern, provided to add more functions to the fluentValidator
context - Validation context which can be shared
返回:
ComplexResult

doAndGetComplexResult

public static ComplexResult doAndGetComplexResult(Decorator decorator)
Execute validation by using a new FluentValidator instance without a shared context. The result type is ComplexResult

参数:
decorator - Same as decorator design pattern, provided to add more functions to the fluentValidator
context - Validation context which can be shared
返回:
ComplexResult

doAndGetComplexResult2

public static ComplexResult2 doAndGetComplexResult2(Decorator decorator,
                                                    ValidatorContext context)
Execute validation by using a new FluentValidator instance with a shared context. The result type is ComplexResult2

参数:
decorator - Same as decorator design pattern, provided to add more functions to the fluentValidator
context - Validation context which can be shared
返回:
ComplexResult2

doAndGetComplexResult2

public static ComplexResult2 doAndGetComplexResult2(Decorator decorator)
Execute validation by using a new FluentValidator instance and without a shared context. The result type is ComplexResult2

参数:
decorator - Same as decorator design pattern, provided to add more functions to the fluentValidator
返回:
ComplexResult2

validate

public static <T extends GenericResult<ValidationError>> T validate(Decorator decorator,
                                                                    FluentValidator fluentValidator,
                                                                    ValidatorContext context,
                                                                    ResultCollector<T> resultCollector)
Use the decorator to add or attach more functions the given fluentValidator instance.

The context can be shared and set up in the new FluentValidator instance.

The motivation for this method is to provide a quick way to launch a validation task. By just passing the validation logic which is wrapped inside the decorator, users can do validation in a ease way.

Because Java7 lacks the ability to pass "action" to a method, so there is Decorator to help to achieve a functional programming approach to get it done. In Java8, users can replace it with lambda.

参数:
decorator - Same as decorator design pattern, provided to add more functions to the fluentValidator
fluentValidator - The base fluentValidator to be executed upon
context - Validation context which can be shared
resultCollector - Result collector
返回:
Result


Copyright © 2015–2016 neoremind. All rights reserved.