[jboss-jira] [JBoss JIRA] (DROOLS-2594) drools compiler doesn't accept is as getter for boolean attribute of POJO

Mario Fusco (JIRA) issues at jboss.org
Tue Jun 5 04:16:00 EDT 2018


    [ https://issues.jboss.org/browse/DROOLS-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13586529#comment-13586529 ] 

Mario Fusco commented on DROOLS-2594:
-------------------------------------

I tried this simple reproducer and it works for me. 

{code}
    public static class Pojo {
        private final boolean current;

        public Pojo( boolean current ) {
            this.current = current;
        }

        public boolean isCurrent() {
            return current;
        }
    }

    @Test
    public void testBooleanAttribute() {
        String str =
                "import " + Pojo.class.getCanonicalName() + ";\n" +
                "rule R when\n" +
                "  Pojo( current == true )\n" +
                "then\n" +
                "end\n";

        KieSession ksession = new KieHelper().addContent( str, ResourceType.DRL ).build().newKieSession();

        ksession.insert( new Pojo( true ) );
        assertEquals( 1, ksession.fireAllRules() );
    }
{code}

Note that you can also replace Pojo( current == true ) with just Pojo( current ).

For now I'm flagging this ticket as cannot reproduce. In case you confirm that this problem is present feel free to reopen the ticket and provide your reproducer.

> drools compiler doesn't accept is as getter for boolean attribute of POJO
> -------------------------------------------------------------------------
>
>                 Key: DROOLS-2594
>                 URL: https://issues.jboss.org/browse/DROOLS-2594
>             Project: Drools
>          Issue Type: Bug
>         Environment: CentOS 7, maven build
>            Reporter: Gal Nitzan
>            Assignee: Mario Fusco
>            Priority: Critical
>              Labels: drools, drools-compiler
>
> Hi, based on [7.7.0 documentation|https://docs.jboss.org/drools/release/7.7.0.Final/drools-docs/html_single/index.html#_constraint_part_of_a_pattern] a POJO boolean getter can be isMyAttribute or getMyAttribute.
> We get the following exception when using is as prefix for boolean getter as follows:
> 2018-05-28 22:17:41 [main] ERROR o.d.c.kie.builder.impl.KieProject - Unable to build KieBaseModel:myKbase
> Unable to Analyse Expression current == true:
> [Error: unable to resolve method using strict-mode: com.acme.pojos.current()]
> [Near : {... current == true ....}]



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list