Class CodeWarnings
java.lang.Object
org.springframework.beans.factory.aot.CodeWarnings
Helper class to register warnings that the compiler may trigger on
generated code.
- Since:
- 6.1
- Author:
- Stephane Nicoll
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondetectDeprecation
(AnnotatedElement... elements) Detect the presence ofDeprecated
on the specified elements.detectDeprecation
(Stream<AnnotatedElement> elements) Detect the presence ofDeprecated
on the specified elements.detectDeprecation
(ResolvableType resolvableType) Detect the presence ofDeprecated
on the signature of the specifiedResolvableType
.Return the currently registered warnings.void
Register a warning to be included for this block.protected void
Consume the builder forSuppressWarnings
if necessary.void
suppress
(org.springframework.javapoet.MethodSpec.Builder method) IncludeSuppressWarnings
on the specified method if necessary.void
suppress
(org.springframework.javapoet.TypeSpec.Builder type) IncludeSuppressWarnings
on the specified type if necessary.toString()
-
Constructor Details
-
CodeWarnings
public CodeWarnings()
-
-
Method Details
-
register
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
Detect the presence ofDeprecated
on the specified elements.- Parameters:
elements
- the elements to check- Returns:
this
instance
-
detectDeprecation
Detect the presence ofDeprecated
on the specified elements.- Parameters:
elements
- the elements to check- Returns:
this
instance
-
detectDeprecation
Detect the presence ofDeprecated
on the signature of the specifiedResolvableType
.- Parameters:
resolvableType
- a type signature- Returns:
this
instance- Since:
- 6.1.8
-
suppress
public void suppress(org.springframework.javapoet.MethodSpec.Builder method) IncludeSuppressWarnings
on the specified method if necessary.- Parameters:
method
- the method to update
-
suppress
public void suppress(org.springframework.javapoet.TypeSpec.Builder type) IncludeSuppressWarnings
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 forSuppressWarnings
if necessary. If this instance has no warnings registered, the consumer is not invoked.- Parameters:
annotationSpec
- a consumer of theAnnotationSpec.Builder
- See Also:
-
MethodSpec.Builder.addAnnotation(AnnotationSpec)
TypeSpec.Builder.addAnnotation(AnnotationSpec)
FieldSpec.Builder.addAnnotation(AnnotationSpec)
-
getWarnings
Return the currently registered warnings.- Returns:
- the warnings
-
toString
-