Skip to content

Commit

Permalink
[DROOLS-7639] ansible-rulebook : support event path for collecting el… (
Browse files Browse the repository at this point in the history
#124) (#128)

* [DROOLS-7639] ansible-rulebook : support event path for collecting elements in array in array
- WIP: test case only

* WIP implementation

* - improved nested list management

* Added more tests

* convert Set too
  • Loading branch information
tkobayas authored Nov 11, 2024
1 parent fd6f945 commit 461e830
Show file tree
Hide file tree
Showing 5 changed files with 959 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.drools.ansible.rulebook.integration.api;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class LogUtil {

Expand All @@ -10,18 +12,23 @@ private LogUtil() {

// convert java class to python class
private static Map<Class<?>, String> convertMap = Map.of(
java.lang.Integer.class, "int",
java.lang.Boolean.class, "bool",
java.lang.String.class, "str",
java.lang.Double.class, "float",
java.util.List.class, "list",
java.util.ArrayList.class, "list",
java.util.Map.class, "dict",
java.util.LinkedHashMap.class, "dict",
java.util.HashMap.class, "dict"
Integer.class, "int",
Boolean.class, "bool",
String.class, "str",
Double.class, "float"
);

public static String convertJavaClassToPythonClass(Class<?> javaClass) {
return convertMap.getOrDefault(javaClass, javaClass.getSimpleName());
if (convertMap.containsKey(javaClass)) {
return convertMap.get(javaClass);
}
if (List.class.isAssignableFrom(javaClass)) {
return "list";
} else if (Map.class.isAssignableFrom(javaClass)) {
return "dict";
} else if (Set.class.isAssignableFrom(javaClass)) {
return "set";
}
return javaClass.getSimpleName();
}
}
Loading

0 comments on commit 461e830

Please sign in to comment.