001/* 002 * Copyright 2002-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.servlet.resource; 018 019import org.springframework.lang.Nullable; 020 021/** 022 * A strategy for extracting and embedding a resource version in its URL path. 023 * 024 * @author Brian Clozel 025 * @author Rossen Stoyanchev 026 * @since 4.1 027*/ 028public interface VersionPathStrategy { 029 030 /** 031 * Extract the resource version from the request path. 032 * @param requestPath the request path to check 033 * @return the version string or {@code null} if none was found 034 */ 035 @Nullable 036 String extractVersion(String requestPath); 037 038 /** 039 * Remove the version from the request path. It is assumed that the given 040 * version was extracted via {@link #extractVersion(String)}. 041 * @param requestPath the request path of the resource being resolved 042 * @param version the version obtained from {@link #extractVersion(String)} 043 * @return the request path with the version removed 044 */ 045 String removeVersion(String requestPath, String version); 046 047 /** 048 * Add a version to the given request path. 049 * @param requestPath the requestPath 050 * @param version the version 051 * @return the requestPath updated with a version string 052 */ 053 String addVersion(String requestPath, String version); 054 055}