Top Description Fields Constructors Methods
org.springframework.beans.factory.aot

pack-priv Class CodeWarnings

extends Object
Class Inheritance
Imports
java.lang.reflect.AnnotatedElement, java.util.Collections, .LinkedHashSet, .Set, .StringJoiner, java.util.stream.Stream, org.springframework.javapoet.AnnotationSpec, .CodeBlock, .MethodSpec, org.springframework.lang.Nullable

Helper class to register warnings that the compiler may trigger on generated code.
Author
Stephane Nicoll
Since
6.1
See Also
SuppressWarnings

Field Summary

Modifier and TypeField and Description
private final Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private AnnotationSpec
public CodeWarnings

Returns:

this instance
detectDeprecation
(AnnotatedElement...
the elements to check
elements
)

Detect the presence of Deprecated on the specified elements.

public CodeWarnings

Returns:

this instance
detectDeprecation
(Stream<AnnotatedElement>
the elements to check
elements
)

Detect the presence of Deprecated on the specified elements.

private CodeBlock
protected Set<String>

Returns:

the warnings
getWarnings
()

Return the currently registered warnings.

public void
register(String
the warning to register, if it hasn't been already
warning
)

Register a warning to be included for this block.

private void
register(Deprecated annotation)

public void
suppress(MethodSpec.Builder
the method to update
method
)

Include SuppressWarnings on the specified method if necessary.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

warningsback to summary
private final Set<String> warnings

Constructor Detail

CodeWarningsback to summary
pack-priv CodeWarnings()

Method Detail

buildAnnotationSpecback to summary
private AnnotationSpec buildAnnotationSpec()
detectDeprecationback to summary
public CodeWarnings detectDeprecation(AnnotatedElement... elements)

Detect the presence of Deprecated on the specified elements.

Parameters
elements:AnnotatedElement[]

the elements to check

Returns:CodeWarnings

this instance

detectDeprecationback to summary
public CodeWarnings detectDeprecation(Stream<AnnotatedElement> elements)

Detect the presence of Deprecated on the specified elements.

Parameters
elements:Stream<AnnotatedElement>

the elements to check

Returns:CodeWarnings

this instance

generateValueCodeback to summary
private CodeBlock generateValueCode()
getWarningsback to summary
protected Set<String> getWarnings()

Return the currently registered warnings.

Returns:Set<String>

the warnings

registerback to summary
public void register(String warning)

Register a warning to be included for this block. Does nothing if the warning is already registered.

Parameters
warning:String

the warning to register, if it hasn't been already

registerback to summary
private void register(Deprecated annotation)
suppressback to summary
public void suppress(MethodSpec.Builder method)

Include SuppressWarnings on the specified method if necessary.

Parameters
method:MethodSpec.Builder

the method to update

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override