use of org.kie.workbench.common.stunner.core.definition.annotation.DefinitionSet in project kie-wb-common by kiegroup.
the class MainProcessor method processDefinitionSetModelBuilder.
private void processDefinitionSetModelBuilder(final Element e, final String className, final Map<String, String> processingContextMap) {
DefinitionSet definitionAnn = e.getAnnotation(DefinitionSet.class);
TypeMirror bMirror = null;
try {
Class<?> builderClass = definitionAnn.builder();
} catch (MirroredTypeException mte) {
bMirror = mte.getTypeMirror();
}
if (null != bMirror && !VoidBuilder.class.getName().equals(bMirror.toString())) {
String fqcn = bMirror.toString();
processingContextMap.put(className, fqcn);
}
}
use of org.kie.workbench.common.stunner.core.definition.annotation.DefinitionSet in project kie-wb-common by kiegroup.
the class BackendBindableDefinitionUtils method getDefinitions.
public static <T> Set<Class<?>> getDefinitions(final T definitionSet) {
Set<Class<?>> result = null;
if (null != definitionSet) {
DefinitionSet annotation = definitionSet.getClass().getAnnotation(DefinitionSet.class);
if (null != annotation) {
Class<?>[] definitions = annotation.definitions();
if (definitions.length > 0) {
result = new HashSet<Class<?>>(definitions.length);
Collections.addAll(result, definitions);
}
}
}
return result;
}
use of org.kie.workbench.common.stunner.core.definition.annotation.DefinitionSet in project kie-wb-common by kiegroup.
the class MainProcessor method processDefinitionSets.
private boolean processDefinitionSets(final Set<? extends TypeElement> set, final Element e, final RoundEnvironment roundEnv) throws Exception {
final Messager messager = processingEnv.getMessager();
final boolean isClass = e.getKind() == ElementKind.CLASS;
if (isClass) {
TypeElement classElement = (TypeElement) e;
PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
messager.printMessage(Diagnostic.Kind.NOTE, "Discovered definition set class [" + classElement.getSimpleName() + "]");
final String packageName = packageElement.getQualifiedName().toString();
final String className = classElement.getSimpleName().toString();
processingContext.setDefinitionSet(packageName, className);
String defSetClassName = packageName + "." + className;
// Description fields.
processFieldName(classElement, defSetClassName, ANNOTATION_DESCRIPTION, processingContext.getDefSetAnnotations().getDescriptionFieldNames(), false);
// Definitions identifiers.
DefinitionSet definitionSetAnn = e.getAnnotation(DefinitionSet.class);
List<? extends TypeMirror> mirrors = null;
try {
Class<?>[] defsClasses = definitionSetAnn.definitions();
} catch (MirroredTypesException mte) {
mirrors = mte.getTypeMirrors();
}
if (null == mirrors) {
throw new RuntimeException("No graph class class specifyed for the @DefinitionSet.");
}
Set<String> defIds = new LinkedHashSet<>();
for (TypeMirror mirror : mirrors) {
if (mirror.getKind().equals(TypeKind.DECLARED)) {
final TypeElement t = (TypeElement) ((DeclaredType) mirror).asElement();
processingContext.getDefinitionElements().add(t);
}
String fqcn = mirror.toString();
defIds.add(fqcn);
}
processingContext.getDefSetAnnotations().getDefinitionIds().addAll(defIds);
// Builder class.
processDefinitionSetModelBuilder(e, defSetClassName, processingContext.getDefSetAnnotations().getBuilderFieldNames());
// Graph factory type.
TypeMirror mirror = null;
try {
Class<?> graphClass = definitionSetAnn.graphFactory();
} catch (MirroredTypeException mte) {
mirror = mte.getTypeMirror();
}
if (null == mirror) {
throw new RuntimeException("No graph factory class specifyed for the @DefinitionSet.");
}
String fqcn = mirror.toString();
processingContext.getDefSetAnnotations().getGraphFactoryTypes().put(defSetClassName, fqcn);
// Definition Set's qualifier.
try {
Class<?> qualifierClass = definitionSetAnn.qualifier();
} catch (MirroredTypeException mte) {
mirror = mte.getTypeMirror();
}
if (null == mirror) {
throw new RuntimeException("No qualifier class specifyed for the @DefinitionSet.");
}
processingContext.getDefSetAnnotations().getQualifiers().put(defSetClassName, mirror.toString());
}
return true;
}
Aggregations