[bv-dev] Bean Validation and lambda expressions

Gunnar Morling gunnar at hibernate.org
Mon Oct 8 13:10:21 EDT 2012


Hi,

I'm not sure what's the current state regarding method references in
Java 8. If they're in, we might make use of them for property
validation:

validator.validateProperty(car, Car::getManufacturer);
validator.validateValue(Car::manufacturer, "Morris");

Or if we add one day an API for programmatic constraint definition
(example based on the API in HV):

ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Car.class )
    .property( Car::getManufacturer" )
        .constraint( NotNull.class )
        .constraint( Size.class ).with( Size::min, 2).with( Size::max, 14 );

That's just a quick thought, not sure whether that really works or
makes too much sense, though.

--Gunnar


2012/10/8 Matt Benson <mbenson at apache.org>:
> That was my reaction as well, wondering whether anyone else would
> propose any ways of augmenting the BV APIs to include
> lambda-compatible interfaces.
>
> Matt
>
> On Mon, Oct 8, 2012 at 11:07 AM, Michael Nascimento <misterm at gmail.com> wrote:
>> Given there are no function types for now, I wonder what sort of
>> impact could it have...
>>
>> Regards,
>> Michael
>>
>> On Mon, Oct 8, 2012 at 8:59 AM, Emmanuel Bernard <emmanuel at hibernate.org> wrote:
>>> How do you think Java 8 lambda expression support will affect Bean
>>> Validation APIs? I have not thought about it yet but there might be
>>> interesting possibilities.
>>>
>>> https://hibernate.onjira.com/browse/BVAL-313
>>>
>>> Emmanuel
>>> _______________________________________________
>>> beanvalidation-dev mailing list
>>> beanvalidation-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>> _______________________________________________
>> beanvalidation-dev mailing list
>> beanvalidation-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev


More information about the beanvalidation-dev mailing list