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

Wolfgang Laun wolfgang.laun at gmail.com
Wed Feb 26 13:49:05 EST 2014


The declare results in a bean, with constructors according to what you
have written, with getters and setters, and methods overriding toText,
equals and hashCode.

-W

On 26/02/2014, profversaggi <profversaggi at gmail.com> wrote:
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list