Search in sources :

Example 1 with PropValidator

use of com.axellience.vuegwt.core.annotations.component.PropValidator in project vue-gwt by Axellience.

the class ComponentJsTypeGenerator method processPropValidators.

/**
 * Process prop validators from the Component Class.
 * @param component {@link VueComponent} to process
 * @param optionsBuilder A {@link MethodSpec.Builder} for the method that creates the
 * {@link VueComponentOptions}
 */
private void processPropValidators(TypeElement component, MethodSpec.Builder optionsBuilder, Builder componentJsTypeBuilder) {
    getMethodsWithAnnotation(component, PropValidator.class).forEach(method -> {
        PropValidator propValidator = method.getAnnotation(PropValidator.class);
        if (!TypeName.get(method.getReturnType()).equals(TypeName.BOOLEAN)) {
            printError("Method " + method.getSimpleName() + " annotated with PropValidator must return a boolean.", component);
        }
        String propertyName = propValidator.value();
        optionsBuilder.addStatement("options.addJavaPropValidator($S, $S)", method.getSimpleName().toString(), propertyName);
        addProxyJsTypeMethodIfNecessary(componentJsTypeBuilder, method);
    });
}
Also used : PropValidator(com.axellience.vuegwt.core.annotations.component.PropValidator)

Aggregations

PropValidator (com.axellience.vuegwt.core.annotations.component.PropValidator)1