## org.apache.ivy.core.module.id
Class ModuleRules

    java.lang.Object
      org.apache.ivy.core.module.id.ModuleRules

    public class ModuleRules

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
`ModuleRules()` Constructs an empty ModuleRules.

Method Summary
`java.lang.Object` `clone()`
`void` `defineRule(MapMatcher condition, java.lang.Object rule)` Defines a new rule for the given condition.
`void` `dump(java.lang.String prefix)` Dump the list of rules to `Message.debug(String)`
`java.util.Map` `getAllRules()` Returns an unmodifiable view of all the rules defined on this ModuleRules.
`java.lang.Object` `getRule(ModuleId mid)` Returns the rule object matching the given `ModuleId`, or `null` if no rule applies.
`java.lang.Object` `getRule(ModuleId mid, Filter filter)` Returns the rule object matching the given `ModuleId` and accepted by the given `Filter`, or `null` if no rule applies.
`java.lang.Object` `getRule(ModuleRevisionId mrid)` Returns the rule object matching the given `ModuleRevisionId`, or `null` if no rule applies.
`java.lang.Object` `getRule(ModuleRevisionId mrid, Filter filter)` Returns the rule object matching the given `ModuleRevisionId` and accepted by the given `Filter`, or `null` if no rule applies.
`java.lang.Object[]` `getRules(ModuleId mid)` Returns the rules objects matching the given `ModuleId`, or an empty array if no rule applies.
`java.lang.Object[]` `getRules(ModuleRevisionId mrid, Filter filter)` Returns the rules object matching the given `ModuleRevisionId` and accepted by the given `Filter`, or an empty array if no rule applies.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ModuleRules

    public ModuleRules()

  Constructs an empty ModuleRules.

Method Detail

### defineRule

    public void defineRule(MapMatcher condition,
                           java.lang.Object rule)

  Defines a new rule for the given condition.

  Parameters:
    `condition` - the condition for which the rule should be applied. Must not be `null`.
    `rule` - the rule to apply. Must not be `null`.

### getRule

    public java.lang.Object getRule(ModuleId mid)

  Returns the rule object matching the given `ModuleId`, or `null` if no rule applies.

  Parameters:
    `mid` - the `ModuleId` to search the rule for. Must not be `null`.
  Returns:
    the rule object matching the given `ModuleId`, or `null` if no rule applies.
  See Also:
    `getRule(ModuleId, Filter)`

### getRules

    public java.lang.Object[] getRules(ModuleId mid)

  Returns the rules objects matching the given `ModuleId`, or an empty array if no rule applies.

  Parameters:
    `mid` - the `ModuleId` to search the rule for. Must not be `null`.
  Returns:
    an array of rule objects matching the given `ModuleId`.

### getRule

    public java.lang.Object getRule(ModuleRevisionId mrid)

  Returns the rule object matching the given `ModuleRevisionId`, or `null` if no rule applies.

  Parameters:
    `mrid` - the `ModuleRevisionId` to search the rule for. Must not be `null`.
  Returns:
    the rule object matching the given `ModuleRevisionId`, or `null` if no rule applies.
  See Also:
    `getRule(ModuleRevisionId, Filter)`

### getRule

    public java.lang.Object getRule(ModuleId mid,
                                    Filter filter)

  Returns the rule object matching the given `ModuleId` and accepted by the given `Filter`, or `null` if no rule applies.

  Parameters:
    `mrid` - the `ModuleRevisionId` to search the rule for. Must not be `null`.
    `filter` - the filter to use to filter the rule to return. The `Filter.accept(Object)` method will be called only with rule objects matching the given `ModuleId`, and the first rule object accepted by the filter will be returned. Must not be `null`.
  Returns:
    the rule object matching the given `ModuleId`, or `null` if no rule applies.
  See Also:
    `getRule(ModuleRevisionId, Filter)`

### getRule

    public java.lang.Object getRule(ModuleRevisionId mrid,
                                    Filter filter)

  Returns the rule object matching the given `ModuleRevisionId` and accepted by the given `Filter`, or `null` if no rule applies.

  Parameters:
    `mrid` - the `ModuleRevisionId` to search the rule for. Must not be `null`.
    `filter` - the filter to use to filter the rule to return. The `Filter.accept(Object)` method will be called only with rule objects matching the given `ModuleRevisionId`, and the first rule object accepted by the filter will be returned. Must not be `null`.
  Returns:
    the rule object matching the given `ModuleRevisionId`, or `null` if no rule applies.
  See Also:
    `getRule(ModuleRevisionId)`

### getRules

    public java.lang.Object[] getRules(ModuleRevisionId mrid,
                                       Filter filter)

  Returns the rules object matching the given `ModuleRevisionId` and accepted by the given `Filter`, or an empty array if no rule applies.

  Parameters:
    `mrid` - the `ModuleRevisionId` to search the rule for. Must not be `null`.
    `filter` - the filter to use to filter the rule to return. The `Filter.accept(Object)` method will be called only with rule objects matching the given `ModuleRevisionId`. Must not be `null`.
  Returns:
    an array of rule objects matching the given `ModuleRevisionId`.

### dump

    public void dump(java.lang.String prefix)

  Dump the list of rules to `Message.debug(String)`

  Parameters:
    `prefix` - the prefix to use for each line dumped

### getAllRules

    public java.util.Map 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 java.lang.Object clone()

  Overrides:
    `clone` in class `java.lang.Object`