Package: org.grails.web.mapping

## [Java] Class DefaultUrlMappingsHolder

- org.grails.web.mapping.DefaultUrlMappingsHolder

- All Implemented Interfaces and Traits:
    UrlMappings

      @java.lang.SuppressWarnings("rawtypes")
      public class DefaultUrlMappingsHolder
      extends java.lang.Object
      implements UrlMappings

  Default implementation of the UrlMappingsHolder interface that takes a list of mappings and then sorts them according to their precedence rules as defined in the implementation of Comparable.

  See Also:
    UrlMapping
    java.lang.Comparable
  Authors:
    Graeme Rocher
  Since:
    0.4

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `private enum` | `DefaultUrlMappingsHolder.CustomListWeigher` |
    `class` | `DefaultUrlMappingsHolder.UriToUrlMappingKey` |
    `class` | `DefaultUrlMappingsHolder.UrlMappingKey` | A class used as a key to lookup a UrlMapping based on controller, action and parameter names
    `class` | `DefaultUrlMappingsHolder.UrlMappingsList` |
    `class` | `DefaultUrlMappingsHolder.UrlMappingsListKey` | A class used as a key to lookup a all UrlMappings based on only controller and action.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private java.util.Set<java.lang.String>` | `DEFAULT_ACTION_PARAMS` |
    `private java.util.Set<java.lang.String>` | `DEFAULT_CONTROLLER_ONLY_PARAMS` |
    `private java.util.Set<java.lang.String>` | `DEFAULT_CONTROLLER_PARAMS` |
    `private static int` | `DEFAULT_MAX_WEIGHTED_CAPACITY` |
    `private java.util.Set<java.lang.String>` | `DEFAULT_NAMESPACE_PARAMS` |
    `static UrlMappingInfo[]` | `EMPTY_RESULTS` |
    `private static org.apache.commons.logging.Log` | `LOG` |
    `private com.github.benmanes.caffeine.cache.Cache<UriToUrlMappingKey, java.util.List<UrlMappingInfo>>` | `cachedListMatches` |
    `private com.github.benmanes.caffeine.cache.Cache<java.lang.String, UrlMappingInfo>` | `cachedMatches` |
    `private java.util.List` | `excludePatterns` |
    `private java.util.concurrent.atomic.AtomicInteger` | `initCounter` |
    `private UrlMapping[]` | `mappings` |
    `private DefaultUrlMappingsHolder.UrlMappingsList` | `mappingsListLookup` |
    `private java.util.Map<UrlMappingKey, UrlMapping>` | `mappingsLookup` |
    `private int` | `maxWeightedCacheCapacity` |
    `private java.util.Map<java.lang.String, UrlMapping>` | `namedMappings` |
    `private org.springframework.util.PathMatcher` | `pathMatcher` |
    `private UrlCreatorCache` | `urlCreatorCache` |
    `private int` | `urlCreatorMaxWeightedCacheCapacity` |
    `private java.util.List<UrlMapping>` | `urlMappings` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `DefaultUrlMappingsHolder (java.util.List<UrlMapping> mappings)`
    `DefaultUrlMappingsHolder (java.util.List<UrlMapping> mappings, java.util.List excludePatterns)`
    `DefaultUrlMappingsHolder (java.util.List<UrlMapping> mappings, java.util.List excludePatterns, boolean doNotCallInit)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public java.util.Collection<UrlMapping>` | `addMappings(groovy.lang.Closure mappings)`
    `` | `public java.util.Set<org.springframework.http.HttpMethod>` | `allowedMethods(java.lang.String uri)`
    `` | `private boolean` | `canInferAction(java.lang.String actionName, boolean secondAttempt, boolean indexAction, UrlMapping mapping)`
    `` | `public java.util.List` | `getExcludePatterns()`
    `` | `public UrlCreator` | `getReverseMapping(java.lang.String controller, java.lang.String action, java.util.Map params)`
    `` | `public UrlCreator` | `getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map params)`
    `` | `public UrlCreator` | `getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)`
    `` | `public UrlCreator` | `getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)`
    `` | `public UrlCreator` | `getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map params)` See Also: UrlMappingsHolder#getReverseMapping(String, String, java.util.Map)
    `` | `public UrlCreator` | `getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.util.Map params)`
    `` | `public UrlCreator` | `getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)`
    `` | `public UrlCreator` | `getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)`
    `` | `public UrlMapping[]` | `getUrlMappings()`
    `` | `public void` | `initialize()`
    `` | `private boolean` | `isExcluded(java.lang.String uri)`
    `` | `protected UrlMapping` | `lookupMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)` Performs a match uses reverse mappings to looks up a mapping from the controller, action and params.
    `` | `public UrlMappingInfo` | `match(java.lang.String uri)` See Also: UrlMappingsHolder.match
    `` | `public UrlMappingInfo[]` | `matchAll(java.lang.String uri)`
    `` | `public UrlMappingInfo[]` | `matchAll(java.lang.String uri, java.lang.String httpMethod)`
    `` | `public UrlMappingInfo[]` | `matchAll(java.lang.String uri, java.lang.String httpMethod, java.lang.String version)`
    `` | `public UrlMappingInfo[]` | `matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod)`
    `` | `public UrlMappingInfo[]` | `matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod, java.lang.String version)`
    `` | `public UrlMappingInfo` | `matchStatusCode(int responseCode)`
    `` | `public UrlMappingInfo` | `matchStatusCode(int responseCode, java.lang.Throwable e)`
    `` | `private UrlCreator` | `resolveUrlCreator(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params, boolean useDefault)`
    `` | `public void` | `setMaxWeightedCacheCapacity(int maxWeightedCacheCapacity)`
    `` | `public void` | `setUrlCreatorMaxWeightedCacheCapacity(int urlCreatorMaxWeightedCacheCapacity)`
    `` | `private void` | `sortMappings()`
    `` | `public java.lang.String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private final java.util.Set<java.lang.String> DEFAULT_ACTION_PARAMS

    - #### private final java.util.Set<java.lang.String> DEFAULT_CONTROLLER_ONLY_PARAMS

    - #### private final java.util.Set<java.lang.String> DEFAULT_CONTROLLER_PARAMS

    - #### private static final int DEFAULT_MAX_WEIGHTED_CAPACITY

    - #### private final java.util.Set<java.lang.String> DEFAULT_NAMESPACE_PARAMS

    - #### public static final UrlMappingInfo[] EMPTY_RESULTS

    - #### private static final org.apache.commons.logging.Log LOG

    - #### private com.github.benmanes.caffeine.cache.Cache<UriToUrlMappingKey, java.util.List<UrlMappingInfo>> cachedListMatches

    - #### private com.github.benmanes.caffeine.cache.Cache<java.lang.String, UrlMappingInfo> cachedMatches

    - #### private final java.util.List excludePatterns

    - #### private final java.util.concurrent.atomic.AtomicInteger initCounter

    - #### private UrlMapping[] mappings

    - #### private final DefaultUrlMappingsHolder.UrlMappingsList mappingsListLookup

    - #### private final java.util.Map<UrlMappingKey, UrlMapping> mappingsLookup

    - #### private int maxWeightedCacheCapacity

    - #### private final java.util.Map<java.lang.String, UrlMapping> namedMappings

    - #### private final org.springframework.util.PathMatcher pathMatcher

    - #### private UrlCreatorCache urlCreatorCache

    - #### private int urlCreatorMaxWeightedCacheCapacity

    - #### private java.util.List<UrlMapping> urlMappings

  - ### Constructor Detail

    - #### public DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings)

    - #### public DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings, java.util.List excludePatterns)

    - #### public DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings, java.util.List excludePatterns, boolean doNotCallInit)

  - ### Method Detail

    - #### @java.lang.Override public java.util.Collection<UrlMapping> addMappings(groovy.lang.Closure mappings)

    - #### @java.lang.Override public java.util.Set<org.springframework.http.HttpMethod> allowedMethods(java.lang.String uri)

    - #### private boolean canInferAction(java.lang.String actionName, boolean secondAttempt, boolean indexAction, UrlMapping mapping)

    - #### public java.util.List getExcludePatterns()

    - #### public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.util.Map params)

    - #### @java.lang.Override public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map params)

    - #### @java.lang.Override public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)

    - #### @java.lang.Override public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)

    - #### public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map params)

      See Also:
        UrlMappingsHolder#getReverseMapping(String, String, java.util.Map)

    - #### public UrlCreator getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.util.Map params)

    - #### @java.lang.Override public UrlCreator getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)

    - #### @java.lang.Override public UrlCreator getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)

    - #### public UrlMapping[] getUrlMappings()

    - #### public void initialize()

    - #### private boolean isExcluded(java.lang.String uri)

    - #### @java.lang.SuppressWarnings("unchecked") protected UrlMapping lookupMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)

      Performs a match uses reverse mappings to looks up a mapping from the controller, action and params. This is refactored to use a list of mappings identified by only controller and action and then matches the mapping to select the mapping that best matches the params (most possible matches).

      Parameters:
        `controller` - The controller name
        `action` - The action name
        `httpMethod` - The HTTP method
        version
        `params` - The params
      Returns:
        A UrlMapping instance or null

    - #### public UrlMappingInfo match(java.lang.String uri)

      See Also:
        UrlMappingsHolder.match

    - #### public UrlMappingInfo[] matchAll(java.lang.String uri)

    - #### public UrlMappingInfo[] matchAll(java.lang.String uri, java.lang.String httpMethod)

    - #### public UrlMappingInfo[] matchAll(java.lang.String uri, java.lang.String httpMethod, java.lang.String version)

    - #### @java.lang.Override public UrlMappingInfo[] matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod)

    - #### @java.lang.Override public UrlMappingInfo[] matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod, java.lang.String version)

    - #### public UrlMappingInfo matchStatusCode(int responseCode)

    - #### public UrlMappingInfo matchStatusCode(int responseCode, java.lang.Throwable e)

    - #### @java.lang.SuppressWarnings("unchecked") private UrlCreator resolveUrlCreator(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params, boolean useDefault)

    - #### public void setMaxWeightedCacheCapacity(int maxWeightedCacheCapacity)

    - #### public void setUrlCreatorMaxWeightedCacheCapacity(int urlCreatorMaxWeightedCacheCapacity)

    - #### @java.lang.SuppressWarnings("unchecked") private void sortMappings()

    - #### @java.lang.Override public java.lang.String toString()