use of org.kie.workbench.common.services.datamodeller.driver.TypeInfoResult in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method loadJavaTypeInfo.
public TypeInfoResult loadJavaTypeInfo(final String source) throws ModelDriverException {
TypeInfoResult result = new TypeInfoResult();
if (source == null || "".equals(source)) {
logger.debug("source: " + source + " is empty.");
result.addError(new DriverError("Source is empty"));
return result;
}
try {
JavaType<?> javaType = Roaster.parse(source);
if (javaType.getSyntaxErrors() != null && !javaType.getSyntaxErrors().isEmpty()) {
addSyntaxErrors(result, null, javaType.getSyntaxErrors());
} else {
JavaTypeInfoImpl typeInfo = new JavaTypeInfoImpl();
result.setTypeInfo(typeInfo);
typeInfo.setName(javaType.getName());
typeInfo.setPackageName(javaType.getPackage());
typeInfo.setAnnotation(javaType.isAnnotation());
typeInfo.setClass(javaType.isClass());
typeInfo.setEnum(javaType.isEnum());
typeInfo.setInterface(javaType.isInterface());
typeInfo.setPackagePrivate(javaType.isPackagePrivate());
typeInfo.setPrivate(javaType.isPrivate());
typeInfo.setProtected(javaType.isProtected());
typeInfo.setPublic(javaType.isPublic());
}
} catch (ParserException e) {
result.addError(new DriverError(e.getMessage()));
} catch (Exception e) {
// Unexpected parsing o model loading exception.
logger.error(errorMessage(GENERIC_ERROR, e));
throw new ModelDriverException(errorMessage(MODEL_LOAD_GENERIC_ERROR), e);
}
return result;
}
Aggregations