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
private static class RequireThisCheck.ClassFrame extends RequireThisCheck.AbstractFrame
A frame initiated at class, enum or interface definition; holds instance variable names.
-
-
Field Summary
Fields Modifier and Type Field Description private Set<DetailAST>
instanceMembers
Set of idents of instance members declared in this frame.private Set<DetailAST>
instanceMethods
Set of idents of instance methods declared in this frame.private Set<DetailAST>
staticMembers
Set of idents of variables declared in this frame.private Set<DetailAST>
staticMethods
Set of idents of static methods declared in this frame.
-
Constructor Summary
Constructors Modifier Constructor Description private
ClassFrame(RequireThisCheck.AbstractFrame parent, DetailAST ident)
Creates new instance of ClassFrame.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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 Detail
-
instanceMembers
private final Set<DetailAST> instanceMembers
Set of idents of instance members declared in this frame.
-
instanceMethods
private final Set<DetailAST> instanceMethods
Set of idents of instance methods declared in this frame.
-
staticMembers
private final Set<DetailAST> staticMembers
Set of idents of variables declared in this frame.
-
staticMethods
private final Set<DetailAST> staticMethods
Set of idents of static methods declared in this frame.
-
-
Constructor Detail
-
ClassFrame
private ClassFrame(RequireThisCheck.AbstractFrame parent, DetailAST ident)
Creates new instance of ClassFrame.- Parameters:
parent
- parent frame.ident
- frame name ident.
-
-
Method Detail
-
getType
protected RequireThisCheck.FrameType getType()
Description copied from class:RequireThisCheck.AbstractFrame
Get the type of the frame.- Specified by:
getType
in classRequireThisCheck.AbstractFrame
- Returns:
- a FrameType.
-
addStaticMember
public void addStaticMember(DetailAST ident)
Adds static member's ident.- Parameters:
ident
- an ident of static member of the class.
-
addStaticMethod
public void addStaticMethod(DetailAST ident)
Adds static method's name.- Parameters:
ident
- an ident of static method of the class.
-
addInstanceMember
public void addInstanceMember(DetailAST ident)
Adds instance member's ident.- Parameters:
ident
- an ident of instance member of the class.
-
addInstanceMethod
public void addInstanceMethod(DetailAST ident)
Adds instance method's name.- Parameters:
ident
- an ident of instance method of the class.
-
hasInstanceMember
public boolean hasInstanceMember(DetailAST ident)
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
public boolean hasInstanceMethod(DetailAST ident)
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
public boolean hasStaticMethod(DetailAST ident)
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
public boolean hasFinalField(DetailAST instanceMember)
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
protected boolean containsFieldOrVariable(DetailAST identToFind)
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
protected boolean isProperDefinition(DetailAST ident, DetailAST ast)
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
private boolean containsMethod(DetailAST methodToFind)
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
private static boolean containsMethodDef(Set<DetailAST> set, DetailAST ident)
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
private static boolean isSimilarSignature(DetailAST ident, DetailAST ast)
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.
-
-