@Override
 public boolean processVariableElement(VariableElement field, DeclaredTypeName fieldType) {
   boolean isViewProperty = TypeConstants.isBasicPropertyType(fieldType);
   ViewQuery isViewQuery = field.getAnnotation(ViewQuery.class);
   Set<Modifier> modifiers = field.getModifiers();
   if (modifiers.containsAll(TypeConstants.PUBLIC_STATIC_FINAL)) {
     if (isViewQuery != null) {
       if (!TypeConstants.QUERY.equals(fieldType)) {
         utils
             .getMessager()
             .printMessage(
                 Diagnostic.Kind.ERROR,
                 "ViewQuery must be an instance of " + TypeConstants.QUERY.toString());
       } else if (modelSpec.hasMetadata(ViewModelSpecWrapper.METADATA_KEY_QUERY_ELEMENT)) {
         utils
             .getMessager()
             .printMessage(Diagnostic.Kind.ERROR, "Only one ViewQuery can be declared per spec");
       } else {
         modelSpec.putMetadata(ViewModelSpecWrapper.METADATA_KEY_VIEW_QUERY, isViewQuery);
         modelSpec.putMetadata(ViewModelSpecWrapper.METADATA_KEY_QUERY_ELEMENT, field);
       }
       return true;
     } else {
       return super.processVariableElement(field, fieldType);
     }
   } else if (isViewProperty) {
     utils
         .getMessager()
         .printMessage(
             Diagnostic.Kind.ERROR, "View properties must be public static final", field);
   }
   return false;
 }
Beispiel #2
0
 @Override
 protected void processVariableElement(VariableElement e, DeclaredTypeName typeName) {
   if (e.getAnnotation(Deprecated.class) != null) {
     return;
   }
   if (e.getAnnotation(ColumnSpec.class) != null) {
     utils
         .getMessager()
         .printMessage(Kind.WARNING, "ColumnSpec is ignored outside of table models", e);
   }
   boolean isViewProperty = TypeConstants.isPropertyType(typeName);
   ViewQuery isViewQuery = e.getAnnotation(ViewQuery.class);
   Set<Modifier> modifiers = e.getModifiers();
   if (modifiers.containsAll(TypeConstants.PUBLIC_STATIC_FINAL)) {
     if (isViewQuery != null) {
       if (!TypeConstants.QUERY.equals(typeName)) {
         utils
             .getMessager()
             .printMessage(
                 Kind.ERROR, "ViewQuery must be an instance of " + TypeConstants.QUERY.toString());
       } else if (queryElement != null) {
         utils.getMessager().printMessage(Kind.ERROR, "Only one ViewQuery per spec allowedd");
       } else {
         viewQueryAnnotation = isViewQuery;
         queryElement = e;
       }
     } else if (!isViewProperty) {
       constantElements.add(e);
     } else {
       initializePropertyGenerator(e);
     }
   } else if (isViewProperty) {
     utils
         .getMessager()
         .printMessage(Kind.ERROR, "View properties must be public static final", e);
   } else {
     utils.getMessager().printMessage(Kind.WARNING, "Unused field in spec", e);
   }
 }