Class CodeWarnings

java.lang.Object
org.springframework.beans.factory.aot.CodeWarnings

public class CodeWarnings extends Object
Helper class to register warnings that the compiler may trigger on generated code.
Since:
6.1
Author:
Stephane Nicoll
See Also:
  • Constructor Details

    • CodeWarnings

      public CodeWarnings()
  • Method Details

    • register

      public void register(String warning)
      Register a warning to be included for this block. Does nothing if the warning is already registered.
      Parameters:
      warning - the warning to register, if it hasn't been already
    • detectDeprecation

      public CodeWarnings detectDeprecation(AnnotatedElement... elements)
      Detect the presence of Deprecated on the specified elements.
      Parameters:
      elements - the elements to check
      Returns:
      this instance
    • detectDeprecation

      public CodeWarnings detectDeprecation(Stream<AnnotatedElement> elements)
      Detect the presence of Deprecated on the specified elements.
      Parameters:
      elements - the elements to check
      Returns:
      this instance
    • detectDeprecation

      public CodeWarnings detectDeprecation(ResolvableType resolvableType)
      Detect the presence of Deprecated on the signature of the specified ResolvableType.
      Parameters:
      resolvableType - a type signature
      Returns:
      this instance
    • suppress

      public void suppress(org.springframework.javapoet.MethodSpec.Builder method)
      Include SuppressWarnings on the specified method if necessary.
      Parameters:
      method - the method to update
    • suppress

      public void suppress(org.springframework.javapoet.TypeSpec.Builder type)
      Include SuppressWarnings on the specified type if necessary.
      Parameters:
      type - the type to update
    • suppress

      protected void suppress(Consumer<org.springframework.javapoet.AnnotationSpec.Builder> annotationSpec)
      Consume the builder for SuppressWarnings if necessary. If this instance has no warnings registered, the consumer is not invoked.
      Parameters:
      annotationSpec - a consumer of the AnnotationSpec.Builder
      See Also:
      • MethodSpec.Builder.addAnnotation(AnnotationSpec)
      • TypeSpec.Builder.addAnnotation(AnnotationSpec)
      • FieldSpec.Builder.addAnnotation(AnnotationSpec)
    • getWarnings

      protected Set<String> getWarnings()
      Return the currently registered warnings.
      Returns:
      the warnings
    • toString

      public String toString()
      Overrides:
      toString in class Object