Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Oct 28, 2024
1 parent 61b51a6 commit b8de3e2
Show file tree
Hide file tree
Showing 6 changed files with 808 additions and 424 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.drools.ansible.rulebook.integration.api;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;


public class LogUtil {

private LogUtil() {
Expand All @@ -10,18 +15,26 @@ 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",
List.class, "list",
ArrayList.class, "list",
Map.class, "dict",
LinkedHashMap.class, "dict",
HashMap.class, "dict"
);

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";
}
return javaClass.getSimpleName();
}
}
Loading

0 comments on commit b8de3e2

Please sign in to comment.