use of jsinterop.annotations.JsType in project vue-gwt by Axellience.
the class VueJsComponentFactoryGenerator method createInitMethod.
@Override
protected List<CodeBlock> createInitMethod(TypeElement component, Builder vueFactoryBuilder) {
JsType jsType = component.getAnnotation(JsType.class);
if (jsType == null || !jsType.isNative()) {
messager.printMessage(Kind.ERROR, component.asType().toString() + " @JsComponent must have a @JsType annotation with isNative to true");
return null;
}
if (!JsPackage.GLOBAL.equals(jsType.namespace())) {
messager.printMessage(Kind.ERROR, component.asType().toString() + " @JsType annotation on @JsComponent must have namespace set to JsPackage.GLOBAL");
return null;
}
JsComponent jsComponent = component.getAnnotation(JsComponent.class);
MethodSpec.Builder initBuilder = MethodSpec.methodBuilder("init").addModifiers(Modifier.PRIVATE);
if ("Function".equals(jsType.name())) {
initForComponentConstructor(jsComponent, initBuilder);
} else if ("Object".equals(jsType.name())) {
initForComponentOptions(jsComponent, initBuilder);
} else {
messager.printMessage(Kind.ERROR, component.asType().toString() + " @JsType annotation on @JsComponent must have name set to either Function or Object.");
}
vueFactoryBuilder.addMethod(initBuilder.build());
return new LinkedList<>();
}
Aggregations