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
ConstructorsModifierConstructorDescriptionprivate
ClassFrame
(RequireThisCheck.AbstractFrame parent, DetailAST ident) Creates new instance of ClassFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInstanceMember
(DetailAST ident) Adds instance member's ident.void
addInstanceMethod
(DetailAST ident) Adds instance method's name.void
addStaticMember
(DetailAST ident) Adds static member's ident.void
addStaticMethod
(DetailAST ident) Adds static method's name.protected boolean
containsFieldOrVariable
(DetailAST identToFind) Check whether the frame contains a field or a variable with the given name.private boolean
containsMethod
(DetailAST methodToFind) Check whether the frame contains a given method.private static boolean
containsMethodDef
(Set<DetailAST> set, DetailAST ident) Whether the set contains a method definition with the same name and number of parameters.protected RequireThisCheck.AbstractFrame
getIfContains
(DetailAST identToFind, boolean lookForMethod) Check whether the frame contains a given name.protected RequireThisCheck.FrameType
getType()
Get the type of the frame.boolean
hasFinalField
(DetailAST instanceMember) Checks whether given instance member has final modifier.boolean
hasInstanceMember
(DetailAST ident) Checks if a given name is a known instance member of the class.boolean
hasInstanceMethod
(DetailAST ident) Checks if a given name is a known instance method of the class.boolean
hasStaticMethod
(DetailAST ident) Checks if a given name is a known static method of the class.protected boolean
isProperDefinition
(DetailAST ident, DetailAST ast) Whether the definition is correspondent to the IDENT.private static boolean
isSimilarSignature
(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.AbstractFrame
Get the type of the frame.- Specified by:
getType
in 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.AbstractFrame
Check whether the frame contains a field or a variable with the given name.- Overrides:
containsFieldOrVariable
in 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.AbstractFrame
Whether the definition is correspondent to the IDENT.- Overrides:
isProperDefinition
in 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.AbstractFrame
Check whether the frame contains a given name.- Overrides:
getIfContains
in 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.
-