Class HandlerFactory
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.indentation.HandlerFactory
-
public class HandlerFactory extends java.lang.Object
Factory for handlers. Looks up constructor via reflection.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<DetailAST,AbstractExpressionHandler>createdHandlersCache for created method call handlers.private java.util.Map<java.lang.Integer,java.lang.reflect.Constructor<?>>typeHandlersRegistered handlers.
-
Constructor Summary
Constructors Constructor Description HandlerFactory()Creates a HandlerFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCreatedHandlers()Clears cache of created handlers.private AbstractExpressionHandlercreateMethodCallHandler(IndentationCheck indentCheck, DetailAST ast, AbstractExpressionHandler parent)Create new instance of handler for METHOD_CALL.int[]getHandledTypes()Gets list of registered handler types.AbstractExpressionHandlergetHandler(IndentationCheck indentCheck, DetailAST ast, AbstractExpressionHandler parent)Get the handler for an AST.booleanisHandledType(int type)Returns true if this type (form TokenTypes) is handled.private <T> voidregister(int type, java.lang.Class<T> handlerClass)Registers a handler.
-
-
-
Field Detail
-
typeHandlers
private final java.util.Map<java.lang.Integer,java.lang.reflect.Constructor<?>> typeHandlers
Registered handlers.
-
createdHandlers
private final java.util.Map<DetailAST,AbstractExpressionHandler> createdHandlers
Cache for created method call handlers.
-
-
Constructor Detail
-
HandlerFactory
public HandlerFactory()
Creates a HandlerFactory.
-
-
Method Detail
-
register
private <T> void register(int type, java.lang.Class<T> handlerClass)
Registers a handler.- Type Parameters:
T- type of the handler class object.- Parameters:
type- type from TokenTypeshandlerClass- the handler to register
-
isHandledType
public boolean isHandledType(int type)
Returns true if this type (form TokenTypes) is handled.- Parameters:
type- type from TokenTypes- Returns:
- true if handler is registered, false otherwise
-
getHandledTypes
public int[] getHandledTypes()
Gets list of registered handler types.- Returns:
- int[] of TokenType types
-
getHandler
public AbstractExpressionHandler getHandler(IndentationCheck indentCheck, DetailAST ast, AbstractExpressionHandler parent)
Get the handler for an AST.- Parameters:
indentCheck- the indentation checkast- ast to handleparent- the handler parent of this AST- Returns:
- the ExpressionHandler for ast
-
createMethodCallHandler
private AbstractExpressionHandler createMethodCallHandler(IndentationCheck indentCheck, DetailAST ast, AbstractExpressionHandler parent)
Create new instance of handler for METHOD_CALL.- Parameters:
indentCheck- the indentation checkast- ast to handleparent- the handler parent of this AST- Returns:
- new instance.
-
clearCreatedHandlers
public void clearCreatedHandlers()
Clears cache of created handlers.
-
-