org.springframework.web.servlet.resource

## Class AbstractVersionStrategy.PrefixVersionPathStrategy

- java.lang.Object
- - org.springframework.web.servlet.resource.AbstractVersionStrategy.PrefixVersionPathStrategy

- All Implemented Interfaces:
    VersionPathStrategy
  Enclosing class:
    AbstractVersionStrategy

      protected static class AbstractVersionStrategy.PrefixVersionPathStrategy
      extends Object
      implements VersionPathStrategy

  A prefix-based `VersionPathStrategy`, e.g. `"{version}/path/foo.js"`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PrefixVersionPathStrategy(String version)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `addVersion(String path, String version)` Add a version to the given request path.
    `String` | `extractVersion(String requestPath)` Extract the resource version from the request path.
    `String` | `removeVersion(String requestPath, String version)` Remove the version from the request path.

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

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

- - ### Constructor Detail

    - #### PrefixVersionPathStrategy

          public PrefixVersionPathStrategy(String version)

  - ### Method Detail

    - #### extractVersion

          @Nullable
          public String extractVersion(String requestPath)

      Description copied from interface: `VersionPathStrategy`
      Extract the resource version from the request path.
      Specified by:
        `extractVersion` in interface `VersionPathStrategy`
      Parameters:
        `requestPath` - the request path to check
      Returns:
        the version string or `null` if none was found

    - #### removeVersion

          public String removeVersion(String requestPath,
                                      String version)

      Description copied from interface: `VersionPathStrategy`
      Remove the version from the request path. It is assumed that the given version was extracted via `VersionPathStrategy.extractVersion(String)`.
      Specified by:
        `removeVersion` in interface `VersionPathStrategy`
      Parameters:
        `requestPath` - the request path of the resource being resolved
        `version` - the version obtained from `VersionPathStrategy.extractVersion(String)`
      Returns:
        the request path with the version removed

    - #### addVersion

          public String addVersion(String path,
                                   String version)

      Description copied from interface: `VersionPathStrategy`
      Add a version to the given request path.
      Specified by:
        `addVersion` in interface `VersionPathStrategy`
      Parameters:
        `path` - the requestPath
        `version` - the version
      Returns:
        the requestPath updated with a version string