use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class GenerationTools method resolveAnnotationType.
public String resolveAnnotationType(Annotation annotation) {
StringBuffer type = new StringBuffer();
AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();
if (annotationDefinition == null) {
logger.warn("Annotation definition for annotation: " + annotation + " is not defined.");
return type.toString();
}
if (annotationDefinition.isMarker()) {
return type.toString();
}
// finally we can process annotation members.
Object memberValue;
int memberCount = 0;
for (AnnotationValuePairDefinition memberDefinition : annotationDefinition.getValuePairs()) {
if ((memberValue = annotation.getValue(memberDefinition.getName())) != null) {
// a value has been set for this member.
if (memberCount == 0) {
type.append("(");
}
if (memberCount > 0) {
type.append(", ");
}
type.append(resolveMemberType(memberDefinition, memberValue));
memberCount++;
}
}
if (memberCount > 0) {
type.append(")");
}
return type.toString();
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class NumericValuePairEditorBaseTest method createEditor.
protected NumericValuePairEditor createEditor(NumberType numberType, String paramName) {
NumericValuePairEditor numericEditor = new NumericValuePairEditor(singleEditorView);
AnnotationDefinition annotationDefinition = createAnnotationDefinition(numberType);
AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair(paramName);
numericEditor.init(valuePairDefinition);
return numericEditor;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method createAnnotation.
private Annotation createAnnotation(AnnotationSource annotationToken, ClassTypeResolver classTypeResolver) throws ModelDriverException {
AnnotationDefinition annotationDefinition;
Annotation annotation = null;
annotationDefinition = buildAnnotationDefinition(annotationToken, classTypeResolver);
if (annotationDefinition != null) {
AnnotationDriver annotationDriver = new DefaultJavaRoasterModelAnnotationDriver();
annotation = annotationDriver.buildAnnotation(annotationDefinition, annotationToken);
} else {
logger.warn("Annotation: " + annotationToken.getName() + " is not configured for this ModelDriver driver.");
}
return annotation;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method addAnnotation.
public AnnotationSource<?> addAnnotation(AnnotationTargetSource annotationTargetSource, Annotation annotation) {
AnnotationSource<?> newAnnotationSource = annotationTargetSource.addAnnotation();
newAnnotationSource.setName(annotation.getClassName());
AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();
if (!annotationDefinition.isMarker()) {
for (AnnotationValuePairDefinition memberDefinition : annotationDefinition.getValuePairs()) {
Object value = annotation.getValue(memberDefinition.getName());
if (value != null) {
addMemberValue(newAnnotationSource, memberDefinition, value);
}
}
}
return newAnnotationSource;
}
use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.
the class DefaultJavaRoasterModelAnnotationDriver method parseAnnotationValue.
private Object parseAnnotationValue(AnnotationSource javaAnnotationToken, AnnotationValuePairDefinition valuePairDefinition) throws ModelDriverException {
String value = javaAnnotationToken.getLiteralValue(valuePairDefinition.getName());
AnnotationDefinition annotationDefinition = valuePairDefinition.getAnnotationDefinition();
Object result = null;
if (value == null)
return null;
if (annotationDefinition == null) {
return value;
}
if (valuePairDefinition.isArray()) {
AnnotationSource[] javaAnnotationTokenValueArray = javaAnnotationToken.getAnnotationArrayValue(valuePairDefinition.getName());
List<Annotation> annotationList = new ArrayList<Annotation>();
Annotation annotation;
if (javaAnnotationTokenValueArray != null) {
for (int i = 0; i < javaAnnotationTokenValueArray.length; i++) {
annotation = buildAnnotation(annotationDefinition, javaAnnotationTokenValueArray[i]);
if (annotation != null) {
annotationList.add(annotation);
}
}
}
result = annotationList.size() > 0 ? annotationList : null;
} else {
AnnotationSource javaAnnotationTokenValue = javaAnnotationToken.getAnnotationValue(valuePairDefinition.getName());
if (javaAnnotationTokenValue != null) {
result = buildAnnotation(annotationDefinition, javaAnnotationTokenValue);
}
}
return result;
}
Aggregations