Class FieldModifierGrader
java.lang.Object
com.spertus.jacquard.common.Grader
com.spertus.jacquard.syntaxgrader.SyntaxGrader
com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
com.spertus.jacquard.syntaxgrader.FieldModifierGrader
Checks whether the correct modifiers are used for fields (instance and
static variables/constants). For example, this could be used to verify
that certain instance variables are declared
private
or final
.-
Field Summary
Fields inherited from class com.spertus.jacquard.syntaxgrader.SyntaxCheckGrader
adapter, maxScorePerInstance
-
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)
.static FieldModifierGrader
makeChecker
(double maxScorePerInstance, List<String> varNames, List<com.github.javaparser.ast.Modifier> requiredModifiers, List<com.github.javaparser.ast.Modifier> optionalModifiers, boolean penalizeMissingFields) Creates a field modifier grader with a default name.static FieldModifierGrader
makeChecker
(String name, double maxScorePerInstance, List<String> varNames, List<com.github.javaparser.ast.Modifier> requiredModifiers, List<com.github.javaparser.ast.Modifier> optionalModifiers, boolean penalizeMissingFields) Creates a field modifier grader.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
-
Method Details
-
makeChecker
public static FieldModifierGrader makeChecker(String name, double maxScorePerInstance, List<String> varNames, List<com.github.javaparser.ast.Modifier> requiredModifiers, List<com.github.javaparser.ast.Modifier> optionalModifiers, boolean penalizeMissingFields) Creates a field modifier grader. IfpenalizeMissingFields
is true and a field is not found, aResult
will be created with a score of 0 and a maximum score ofmaxScorePerInstance
. Otherwise, noResult
will be created for missing fields.- Parameters:
name
- the namemaxScorePerInstance
- the maximum score for each variablevarNames
- the names of the variables to checkrequiredModifiers
- modifiers that must be used on each variableoptionalModifiers
- modifiers that may be used on variablespenalizeMissingFields
- whether to apply a penalty to missing fields- Returns:
- a new instance
-
makeChecker
public static FieldModifierGrader makeChecker(double maxScorePerInstance, List<String> varNames, List<com.github.javaparser.ast.Modifier> requiredModifiers, List<com.github.javaparser.ast.Modifier> optionalModifiers, boolean penalizeMissingFields) Creates a field modifier grader with a default name. IfpenalizeMissingFields
is true and a field is not found, aResult
will be created with a score of 0 and a maximum score ofmaxScorePerInstance
. Otherwise, noResult
will be created for missing fields.- Parameters:
maxScorePerInstance
- the maximum score for each variablevarNames
- the names of the variables to checkrequiredModifiers
- modifiers that must be used on each variableoptionalModifiers
- modifiers that may be used on variablespenalizeMissingFields
- whether to apply a penalty to missing fields- Returns:
- a new instance
-
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
-