Class DefaultEnforcementRuleHelper
- java.lang.Object
-
- org.apache.maven.plugins.enforcer.internal.DefaultEnforcementRuleHelper
-
- All Implemented Interfaces:
EnforcerRuleHelper
,org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
public class DefaultEnforcementRuleHelper extends java.lang.Object implements EnforcerRuleHelper
Default implementation of the EnforcementRuleHelper interface. This is used to help retrieve information from the session and provide useful elements like the log.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Object>
cache
A cache.private org.codehaus.plexus.PlexusContainer
container
The container.private org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
evaluator
The evaluator.private org.apache.maven.plugin.logging.Log
log
The log.
-
Constructor Summary
Constructors Constructor Description DefaultEnforcementRuleHelper(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator evaluator, org.apache.maven.plugin.logging.Log log, org.codehaus.plexus.PlexusContainer container)
Instantiates a new default enforcement rule helper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.File
alignToBaseDirectory(java.io.File theFile)
java.lang.Object
evaluate(java.lang.String theExpression)
java.lang.Object
getCache(java.lang.String key, java.util.function.Supplier<?> producer)
Gets a cached value, or uses the provided producer to compute it.<T> T
getComponent(java.lang.Class<T> clazz)
Gets the component.<T> T
getComponent(java.lang.Class<T> clazz, java.lang.String roleHint)
Gets the component.java.lang.Object
getComponent(java.lang.String theComponentKey)
Gets the component.java.lang.Object
getComponent(java.lang.String theRole, java.lang.String theRoleHint)
Gets the component.java.util.List<java.lang.Object>
getComponentList(java.lang.String theRole)
Gets the component list.java.util.Map<java.lang.String,java.lang.Object>
getComponentMap(java.lang.String theRole)
Gets the component map.org.codehaus.plexus.PlexusContainer
getContainer()
Gets the container.org.apache.maven.plugin.logging.Log
getLog()
Gets the log.
-
-
-
Field Detail
-
log
private org.apache.maven.plugin.logging.Log log
The log.
-
evaluator
private org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator evaluator
The evaluator.
-
container
private org.codehaus.plexus.PlexusContainer container
The container.
-
cache
private java.util.Map<java.lang.String,java.lang.Object> cache
A cache.
-
-
Constructor Detail
-
DefaultEnforcementRuleHelper
public DefaultEnforcementRuleHelper(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator evaluator, org.apache.maven.plugin.logging.Log log, org.codehaus.plexus.PlexusContainer container)
Instantiates a new default enforcement rule helper.- Parameters:
session
- the sessionevaluator
- the evaluatorlog
- the logcontainer
- the container
-
-
Method Detail
-
getLog
public org.apache.maven.plugin.logging.Log getLog()
Description copied from interface:EnforcerRuleHelper
Gets the log.- Specified by:
getLog
in interfaceEnforcerRuleHelper
- Returns:
- the log
-
alignToBaseDirectory
public java.io.File alignToBaseDirectory(java.io.File theFile)
- Specified by:
alignToBaseDirectory
in interfaceorg.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
-
evaluate
public java.lang.Object evaluate(java.lang.String theExpression) throws org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException
- Specified by:
evaluate
in interfaceorg.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
- Throws:
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException
-
getComponent
public <T> T getComponent(java.lang.Class<T> clazz) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
Description copied from interface:EnforcerRuleHelper
Gets the component.- Specified by:
getComponent
in interfaceEnforcerRuleHelper
- Type Parameters:
T
- a class type- Parameters:
clazz
- the clazz- Returns:
- the component
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
- the component lookup exception
-
getComponent
public java.lang.Object getComponent(java.lang.String theComponentKey) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
Description copied from interface:EnforcerRuleHelper
Gets the component.- Specified by:
getComponent
in interfaceEnforcerRuleHelper
- Parameters:
theComponentKey
- the component key- Returns:
- the component
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
- the component lookup exception
-
getComponent
public java.lang.Object getComponent(java.lang.String theRole, java.lang.String theRoleHint) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
Description copied from interface:EnforcerRuleHelper
Gets the component.- Specified by:
getComponent
in interfaceEnforcerRuleHelper
- Parameters:
theRole
- the roletheRoleHint
- the role hint- Returns:
- the component
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
- the component lookup exception
-
getComponentList
public java.util.List<java.lang.Object> getComponentList(java.lang.String theRole) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
Description copied from interface:EnforcerRuleHelper
Gets the component list.- Specified by:
getComponentList
in interfaceEnforcerRuleHelper
- Parameters:
theRole
- the role- Returns:
- the component list
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
- the component lookup exception
-
getComponentMap
public java.util.Map<java.lang.String,java.lang.Object> getComponentMap(java.lang.String theRole) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
Description copied from interface:EnforcerRuleHelper
Gets the component map.- Specified by:
getComponentMap
in interfaceEnforcerRuleHelper
- Parameters:
theRole
- the role- Returns:
- the component map
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
- the component lookup exception
-
getComponent
public <T> T getComponent(java.lang.Class<T> clazz, java.lang.String roleHint) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
Description copied from interface:EnforcerRuleHelper
Gets the component.- Specified by:
getComponent
in interfaceEnforcerRuleHelper
- Type Parameters:
T
- a class type- Parameters:
clazz
- the clazzroleHint
- the role hint- Returns:
- the component
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
- the component lookup exception
-
getContainer
public org.codehaus.plexus.PlexusContainer getContainer()
Description copied from interface:EnforcerRuleHelper
Gets the container.- Specified by:
getContainer
in interfaceEnforcerRuleHelper
- Returns:
- the container
-
getCache
public java.lang.Object getCache(java.lang.String key, java.util.function.Supplier<?> producer)
Description copied from interface:EnforcerRuleHelper
Gets a cached value, or uses the provided producer to compute it.- Specified by:
getCache
in interfaceEnforcerRuleHelper
- Parameters:
key
- a key to identify the value storedproducer
- a supplier for the value if it's not already present- Returns:
- a previously-cached or freshly-computed value
-
-