MatcherLookup
Date: 2014-12-13

org.apache.ivy.core.module.id

## Class MatcherLookup

- java.lang.Object
- - org.apache.ivy.core.module.id.MatcherLookup

-     public class MatcherLookup
      extends java.lang.Object

  This class targets to speed up lookup for exact pattern matcher by keys, which are created with (organization, module) information. When exact pattern matcher is added, the key is created from matcher's attributes. When matcher is looked up against specific module, the key is recreated from module's attributes.

  The lookup doesn't target to speed up lookup for non exact pattern matcher. All non exact matchers are placed in non-keyed collection.

  At lookup for matchers against specific module, all non exact pattern matchers are iterated to match with module attributes, and exact pattern matchers binding to the same key will also iterated to match with module attributes.

  If there are much more exact pattern matchers than non exact pattern matchers, the matcher lookup speed can benefit from this class significantly. A quick example could be user declares lots of dependencyOverrides which are typically exact pattern matchers.

  If there are balanced exact and non exact pattern matchers, the matcher lookup speed doesn't hurt by this class.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MatcherLookup()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(MapMatcher matcher)` Add matcher.
    `java.util.List` | `get(java.util.Map attrs)` Get a list of matchers which can apply to module with specified attributes

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MatcherLookup

          public MatcherLookup()

  - ### Method Detail

    - #### add

          public void add(MapMatcher matcher)

      Add matcher. If matcher is exact pattern matcher, it will be associated with a key and placed in keyed collection. If matcher is not exact pattern matcher, it will be placed into non-keyed collection
      Parameters:
        `matcher` -

    - #### get

          public java.util.List get(java.util.Map attrs)

      Get a list of matchers which can apply to module with specified attributes
      Parameters:
        `attrs` - A map of attributes that matcher should match.
      Returns:
        list A list of candidate matchers that matches specified attributes