polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: Predicates as Constraints
Date Wed, 09 Sep 2015 14:20:52 GMT
:-)

On Mon, Sep 7, 2015 at 11:42 PM, Paul Merlin <paul@nosphere.org> wrote:

> 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
>
>


-- 
Niclas Hedhman, Software Developer
http://zest.apache.org - New Energy for Java

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message