Class PropertyConditionBase
- All Implemented Interfaces:
PropertyCondition,Condition,ContextAware,LifeCycle
- Direct Known Subclasses:
ExpressionPropertyCondition,IsPropertyDefinedCondition,IsPropertyNullCondition,PropertyEqualityCondition
Abstract base class provides some scaffolding. It is intended to ease migration from legacy conditional processing in configuration files (e.g. <if>, <then>, <else>) using the Janino library. Nevertheless, it should also be useful in newly written code.
Properties are looked up in the following order:
- In the local property container, usually the
ModelInterpretationContext - in the logger context
- system properties
- environment variables
- Since:
- 1.5.20
- Author:
- Ceki Gülcü
- See Also:
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the local property container used by this evaluator.booleanChecks if the property with the given key is defined (not null).booleanChecks if the property with the given key is null.booleanChecks if this evaluator has been started.Retrieves the property value for the given key, returning an empty string if null.Retrieves the property value for the given key, returning an empty string if null.booleanpropertyContains(String k, String inclusion) Determine whether the resolved property value contains the given substring.booleanpropertyEquals(String propertyKey, String value) Compare the resolved property value with the provided expected value.voidsetLocalPropertyContainer(PropertyContainer aLocalPropertyContainer) Sets the local property container for this evaluator.voidstart()Starts this evaluator.voidstop()Stops this evaluator.Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
PropertyConditionBase
public PropertyConditionBase()
-
-
Method Details
-
getLocalPropertyContainer
Returns the local property container used by this evaluator.Local properties correspond to the properties in the embedding configurator, i.e. usually the
ModelInterpretationContextinstance.- Specified by:
getLocalPropertyContainerin interfacePropertyCondition- Returns:
- the local property container
-
setLocalPropertyContainer
Sets the local property container for this evaluator.Local properties correspond to the properties in the embedding configurator, i.e. usually the
ModelInterpretationContextinstance.- Specified by:
setLocalPropertyContainerin interfacePropertyCondition- Parameters:
aLocalPropertyContainer- the local property container to set
-
isNull
Checks if the property with the given key is null.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.- Parameters:
k- the property key- Returns:
- true if the property is null, false otherwise
-
isDefined
Checks if the property with the given key is defined (not null).The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.- Parameters:
k- the property key- Returns:
- true if the property is defined, false otherwise
-
p
Retrieves the property value for the given key, returning an empty string if null. This is a shorthand forproperty(String).- Parameters:
k- the property key- Returns:
- the property value or an empty string
-
property
Retrieves the property value for the given key, returning an empty string if null.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.- Parameters:
k- the property key- Returns:
- the property value or an empty string
-
propertyEquals
Compare the resolved property value with the provided expected value.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.Returns
trueif the resolved property value is equal tovalaccording toString.equals(Object). If the resolved property value orvalis null, then false is returned.- Parameters:
propertyKey- the property key to look upvalue- expected string value to compare against; must be non-null- Returns:
trueif the resolved property equalsvalue,falseotherwise or if either the resolved property orvalueis null.- Since:
- 1.5.24
-
propertyContains
Determine whether the resolved property value contains the given substring.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.This method returns
trueif the resolved property value'sString.contains(CharSequence)returnstruefor the suppliedinclusion. False is returned if either the resolved property value orinclusionparameter is null.- Parameters:
k- the property key to look upinclusion- substring to search for in the resolved property value; must be non-null- Returns:
trueif the property value containsinclusion, false otherwise or if either the resolved property value orinclusionis null- Since:
- 1.5.24
-
isStarted
-
start
-
stop
-