Class RequireThisCheck.ClassFrame
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.AbstractFrame
com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.ClassFrame
- Direct Known Subclasses:
RequireThisCheck.AnonymousClassFrame
- Enclosing class:
- RequireThisCheck
A frame initiated at class, enum or interface definition; holds instance variable names.
-
Field Summary
FieldsModifier and TypeFieldDescriptionSet of idents of instance members declared in this frame.Set of idents of instance methods declared in this frame.Set of idents of variables declared in this frame.Set of idents of static methods declared in this frame. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateClassFrame(RequireThisCheck.AbstractFrame parent, DetailAST ident) Creates new instance of ClassFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInstanceMember(DetailAST ident) Adds instance member's ident.voidaddInstanceMethod(DetailAST ident) Adds instance method's name.voidaddStaticMember(DetailAST ident) Adds static member's ident.voidaddStaticMethod(DetailAST ident) Adds static method's name.protected booleancontainsFieldOrVariable(DetailAST identToFind) Check whether the frame contains a field or a variable with the given name.private booleancontainsMethod(DetailAST methodToFind) Check whether the frame contains a given method.private static booleancontainsMethodDef(Set<DetailAST> set, DetailAST ident) Whether the set contains a method definition with the same name and number of parameters.protected RequireThisCheck.AbstractFramegetIfContains(DetailAST identToFind, boolean lookForMethod) Check whether the frame contains a given name.protected RequireThisCheck.FrameTypegetType()Get the type of the frame.booleanhasFinalField(DetailAST instanceMember) Checks whether given instance member has final modifier.booleanhasInstanceMember(DetailAST ident) Checks if a given name is a known instance member of the class.booleanhasInstanceMethod(DetailAST ident) Checks if a given name is a known instance method of the class.booleanhasStaticMethod(DetailAST ident) Checks if a given name is a known static method of the class.protected booleanisProperDefinition(DetailAST ident, DetailAST ast) Whether the definition is correspondent to the IDENT.private static booleanisSimilarSignature(DetailAST ident, DetailAST ast) Whether the method definition has the same name and number of parameters.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.AbstractFrame
containsFieldOrVariableDef, getFrameName, getFrameNameIdent, getParent
-
Field Details
-
instanceMembers
Set of idents of instance members declared in this frame. -
instanceMethods
Set of idents of instance methods declared in this frame. -
staticMembers
Set of idents of variables declared in this frame. -
staticMethods
Set of idents of static methods declared in this frame.
-
-
Constructor Details
-
ClassFrame
Creates new instance of ClassFrame.- Parameters:
parent- parent frame.ident- frame name ident.
-
-
Method Details
-
getType
Description copied from class:RequireThisCheck.AbstractFrameGet the type of the frame.- Specified by:
getTypein classRequireThisCheck.AbstractFrame- Returns:
- a FrameType.
-
addStaticMember
Adds static member's ident.- Parameters:
ident- an ident of static member of the class.
-
addStaticMethod
Adds static method's name.- Parameters:
ident- an ident of static method of the class.
-
addInstanceMember
Adds instance member's ident.- Parameters:
ident- an ident of instance member of the class.
-
addInstanceMethod
Adds instance method's name.- Parameters:
ident- an ident of instance method of the class.
-
hasInstanceMember
Checks if a given name is a known instance member of the class.- Parameters:
ident- the IDENT ast of the name to check.- Returns:
- true is the given name is a name of a known instance member of the class.
-
hasInstanceMethod
Checks if a given name is a known instance method of the class.- Parameters:
ident- the IDENT ast of the method call to check.- Returns:
- true if the given ast is correspondent to a known instance method of the class.
-
hasStaticMethod
Checks if a given name is a known static method of the class.- Parameters:
ident- the IDENT ast of the method call to check.- Returns:
- true is the given ast is correspondent to a known instance method of the class.
-
hasFinalField
Checks whether given instance member has final modifier.- Parameters:
instanceMember- an instance member of a class.- Returns:
- true if given instance member has final modifier.
-
containsFieldOrVariable
Description copied from class:RequireThisCheck.AbstractFrameCheck whether the frame contains a field or a variable with the given name.- Overrides:
containsFieldOrVariablein classRequireThisCheck.AbstractFrame- Parameters:
identToFind- the IDENT ast of the name we're looking for.- Returns:
- whether it was found.
-
isProperDefinition
Description copied from class:RequireThisCheck.AbstractFrameWhether the definition is correspondent to the IDENT.- Overrides:
isProperDefinitionin classRequireThisCheck.AbstractFrame- Parameters:
ident- the IDENT ast to check.ast- the IDENT ast of the definition to check.- Returns:
- true if ast is correspondent to ident.
-
getIfContains
protected RequireThisCheck.AbstractFrame getIfContains(DetailAST identToFind, boolean lookForMethod) Description copied from class:RequireThisCheck.AbstractFrameCheck whether the frame contains a given name.- Overrides:
getIfContainsin classRequireThisCheck.AbstractFrame- Parameters:
identToFind- IDENT ast of the name we're looking for.lookForMethod- whether we are looking for a method name.- Returns:
- whether it was found.
-
containsMethod
Check whether the frame contains a given method.- Parameters:
methodToFind- the AST of the method to find.- Returns:
- true, if a method with the same name and number of parameters is found.
-
containsMethodDef
Whether the set contains a method definition with the same name and number of parameters.- Parameters:
set- the set of definitions.ident- the specified method call IDENT ast.- Returns:
- true if the set contains a definition with the same name and number of parameters.
-
isSimilarSignature
Whether the method definition has the same name and number of parameters.- Parameters:
ident- the specified method call IDENT ast.ast- the ast of a method definition to compare with.- Returns:
- true if a method definition has the same name and number of parameters as the method call.
-