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 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).static FieldModifierGradermakeChecker(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 FieldModifierGradermakeChecker(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, 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
-
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. IfpenalizeMissingFieldsis true and a field is not found, aResultwill be created with a score of 0 and a maximum score ofmaxScorePerInstance. Otherwise, noResultwill 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. IfpenalizeMissingFieldsis true and a field is not found, aResultwill be created with a score of 0 and a maximum score ofmaxScorePerInstance. Otherwise, noResultwill 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: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
-