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
ConstructorDescriptionMethodModifierGrader
(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 TypeMethodDescriptionvoid
finalizeResults
(List<Result> results) Adds any results that cannot be computed until all visits are complete.void
Performs any setup before a call toSyntaxCheckGrader.grade(CompilationUnit)
.Methods inherited from class com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
grade, makeFailingResult, makeSuccessResult
Methods inherited from class com.spertus.jacquard.syntaxgrader.SyntaxGrader
getCallableSingleTarget
Methods 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. IfpenalizeMissingMethods
is true and a method is not found, aResult
will be created with a score of 0 and a maximum score ofmaxScorePerInstance
. Otherwise, noResult
will be created for missing methods.- Parameters:
name
- the name, which is used in theResult
maxScorePerInstance
- 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. IfpenalizeMissingMethods
is true and a method is not found, aResult
will be created with a score of 0 and a maximum score ofmaxScorePerInstance
. Otherwise, noResult
will 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:SyntaxCheckGrader
Performs any setup before a call toSyntaxCheckGrader.grade(CompilationUnit)
.- Overrides:
initialize
in classSyntaxCheckGrader
-
finalizeResults
Description copied from class:SyntaxCheckGrader
Adds any results that cannot be computed until all visits are complete.- Overrides:
finalizeResults
in classSyntaxCheckGrader
- Parameters:
results
- the list of results, which may be mutated by this call
-