in kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/proto/AbstractProtoGenerator.java [243:297]
protected String protoType(String type) {
if (protoBuiltins().contains(type)) {
return null;
}
LOGGER.debug("Computing proto type for {}", type);
if (String.class.getCanonicalName().equals(type) || String.class.getSimpleName().equalsIgnoreCase(type)) {
return "string";
} else if (Integer.class.getCanonicalName().equals(type) || "int".equalsIgnoreCase(type)) {
return "int32";
} else if (Long.class.getCanonicalName().equals(type) || "long".equalsIgnoreCase(type)) {
return "int64";
} else if (Double.class.getCanonicalName().equals(type) || "double".equalsIgnoreCase(type)) {
return "double";
} else if (Float.class.getCanonicalName().equals(type) || "float".equalsIgnoreCase(type)) {
return "float";
} else if (Boolean.class.getCanonicalName().equals(type) || "boolean".equalsIgnoreCase(type)) {
return "bool";
} else if (Date.class.getCanonicalName().equals(type) || "date".equalsIgnoreCase(type)) {
return "kogito.Date";
} else if (byte[].class.getCanonicalName().equals(type) || "[B".equalsIgnoreCase(type)) {
return "bytes";
} else if (Instant.class.getCanonicalName().equals(type)) {
return "kogito.Instant";
} else if (type.startsWith("java.lang") || type.startsWith("java.util") || type.startsWith("java.time") || type.startsWith("java.math")) {
try {
Class<?> cls = Class.forName(type);
if (cls.isInterface()) {
return null;
}
boolean assignable = Serializable.class.isAssignableFrom(cls);
if (assignable) {
return KOGITO_SERIALIZABLE;
} else {
throw new IllegalArgumentException(format("Java type %s is no supported by Kogito persistence, please consider using a class that extends java.io.Serializable", type));
}
} catch (ClassNotFoundException e) {
return null;
}
} else {
try {
Class<?> cls = Class.forName(type);
if (cls.isEnum() || hasDefaultConstructor(cls)) {
return null;
} else if (Serializable.class.isAssignableFrom(cls)) {
return KOGITO_SERIALIZABLE;
} else {
throw new IllegalArgumentException(
format("Custom type %s is no supported by Kogito persistence, please consider using a class that extends java.io.Serializable and contains a no arg constructor", type));
}
} catch (ClassNotFoundException e) {
return null;
}
}
}