eric-maynard commented on code in PR #1170:
URL: https://github.com/apache/polaris/pull/1170#discussion_r2002452496


##########
polaris-core/src/main/java/org/apache/polaris/core/config/BehaviorChangeProcessor.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.config;
+
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.Elements;
+import javax.tools.Diagnostic;
+
+@SupportedAnnotationTypes("BehaviorChange")
+@SupportedSourceVersion(SourceVersion.RELEASE_8)
+public class BehaviorChangeProcessor extends AbstractProcessor {
+
+  @Override
+  public boolean process(Set<? extends TypeElement> annotations, 
RoundEnvironment roundEnv) {
+
+    Elements elementUtils = processingEnv.getElementUtils();
+
+    for (Element element : roundEnv.getRootElements()) {
+      if (element.getKind() == ElementKind.CLASS) {
+        TypeElement typeElement = (TypeElement) element;
+        for (Element enclosedElement : typeElement.getEnclosedElements()) {
+          if (enclosedElement.getKind() == ElementKind.FIELD) {
+            VariableElement field = (VariableElement) enclosedElement;
+            TypeMirror fieldType = field.asType();
+
+            if (isBehaviorChangeConfiguration(fieldType, elementUtils)) {
+              if (field.getAnnotation(BehaviorChange.class) == null) {
+                processingEnv
+                    .getMessager()
+                    .printMessage(
+                        Diagnostic.Kind.ERROR,
+                        "Field "
+                            + field.getSimpleName()
+                            + " of type BehaviorChangeConfiguration<?> must be 
annotated with @BehaviorChange",
+                        field);
+              } else {
+                processingEnv
+                    .getMessager()
+                    .printMessage(
+                        Diagnostic.Kind.NOTE,
+                        "Field "
+                            + field.getSimpleName()
+                            + " is correctly annotated with @BehaviorChange",

Review Comment:
   I think it's not, but I noticed the processor isn't working so I added this 
to debug -- see my comment 
[here](https://github.com/apache/polaris/pull/1170#discussion_r1996520922). If 
you have any tips on fixing this, that would be awesome. I think the annotation 
processor is a good suggestion



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to