Print

Print


The only constraints ECJ provides are its strong typing constraints (see the manual).  Beyond that you're on your own.

Sean

On May 2, 2013, at 12:14 PM, Bojan Janisch wrote:

> Hi everyone,
> 
> is there a way to set a generic constraint for a GPNode at runtime?
> 
> Background:
> 
> I've a class called FactChecker.class. In this class there are many many boolean methods 
> which compare textbased entites.
> 
> A method could look like:
> 
> public boolean comesAfter(Entity a, Entity b){
> 
> b comes after a? return true;
> else return false;
> }
> 
> So now I don't have only so easy methods, they could also be:
> 
> public boolean comesAfterInRange(Entity a, Entity b, int r){
> 
> b comes after a in range r? return true;
> else return false;
> }
> 
> And so on... Now I need a way to constrain a GPNode to the types a method needs. The methods 
> are chosen randomly, so I don't know which classes a method will need. 
> 
> Up till now I'm checking only if all children-classes, match the order of classes 
> needed for the method to invoke. If they're fine I'll let the node evaluate, otherwise
> I skip the invoking, so basically the use of the method itself, what makes the tree useless but
> for now I don't get any IllegalArgumentException anymore and that saves me some nerve (Can't
> see this exception anymore...)
> 
> Is there a way to generate constraints at runtime so that I can check for the classes and don't
> even let such nodes generate?
> 
> Greetings
> Bojan