use of com.axellience.vuegwt.core.annotations.component.Prop in project vue-gwt by Axellience.
the class ComponentTemplateProcessor method processLocalComponentClass.
/**
* Register the local component and all of its {@link Prop}.
* This will be used for type validation.
* @param localComponents The {@link LocalComponents} object where we should register our {@link LocalComponent}
* @param localComponentType The class to process
*/
private void processLocalComponentClass(LocalComponents localComponents, TypeElement localComponentType) {
Component componentAnnotation = localComponentType.getAnnotation(Component.class);
String localComponentTagName = componentToTagName(localComponentType.getSimpleName().toString(), componentAnnotation);
if (localComponents.hasLocalComponent(localComponentTagName))
return;
LocalComponent localComponent = localComponents.addLocalComponent(localComponentTagName);
ElementFilter.fieldsIn(localComponentType.getEnclosedElements()).forEach(field -> {
Prop propAnnotation = field.getAnnotation(Prop.class);
if (propAnnotation != null) {
localComponent.addProp(field.getSimpleName().toString(), TypeName.get(field.asType()), propAnnotation.required());
}
});
}
use of com.axellience.vuegwt.core.annotations.component.Prop in project vue-gwt by Axellience.
the class ComponentJsTypeGenerator method processProps.
/**
* Process Vue Props from the {@link VueComponent} Class.
* @param component {@link VueComponent} to process
* @param optionsBuilder A {@link MethodSpec.Builder} for the method that creates the
* {@link VueComponentOptions}
*/
private void processProps(TypeElement component, MethodSpec.Builder optionsBuilder) {
ElementFilter.fieldsIn(component.getEnclosedElements()).stream().filter(field -> hasAnnotation(field, Prop.class)).forEach(field -> {
String fieldName = field.getSimpleName().toString();
Prop prop = field.getAnnotation(Prop.class);
if (!isFieldVisibleInJS(field)) {
printError("The field \"" + fieldName + "\" annotated with @Prop must also be annotated with @JsProperty.", component);
}
optionsBuilder.addStatement("options.addJavaProp($S, $L, $S)", fieldName, prop.required(), prop.checkType() ? getNativeNameForJavaType(field.asType()) : null);
});
}
Aggregations