Class MethodModifierGrader


public final class MethodModifierGrader extends SyntaxCheckGrader
Checks whether the correct modifiers are used for methods (instance and static). For example, this could be used to verify that certain methods are declared public or static.
  • Constructor Details

    • MethodModifierGrader

      public MethodModifierGrader(String name, double maxScorePerInstance, List<String> methodNames, List<com.github.javaparser.ast.Modifier> requiredModifiers, List<com.github.javaparser.ast.Modifier> optionalModifiers, boolean penalizeMissingMethods)
      Creates a method modifier grader. If penalizeMissingMethods is true and a method is not found, a Result will be created with a score of 0 and a maximum score of maxScorePerInstance. Otherwise, no Result will be created for missing methods.
      Parameters:
      name - the name, which is used in the Result
      maxScorePerInstance - the maximum score for each method
      methodNames - the names of the methods to check
      requiredModifiers - modifiers that must be used on each method
      optionalModifiers - modifiers that may be used on methods
      penalizeMissingMethods - whether to apply a penalty to missing methods
    • MethodModifierGrader

      public MethodModifierGrader(double maxScorePerInstance, List<String> varNames, List<com.github.javaparser.ast.Modifier> requiredModifiers, List<com.github.javaparser.ast.Modifier> optionalModifiers, boolean penalizeMissingMethods)
      Creates a method modifier checker with a default name. If penalizeMissingMethods is true and a method is not found, a Result will be created with a score of 0 and a maximum score of maxScorePerInstance. Otherwise, no Result will be created for missing methods.
      Parameters:
      maxScorePerInstance - the maximum score for each method
      varNames - the names of the methods to check
      requiredModifiers - modifiers that must be used on each method
      optionalModifiers - modifiers that may be used on methods
      penalizeMissingMethods - whether to apply a penalty to missing methods
  • Method Details