package io.vertx.codegen.type;
import io.vertx.codegen.ClassModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
public enum ClassKind {
STRING(true, false, false),
BOXED_PRIMITIVE(true, false, false),
PRIMITIVE(true, false, false),
ENUM(false, false, false),
JSON_OBJECT(false, true, false),
JSON_ARRAY(false, true, false),
THROWABLE(false, false, false),
VOID(false, false, false),
OBJECT(false, false, false),
LIST(false, false, true),
SET(false, false, true),
MAP(false, false, true),
API(false, false, false),
HANDLER(false, false, false),
FUNCTION(false, false, false),
ASYNC_RESULT(false, false, false),
CLASS_TYPE(false, false, false),
FUTURE(false, false, false),
OTHER(false, false, false);
public final boolean basic;
public final boolean json;
public final boolean collection;
ClassKind(boolean basic, boolean json, boolean collection) {
this.basic = basic;
this.json = json;
this.collection = collection;
}
public static Map<String, ClassKind> vars() {
HashMap<String, ClassKind> vars = new HashMap<>();
for (ClassKind classKind : ClassKind.values()) {
vars.put("CLASS_" + classKind.name(), classKind);
}
return vars;
}
public static ClassKind getKind(String fqcn, boolean isVertxGenAnnotated) {
if (isVertxGenAnnotated) {
return API;
} else if (fqcn.equals("java.lang.Class")) {
return CLASS_TYPE;
} else if (fqcn.equals("io.vertx.core.Future")) {
return FUTURE;
} else if (fqcn.equals(ClassModel.VERTX_HANDLER)) {
return HANDLER;
} else if (fqcn.equals(ClassModel.VERTX_ASYNC_RESULT)) {
return ASYNC_RESULT;
} else if (fqcn.equals(ClassModel.JSON_ARRAY)) {
return JSON_ARRAY;
} else if (fqcn.equals(ClassModel.JSON_OBJECT)) {
return JSON_OBJECT;
} else if (fqcn.equals(Object.class.getName())) {
return OBJECT;
} else if (fqcn.equals(String.class.getName())) {
return STRING;
} else if (fqcn.equals(List.class.getName())) {
return LIST;
} else if (fqcn.equals(Set.class.getName())) {
return SET;
} else if (fqcn.equals(Map.class.getName())) {
return MAP;
} else if (fqcn.equals(Throwable.class.getName())) {
return THROWABLE;
} else if (fqcn.equals(Void.class.getName())) {
return VOID;
} else if (fqcn.equals(Function.class.getName())) {
return FUNCTION;
} else if (fqcn.equals(Integer.class.getName()) ||
fqcn.equals(Long.class.getName()) ||
fqcn.equals(Boolean.class.getName()) ||
fqcn.equals(Double.class.getName()) ||
fqcn.equals(Float.class.getName()) ||
fqcn.equals(Short.class.getName()) ||
fqcn.equals(Character.class.getName()) ||
fqcn.equals(Byte.class.getName())) {
return BOXED_PRIMITIVE;
} else {
return OTHER;
}
}
}