use of javax.lang.model.util.Elements in project blue by kunstmusik.
the class ProjectPluginEditorItemProcessor method handleProcess.
@Override
protected boolean handleProcess(Set<? extends TypeElement> set, RoundEnvironment env) throws LayerGenerationException {
Elements elements = processingEnv.getElementUtils();
for (Element e : env.getElementsAnnotatedWith(ProjectPluginEditorItem.class)) {
TypeElement clazz = (TypeElement) e;
String teName = elements.getBinaryName(clazz).toString();
ProjectPluginEditorItem ppePlugin = clazz.getAnnotation(ProjectPluginEditorItem.class);
File f = layer(e).file("blue/project/plugins/editors/" + teName.replace('.', '-') + ".instance").intvalue("position", ppePlugin.position()).bundlevalue("displayName", ppePlugin.displayName());
f.write();
}
return true;
}
use of javax.lang.model.util.Elements in project blue by kunstmusik.
the class SoundObjectPluginProcessor method handleProcess.
@Override
protected boolean handleProcess(Set<? extends TypeElement> set, RoundEnvironment env) throws LayerGenerationException {
Elements elements = processingEnv.getElementUtils();
for (Element e : env.getElementsAnnotatedWith(SoundObjectPlugin.class)) {
TypeElement clazz = (TypeElement) e;
SoundObjectPlugin sObjPlugin = clazz.getAnnotation(SoundObjectPlugin.class);
String teName = elements.getBinaryName(clazz).toString();
File f = layer(e).file("blue/score/soundObjects/" + teName.replace('.', '-') + ".instance").intvalue("position", sObjPlugin.position()).bundlevalue("displayName", sObjPlugin.displayName()).boolvalue("live", sObjPlugin.live());
f.write();
}
return true;
}
use of javax.lang.model.util.Elements in project blue by kunstmusik.
the class ProjectPluginItemProcessor method handleProcess.
@Override
protected boolean handleProcess(Set<? extends TypeElement> set, RoundEnvironment env) throws LayerGenerationException {
Elements elements = processingEnv.getElementUtils();
for (Element e : env.getElementsAnnotatedWith(ProjectPluginItem.class)) {
TypeElement clazz = (TypeElement) e;
String teName = elements.getBinaryName(clazz).toString();
ProjectPluginItem ppePlugin = clazz.getAnnotation(ProjectPluginItem.class);
File f = layer(e).file("blue/project/plugins/" + teName.replace('.', '-') + ".instance").intvalue("position", ppePlugin.position());
f.write();
}
return true;
}
use of javax.lang.model.util.Elements in project kripton by xcesco.
the class BindTypeBuilder method generate.
/**
* @return typeName of generated class
*
* @throws IOException
*/
public static String generate(Filer filer, BindEntity item) throws IOException {
Elements elementUtils = BaseProcessor.elementUtils;
String beanClassName = item.getSimpleName().toString();
boolean needSuffix = true;
if (beanClassName.endsWith(SUFFIX)) {
needSuffix = false;
}
String className = PREFIX + beanClassName + (needSuffix ? SUFFIX : "");
PackageElement pkg = elementUtils.getPackageOf(item.getElement());
String packageName = pkg.isUnnamed() ? "" : pkg.getQualifiedName().toString();
AnnotationProcessorUtilis.infoOnGeneratedClasses(BindType.class, packageName, className);
// @formatter:off
TypeSpec.Builder builder = TypeSpec.classBuilder(className).addAnnotation(AnnotationSpec.builder(BindMap.class).addMember("value", "$T.class", typeName(item.getElement().asType())).build()).addModifiers(Modifier.PUBLIC).superclass(TypeUtility.parameterizedTypeName(className(AbstractMapper.class), typeName(item.getElement().asType())));
BindTypeContext context = new BindTypeContext(builder, TypeUtility.typeName(packageName, className), Modifier.PRIVATE);
// @formatter:on
builder.addJavadoc("This class is binder map for $T\n\n", item.getElement());
JavadocUtility.generateJavadocGeneratedBy(builder);
builder.addJavadoc("@see $T\n", item.getElement());
// order item by order, property typeName
Collections.sort(item.getCollection(), new Comparator<BindProperty>() {
@Override
public int compare(BindProperty lhs, BindProperty rhs) {
int c1 = lhs.order - rhs.order;
if (c1 != 0)
return c1;
return lhs.getName().compareTo(rhs.getName());
}
});
// generate serializeOnJackson
generateSerializeOnJackson(context, item);
// generate serializeOnJacksonAsString
generateSerializeOnJacksonAsString(context, item);
// order item by type (attribute, element, value), order, xmlName
Collections.sort(item.getCollection(), new Comparator<BindProperty>() {
@Override
public int compare(BindProperty lhs, BindProperty rhs) {
int c1 = lhs.xmlInfo.xmlType.ordinal() - rhs.xmlInfo.xmlType.ordinal();
if (c1 != 0)
return c1;
c1 = lhs.order - rhs.order;
if (c1 != 0)
return c1;
return lhs.label.compareTo(rhs.label);
}
});
// generate serializeOnXml
generateSerializeOnXml(context, item);
// generate parseOnJackson
generateParseOnJackson(context, item);
// generate parseOnJacksonAsString
generateParseOnJacksonAsString(context, item);
// generate parseOnXml
generateParseOnXml(context, item);
TypeSpec typeSpec = builder.build();
JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);
return className;
}
use of javax.lang.model.util.Elements in project kripton by xcesco.
the class AnnotationUtility method extractAsInt.
public static int extractAsInt(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attributeName) {
final Elements elementUtils = BaseProcessor.elementUtils;
final One<Integer> result = new One<Integer>();
result.value0 = 0;
extractString(elementUtils, item, annotationClass, attributeName, new OnAttributeFoundListener() {
@Override
public void onFound(String value) {
result.value0 = Integer.parseInt(value);
}
});
return result.value0;
}
Aggregations