polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Merlin <p...@nosphere.org>
Subject Re: Predicates as Constraints
Date Mon, 07 Sep 2015 15:42:36 GMT
Niclas Hedhman a écrit :
> No, please.... ;-)  No programming language in annotations.
>
> Is that even possible??
>
> You are trying to avoid new annotations, and build logic with smaller ones.
> It feels super-icky to me...
> Off the top of my head, something like this;
>
> void someMethod( @PaulsDreaming(1,4,8) Integer something );
>
> @ConstraintFactory( PaulsDreamFactory.class )
> public interface @PaulsDreaming
> {
>     int[] value();
> }
>
> public class PaulsDreamFactory
> {
>     public Predicate<Integer> create( PaulsDreaming annot )
>     {
>         int[] values = annot.values();
>         return new RangePredicate( values[0], values[1])
>                .or( new MinPredicate( values[2] ) );
>     }
> }
You're damn right Niclas. I must have abused of something too strong for
me. Now going to rehab ...

And now I see what is the ConstraintFactory you wrote about earlier.

Cheers

/Paul


Mime
View raw message