Search in sources :

Example 1 with Computed

use of com.datastax.oss.driver.api.mapper.annotations.Computed in project java-driver by datastax.

the class DefaultEntityFactory method getComputedFormula.

private Optional<String> getComputedFormula(Map<Class<? extends Annotation>, Annotation> annotations, ExecutableElement getMethod, @Nullable VariableElement field) {
    Computed annotation = (Computed) annotations.get(Computed.class);
    if (annotation != null) {
        // ensure formula is non-empty
        String value = annotation.value();
        if (value.isEmpty()) {
            Element element = field != null && field.getAnnotation(Computed.class) != null ? field : getMethod;
            context.getMessager().error(element, "@Computed value should be non-empty.");
        }
        return Optional.of(value);
    }
    return Optional.empty();
}
Also used : VariableElement(javax.lang.model.element.VariableElement) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Element(javax.lang.model.element.Element) Computed(com.datastax.oss.driver.api.mapper.annotations.Computed)

Aggregations

Computed (com.datastax.oss.driver.api.mapper.annotations.Computed)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1