[rules-users] @key declarations for a type - What's under the hood?

profversaggi profversaggi at gmail.com
Wed Feb 26 13:11:12 EST 2014


Is there any way to interrogate exactly, as in get a printed representation
of what goes on under the hood for one of these type of declarations ?

As an example: (as per the docs) for a declared type like the following:

declare Person
    *firstName : String @key*
    *lastName : String @key*
    age : int
end

The compiler will implicitly generate 3 constructors: one without
parameters, 
one with the @key fields, and one with all fields.

Person() // parameterless constructor
Person( String firstName, String lastName )
Person( String firstName, String lastName, int age )

...creating an instance using the @key constructor

/Person person = new Person( "John", "Doe" );/

****************

So lets say I do the following:


declare Here
    location: String @key
end

I understand that it does the above, but it *also* lets me do this as well:

*    Here here = new Here("kitchen");
    System.out.println( here );
    System.out.println( here.getLocation(); );
    $lh : Here (location == "kitchen")
    System.out.println( "You are in the " + $lh.getLocation() );*

And get ...

*Here( location=kitchen )
kitchen
You are in the kitchen*

... from various rules I've created ... so there is a lot going on under the
hood, I just want to get a complete inventory of what that is and how I
inspect it for more complex type declarations.

Any ideas?


-matt







--
View this message in context: http://drools.46999.n3.nabble.com/key-declarations-for-a-type-What-s-under-the-hood-tp4028343.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list