Class RecordDeclarationValidator
java.lang.Object
com.github.javaparser.ast.validator.language_level_validations.chunks.RecordDeclarationValidator
- All Implemented Interfaces:
TypedValidator<RecordDeclaration>
,BiConsumer<RecordDeclaration,
ProblemReporter>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(RecordDeclaration node, ProblemReporter reporter) private void
forbidAbstractModifier
(RecordDeclaration n, ProblemReporter reporter) private void
private void
Given this sample record example:Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.function.BiConsumer
andThen
Methods inherited from interface com.github.javaparser.ast.validator.TypedValidator
processor
-
Constructor Details
-
RecordDeclarationValidator
public RecordDeclarationValidator()
-
-
Method Details
-
accept
- Specified by:
accept
in interfaceBiConsumer<RecordDeclaration,
ProblemReporter> - Specified by:
accept
in interfaceTypedValidator<RecordDeclaration>
- Parameters:
node
- the node that wants to be validatedreporter
- when found, validation errors can be reported here
-
forbidAbstractModifier
-
forbidNonStaticFieldsInRecords
-
validateRecordComponentAccessorMethods
Given this sample record example:record ABC(int x, int y) { }
Permitted - shadows int x (matches name and return type)
public int x() { return x; }
Forbidden - shadows int x, but has a type mismatch (String vs int).
public String x() { return ""; }
Permitted - shadows int x, but not considered a component accessor due to presence of parameter.
public String x(int a) { return ""; }
-