[rules-dev] Declared types - extension

Michael Anstis michael.anstis at gmail.com
Wed Jul 13 08:00:51 EDT 2011


Wolfgang, still no news as to the expected behaviour :(

Sotty, I appreciate you are probably busy with other activities, however any
your thoughts on the following would be most welcome:-

   - For POJOs is a field only added to the declared type if it has a getter
   and setter (something laune said he'd seen; email earlier in this thread)?
   - Are fact-level annotations inherited?
   - Are field-level annotations inherited?
   - Type erasure on subclasses, if type A declares "myVar : String" and
   type B extends A and declaring "myVar : Integer", what should happen?

For others interested, here's some answers already received:

   - Can declarative types extend Java POJOs and other declared types?

<sotty> yes

   - For POJO's do I need to include an "empty" declaration? So "declare
   java.util.ArrayList end" if I want to "declare MyList extends ArrayList" in
   a java.util package?

<sotty> no, it should be enough to import the fqn or use it in the
"extends".
*<manstis> note this is different to what is documented in the Drools Expert
user-guide
*
Thanks,

Mike

On 12 July 2011 13:12, Michael Anstis <michael.anstis at gmail.com> wrote:

> https://issues.jboss.org/browse/JBRULES-3133 created.
>
>
> On 12 July 2011 13:08, Michael Anstis <michael.anstis at gmail.com> wrote:
>
>> There's also a quirk regarding the class resolution:-
>>
>> Given Person class:-
>>
>> package com.guvnor.domain;
>>
>> import java.math.BigDecimal;
>>
>> public class Person {
>>
>>     private BigDecimal salary;
>>
>>     public BigDecimal getSalary() {
>>         return salary;
>>     }
>>
>>     public void setSalary(BigDecimal salary) {
>>         this.salary = salary;
>>     }
>>
>> }
>>
>>
>> The following compiles OK:-
>>
>> package com.sample
>>
>> import com.guvnor.domain.Person
>>
>> declare Person
>> end
>>
>> However the following does not (without explicitly importing
>> java.math.BigDecimal - which is a field type in Person):-
>>
>> package com.sample
>>
>> import com.guvnor.domain.Person
>> import com.guvnor.domain.Address
>>
>> declare Person
>> end
>>
>> declare Person2 extends Person
>>     flange : String
>> end
>>
>> Error being "Unknown DroolsError class
>> org.drools.compiler.TypeDeclarationError: Unable to find class 'BigDecimal'
>> ".
>>
>> With kind regards,
>>
>> Mike
>>
>>
>> On 11 July 2011 08:41, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
>>
>>> Subsection 5.7.7 discusses 'extends' and describes how it is done for
>>> types declared in Java.
>>>
>>> One finesse is apparently not documented: Java types must be proper
>>> JavaBeans; otherwise the construction of the accessors will fail. (Try, for
>>> instance, a property with a getter but no matching setter.)
>>>
>>> HTH
>>> -W
>>>
>>>
>>> On 10 July 2011 22:29, Michael Anstis <michael.anstis at gmail.com> wrote:
>>>
>>>> What's the rules around declared types extending another (declared)
>>>> type?
>>>>
>>>> I've been asked to provide for declared type extension in Guvnor (by
>>>> Prakash) but the Expert user-guide doesn't say it exists at the engine
>>>> level.
>>>>
>>>> I tried "declare MyType extends java.util.ArrayList" and received a
>>>> parser\compiler error stating "java.util.ArrayList was not a declared type"
>>>> (or words to that effect) so some form of extension appears possible.
>>>>
>>>> Thanks,
>>>>
>>>> Mike
>>>>
>>>> _______________________________________________
>>>> rules-dev mailing list
>>>> rules-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>>
>>>>
>>>
>>> _______________________________________________
>>> rules-dev mailing list
>>> rules-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110713/99e43896/attachment.html 


More information about the rules-dev mailing list