[rules-users] Java beans inheritance

Anstis, Michael (M.) manstis1 at ford.com
Thu Nov 12 11:56:09 EST 2009


If you are checking for class in the LHS would it not be better to
define a separate rule for the subclass?
 
I assume you're doing something like:-
 
rule "current"
    when
        MyClass(class == MySubClassOfMyClass.class)
    then
        //Something specific to the subclass
    end
 
When something like this might be more suited?
 
rule "super"
    when   
        MyClass()
    then
        //Do generic stuff
    end
 
rule "sub"
    when
        MySubClassOfMyClass()
    then
        //Do something more specific
    end
 
I don't know whether this would cause two activations or whether the
more generic would swallow the Fact in the first ObjectType node in the
RETE network; Edson?

________________________________

	From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
	Sent: 12 November 2009 16:48
	To: Rules Users List
	Subject: Re: [rules-users] Java beans inheritance
	
	
	Are you using MVEL at all in this rule?
	
	Anyway, better would be
	
	   class == SomeClass.class
	
	which avoids string handling.
	
	-W
	
	
	
	On Thu, Nov 12, 2009 at 3:25 PM, Zohar Etzioni
<zohar.etzioni at gmail.com> wrote:
	

		Hi,
		
		I have a class hierarchy of objects that I'm inserting
as facts. Lets
		say X, Y extends X and Z extends Y. I have a rule that
is defined on X
		and therefore applies to all of them, however in the
rule I want to
		ask about the class name and I'm referring to it as
		class.name=="some.class". This should work as far as I
understand coz
		it keeps the java beans format, however it is not
directly defined in
		the class X but rather in Object. The error I'm getting
is "Error:
		could not access: name". Any idea what I'm doing wrong?
		
		Thanks,
		Dawg
		_______________________________________________
		rules-users mailing list
		rules-users at lists.jboss.org
		https://lists.jboss.org/mailman/listinfo/rules-users
		


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091112/32b20cd1/attachment.html 


More information about the rules-users mailing list