use of com.bakdata.conquery.introspection.Introspection in project conquery by bakdata.
the class GroupHandler method handleField.
private void handleField(ClassInfo currentType, FieldInfo field) throws IOException {
if (!isJSONSettableField(field)) {
return;
}
Introspection introspec = Introspection.from(root, field.getClassInfo()).findField(field);
String name = field.getName();
TypeSignature typeSignature = field.getTypeSignatureOrTypeDescriptor();
Ctx ctx = new Ctx().withField(field);
String type;
if (ID_REF.stream().anyMatch(field::hasAnnotation)) {
type = ID_OF + printType(ctx.withIdOf(true), typeSignature);
} else if (ID_REF_COL.stream().anyMatch(field::hasAnnotation)) {
type = LIST_OF + ID_OF + StringUtils.removeStart(printType(ctx.withIdOf(true), typeSignature), LIST_OF);
} else {
type = printType(ctx, typeSignature);
}
out.table(editLink(introspec), name, type, findDefault(currentType, field), introspec.getExample(), introspec.getDescription());
}
use of com.bakdata.conquery.introspection.Introspection in project conquery by bakdata.
the class GroupHandler method handleClass.
private void handleClass(String name, ClassInfo c) throws IOException {
Introspection source = Introspection.from(root, c);
try (Closeable details = details(name, c, source)) {
if (c.getFieldInfo().stream().anyMatch(this::isJSONSettableField)) {
out.line("Supported Fields:");
out.tableHeader("", "Field", "Type", "Default", "Example", "Description");
for (FieldInfo field : c.getFieldInfo().stream().sorted().collect(Collectors.toList())) {
handleField(c, field);
}
} else {
out.paragraph("No fields can be set for this type.");
}
}
}
use of com.bakdata.conquery.introspection.Introspection in project conquery by bakdata.
the class GroupHandler method handleEndpoint.
private void handleEndpoint(String url, MethodInfo method) throws IOException {
Introspection introspec = Introspection.from(root, method.getClassInfo()).findMethod(method);
try (Closeable details = details(getRestMethod(method) + "\u2001" + url, method.getClassInfo(), introspec)) {
out.paragraph("Method: " + code(method.getName()));
for (MethodParameterInfo param : method.getParameterInfo()) {
if (param.hasAnnotation(PATH_PARAM) || param.hasAnnotation(AUTH) || param.hasAnnotation(CONTEXT)) {
continue;
}
out.line("Expects: " + printType(new Ctx(), param.getTypeSignatureOrTypeDescriptor()));
}
out.paragraph("Returns: " + printType(new Ctx(), method.getTypeSignatureOrTypeDescriptor().getResultType()));
}
}
use of com.bakdata.conquery.introspection.Introspection in project conquery by bakdata.
the class GroupHandler method handleMarkerInterface.
private void handleMarkerInterface(String name, ClassInfo c) throws IOException {
Introspection source = Introspection.from(root, c);
try (Closeable details = details(name, c, source)) {
Set<String> values = new HashSet<>();
for (Class<?> cl : group.getOtherClasses()) {
if (c.loadClass().isAssignableFrom(cl)) {
values.add("[" + cl.getSimpleName() + "](" + anchor(typeTitle(cl)) + ")");
}
}
content.values().stream().filter(p -> c.loadClass().isAssignableFrom(p.getRight().loadClass())).forEach(p -> values.add("[" + p.getLeft().id() + "](" + anchor(p.getLeft().id()) + ")"));
for (Class<?> cl : group.getMarkerInterfaces()) {
if (c.loadClass().isAssignableFrom(cl) && !c.loadClass().equals(cl)) {
values.add("[" + cl.getSimpleName() + "](" + anchor(typeTitle(cl)) + ")");
}
}
if (!values.isEmpty()) {
out.paragraph("A " + name + " is any of:\n* " + values.stream().sorted().collect(Collectors.joining("\n* ")));
}
}
}
Aggregations