Class MethodModifierGrader
java.lang.Object
com.spertus.jacquard.common.Grader
com.spertus.jacquard.syntaxgrader.SyntaxGrader
com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
com.spertus.jacquard.syntaxgrader.MethodModifierGrader
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.-
Field Summary
Fields inherited from class com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
adapter, maxScorePerInstance -
Constructor Summary
ConstructorsConstructorDescriptionMethodModifierGrader(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.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. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalizeResults(List<Result> results) Adds any results that cannot be computed until all visits are complete.voidPerforms any setup before a call toSyntaxCheckGrader.grade(CompilationUnit).Methods inherited from class com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
grade, makeFailingResult, makeSuccessResultMethods inherited from class com.spertus.jacquard.syntaxgrader.SyntaxGrader
getCallableSingleTargetMethods inherited from class com.spertus.jacquard.common.Grader
getCallableMultiTarget, grade, grade, gradeAll, makeExceptionResult, makeExceptionResultList, makeFailureResult, makeFailureResultList, makePartialCreditResult, makeSuccessResult, makeSuccessResultList
-
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. IfpenalizeMissingMethodsis true and a method is not found, aResultwill be created with a score of 0 and a maximum score ofmaxScorePerInstance. Otherwise, noResultwill be created for missing methods.- Parameters:
name- the name, which is used in theResultmaxScorePerInstance- the maximum score for each methodmethodNames- the names of the methods to checkrequiredModifiers- modifiers that must be used on each methodoptionalModifiers- modifiers that may be used on methodspenalizeMissingMethods- 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. IfpenalizeMissingMethodsis true and a method is not found, aResultwill be created with a score of 0 and a maximum score ofmaxScorePerInstance. Otherwise, noResultwill be created for missing methods.- Parameters:
maxScorePerInstance- the maximum score for each methodvarNames- the names of the methods to checkrequiredModifiers- modifiers that must be used on each methodoptionalModifiers- modifiers that may be used on methodspenalizeMissingMethods- whether to apply a penalty to missing methods
-
-
Method Details
-
initialize
public void initialize()Description copied from class:SyntaxCheckGraderPerforms any setup before a call toSyntaxCheckGrader.grade(CompilationUnit).- Overrides:
initializein classSyntaxCheckGrader
-
finalizeResults
Description copied from class:SyntaxCheckGraderAdds any results that cannot be computed until all visits are complete.- Overrides:
finalizeResultsin classSyntaxCheckGrader- Parameters:
results- the list of results, which may be mutated by this call
-