java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.model.processor.ModelHandlerBase
ch.qos.logback.tyler.base.handler.IfModelHandler
- All Implemented Interfaces:
ch.qos.logback.core.spi.ContextAware
Handler responsible for processing IfModel instances encountered during model interpretation.
This handler pushes the IfModel onto the interpretation stack, validates the condition string and emits the corresponding Java "if" control flow into the Tyler configuration method being built (via MethodSpec).
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
ConstructorsConstructorDescriptionIfModelHandler(ch.qos.logback.core.Context context) Create a new IfModelHandler. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddJavaStatement(TylerModelInterpretationContext tmic, String conditionStr) Emit the Java "if" control flow for the given condition into the supplied TylerModelInterpretationContext's MethodSpec builder.protected Class<ch.qos.logback.core.model.conditional.IfModel> Return the model class that this handler supports.voidhandle(ch.qos.logback.core.model.processor.ModelInterpretationContext mic, ch.qos.logback.core.model.Model model) Handle anIfModelby validating its condition and emitting the corresponding Java "if" statement into the Tyler method spec builder.static ch.qos.logback.core.model.processor.ModelHandlerBasemakeInstance(ch.qos.logback.core.Context context, ch.qos.logback.core.model.processor.ModelInterpretationContext ic) Factory method used by the model processing infrastructure.voidpostHandle(ch.qos.logback.core.model.processor.ModelInterpretationContext mic, ch.qos.logback.core.model.Model model) Finalize handling of theIfModel: verify the model stack, end the emitted control flow and pop the model from the stack.Methods inherited from class ch.qos.logback.core.model.processor.ModelHandlerBase
isSupportedModelType, toStringMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Constructor Details
-
IfModelHandler
Create a new IfModelHandler.- Parameters:
context- the Logback context used for this handler
-
-
Method Details
-
makeInstance
public static ch.qos.logback.core.model.processor.ModelHandlerBase makeInstance(ch.qos.logback.core.Context context, ch.qos.logback.core.model.processor.ModelInterpretationContext ic) Factory method used by the model processing infrastructure.- Parameters:
context- the Logback contextic- the current ModelInterpretationContext (unused by this factory)- Returns:
- a new instance of IfModelHandler
-
getSupportedModelClass
Return the model class that this handler supports.- Overrides:
getSupportedModelClassin classch.qos.logback.core.model.processor.ModelHandlerBase- Returns:
- the supported model class (IfModel.class)
-
handle
public void handle(ch.qos.logback.core.model.processor.ModelInterpretationContext mic, ch.qos.logback.core.model.Model model) throws ch.qos.logback.core.model.processor.ModelHandlerException Handle anIfModelby validating its condition and emitting the corresponding Java "if" statement into the Tyler method spec builder.- Specified by:
handlein classch.qos.logback.core.model.processor.ModelHandlerBase- Parameters:
mic- the model interpretation contextmodel- the model to handle (expected to beIfModel)- Throws:
ch.qos.logback.core.model.processor.ModelHandlerException- if an error occurs while handling the model
-
addJavaStatement
Emit the Java "if" control flow for the given condition into the supplied TylerModelInterpretationContext's MethodSpec builder.- Parameters:
tmic- the Tyler model interpretation context containing the MethodSpec builderconditionStr- the Java expression to use as the if condition
-
postHandle
public void postHandle(ch.qos.logback.core.model.processor.ModelInterpretationContext mic, ch.qos.logback.core.model.Model model) Finalize handling of theIfModel: verify the model stack, end the emitted control flow and pop the model from the stack.- Overrides:
postHandlein classch.qos.logback.core.model.processor.ModelHandlerBase- Parameters:
mic- the model interpretation contextmodel- the model that was handled
-