Class RegexpPathMapping

  • All Implemented Interfaces:
    PathMapping

    public final class RegexpPathMapping
    extends java.lang.Object
    implements PathMapping
    Implements a path mapping that supports regular expressions, i.e. /etc/(.*)=/dummy/$1/custom
    Since:
    3.1.42
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <K,​V>
      RegexpPathMapping
      addAllMappings​(java.util.Map<K,​V> pathsMappingMap)
      Allows importing mappings specified in data structure such as Map or Properties.
      RegexpPathMapping addMapping​(java.lang.String fromPattern, java.lang.String toPattern)
      Add a new mapping based on regular expression.
      java.lang.String map​(java.lang.String path)
      Maps the given path to a new location.
      java.lang.String map​(java.lang.String path, boolean reverse)
      Maps the given path to a new location.
      RegexpPathMapping merge​(RegexpPathMapping base)
      Merges the regexp mapping from the given base mapping.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RegexpPathMapping

        public RegexpPathMapping()
    • Method Detail

      • addAllMappings

        @Nonnull
        public <K,​V> RegexpPathMapping addAllMappings​(@Nonnull
                                                            java.util.Map<K,​V> pathsMappingMap)
        Allows importing mappings specified in data structure such as Map or Properties. All null entries (both keys and values) are ignored.
        Type Parameters:
        V - Value type
        K - KEey type
        Parameters:
        pathsMappingMap - the data structure containing the mapping
        Returns:
        this
      • addMapping

        @Nonnull
        public RegexpPathMapping addMapping​(@Nonnull
                                            java.lang.String fromPattern,
                                            @Nonnull
                                            java.lang.String toPattern)
        Add a new mapping based on regular expression.
        Parameters:
        fromPattern - the matching pattern, i.e. /etc/(.*)
        toPattern - the replacing pattern, i.e. /dummy/$1/custom
        Returns:
        this
      • merge

        @Nonnull
        public RegexpPathMapping merge​(@Nullable
                                       RegexpPathMapping base)
        Merges the regexp mapping from the given base mapping.
        Parameters:
        base - base mapping
        Returns:
        this
      • map

        @Nonnull
        public java.lang.String map​(@Nonnull
                                    java.lang.String path)
        Maps the given path to a new location.
        Specified by:
        map in interface PathMapping
        Parameters:
        path - the path
        Returns:
        the mapped path.
      • map

        @Nonnull
        public java.lang.String map​(@Nonnull
                                    java.lang.String path,
                                    boolean reverse)
        Maps the given path to a new location.
        Specified by:
        map in interface PathMapping
        Parameters:
        path - the path
        reverse - if true a reverse mapping is applied
        Returns:
        the mapped path.