Cannot use "contains" operation for an object of runtime type List gotten from Map.

Solution Unverified - Updated -

Issue

On RHDM 7.12.0 or later releases, when we build a project containing a rule like (*1) and a data object like (*2), the error (*3) occurs against the constraint (*1-1).

(*1) Example rule

dialect "mvel"

rule "Rule 1"
    when
        DataStore( data["FinalistsTeamList"] contains "Argentina" )    // (*1-1) data["FinalistsTeamList"] contains "Argentina"
    then
        System.out.println("***** Action of Rule 1");
end

(*2) Example Data Object

public class DataStore {
    private Map<String, Object> data;

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
}

(*3) Error in question

Cannot use contains on class java.lang.Object in expression 'data["FinalistsTeamList"] contains "Argentina"' : [Rule name='Rule 1']

Environment

  • Red Hat Decision Manager (RHDM)
    • 7.12.0 or later releases

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content