Package org.apache.ivy.core.module.id
Class ModuleRules<T>
- java.lang.Object
-
- org.apache.ivy.core.module.id.ModuleRules<T>
-
- Type Parameters:
T
- a type parameter
public class ModuleRules<T> extends java.lang.Object
A list of module specific rules.This class defines a list of module specific rules. For each module only one rule apply, sometimes none.
To know which rule to apply, they are configured using matchers. So you can define a rule applying to all module from one particular organization, or to all modules with a revisions matching a pattern, and so on.
Rules condition are evaluated in order, so the first matching rule is returned.
Rules themselves can be represented by any object, depending on the purpose of the rule (define which resolver to use, which TTL in cache, ...)
-
-
Constructor Summary
Constructors Constructor Description ModuleRules()
Constructs an empty ModuleRules.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModuleRules<T>
clone()
void
defineRule(MapMatcher condition, T rule)
Defines a new rule for the given condition.void
dump(java.lang.String prefix)
Dump the list of rules toMessage.debug(String)
java.util.Map<MapMatcher,T>
getAllRules()
Returns an unmodifiable view of all the rules defined on this ModuleRules.T
getRule(ModuleId mid)
Returns the rule object matching the givenModuleId
, ornull
if no rule applies.T
getRule(ModuleId mid, Filter<T> filter)
T
getRule(ModuleRevisionId mrid)
Returns the rule object matching the givenModuleRevisionId
, ornull
if no rule applies.T
getRule(ModuleRevisionId mrid, Filter<T> filter)
Returns the rule object matching the givenModuleRevisionId
and accepted by the givenFilter
, ornull
if no rule applies.java.util.List<T>
getRules(ModuleId mid)
Returns the rules objects matching the givenModuleId
, or an empty array if no rule applies.java.util.List<T>
getRules(ModuleRevisionId mrid, Filter<T> filter)
Returns the rules object matching the givenModuleRevisionId
and accepted by the givenFilter
, or an empty array if no rule applies.
-
-
-
Method Detail
-
defineRule
public void defineRule(MapMatcher condition, T rule)
Defines a new rule for the given condition.- Parameters:
condition
- the condition for which the rule should be applied. Must not benull
.rule
- the rule to apply. Must not benull
.
-
getRule
public T getRule(ModuleId mid)
Returns the rule object matching the givenModuleId
, ornull
if no rule applies.- Parameters:
mid
- theModuleId
to search the rule for. Must not benull
.- Returns:
- the rule object matching the given
ModuleId
, ornull
if no rule applies. - See Also:
getRule(ModuleId, Filter)
-
getRules
public java.util.List<T> getRules(ModuleId mid)
Returns the rules objects matching the givenModuleId
, or an empty array if no rule applies.
-
getRule
public T getRule(ModuleRevisionId mrid)
Returns the rule object matching the givenModuleRevisionId
, ornull
if no rule applies.- Parameters:
mrid
- theModuleRevisionId
to search the rule for. Must not benull
.- Returns:
- the rule object matching the given
ModuleRevisionId
, ornull
if no rule applies. - See Also:
getRule(ModuleRevisionId, Filter)
-
getRule
public T getRule(ModuleId mid, Filter<T> filter)
Returns the rule object matching the givenModuleId
and accepted by the givenFilter
, ornull
if no rule applies.- Parameters:
mid
- theModuleRevisionId
to search the rule for. Must not benull
.filter
- the filter to use to filter the rule to return. TheFilter.accept(Object)
method will be called only with rule objects matching the givenModuleId
, and the first rule object accepted by the filter will be returned. Must not benull
.- Returns:
- the rule object matching the given
ModuleId
, ornull
if no rule applies. - See Also:
getRule(ModuleRevisionId, Filter)
-
getRule
public T getRule(ModuleRevisionId mrid, Filter<T> filter)
Returns the rule object matching the givenModuleRevisionId
and accepted by the givenFilter
, ornull
if no rule applies.- Parameters:
mrid
- theModuleRevisionId
to search the rule for. Must not benull
.filter
- the filter to use to filter the rule to return. TheFilter.accept(Object)
method will be called only with rule objects matching the givenModuleRevisionId
, and the first rule object accepted by the filter will be returned. Must not benull
.- Returns:
- the rule object matching the given
ModuleRevisionId
, ornull
if no rule applies. - See Also:
getRule(ModuleRevisionId)
-
getRules
public java.util.List<T> getRules(ModuleRevisionId mrid, Filter<T> filter)
Returns the rules object matching the givenModuleRevisionId
and accepted by the givenFilter
, or an empty array if no rule applies.- Parameters:
mrid
- theModuleRevisionId
to search the rule for. Must not benull
.filter
- the filter to use to filter the rule to return. TheFilter.accept(Object)
method will be called only with rule objects matching the givenModuleRevisionId
. Must not benull
.- Returns:
- an array of rule objects matching the given
ModuleRevisionId
.
-
dump
public void dump(java.lang.String prefix)
Dump the list of rules toMessage.debug(String)
- Parameters:
prefix
- the prefix to use for each line dumped
-
getAllRules
public java.util.Map<MapMatcher,T> getAllRules()
Returns an unmodifiable view of all the rules defined on this ModuleRules.The rules are returned in a Map where they keys are the MapMatchers matching the rules object, and the values are the rules object themselves.
- Returns:
- an unmodifiable view of all the rules defined on this ModuleRules.
-
clone
public ModuleRules<T> clone()
- Overrides:
clone
in classjava.lang.Object
-
-