Mark Park
Mark Park

Reputation: 13

Drools - Pulling an ArrayList<String> from a HashMap<String, Object> in drools

For the life of me I cannot pull a simple String ArrayList from my generic hashmap: HashMap<String, Object>

I have been able to pull much more complicated structures such as List of objects which are nested and possess other collections, as they are treated as a LinkedHashMap when retrieving.

But when I try to pull a simple String ArrayList from the hashmap, it never pulls.

$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
$test: ArrayList() from $mappings["role"]

I've also tried many other iterations..

$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
$test: ArrayList(size > 0) from (ArrayList) $mappings["role"]
$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
$test: List(size > 0) from (List) $mappings["role"]
$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
$test: List() from $mappings["role"]
$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
$test: List() from $mappings.get("role")
$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
$test: ArrayList() from $mappings.get("role")
$nonNull: SomeObject(mappings != null) 
$mappings: HashMap() from $nonNull.getMappings() 
ArrayList($test : size > 0) from $mappings.get("role")

Why is it so difficult to pull a simple ArrayList when I can pull incredibly nested structures from this hashmap.

I have ensured I have the proper imports in the .drl file.

I am using mvn dependency Drools 7.58

Upvotes: 0

Views: 36

Answers (0)

Related Questions