Class RecordDeclarationValidator

    • Constructor Detail

      • RecordDeclarationValidator

        public RecordDeclarationValidator()
    • Method Detail

      • validateRecordComponentAccessorMethods

        private void validateRecordComponentAccessorMethods​(RecordDeclaration n,
                                                            ProblemReporter reporter)
        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 "";
             }