001/*
002 * Copyright 2002-2014 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.handler;
018
019import org.springframework.web.method.HandlerMethod;
020
021/**
022 * A strategy for assigning a name to a handler method's mapping.
023 *
024 * <p>The strategy can be configured on
025 * {@link org.springframework.web.servlet.handler.AbstractHandlerMethodMapping
026 * AbstractHandlerMethodMapping}. It is used to assign a name to the mapping of
027 * every registered handler method. The names can then be queried via
028 * {@link org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#getHandlerMethodsForMappingName(String)
029 * AbstractHandlerMethodMapping#getHandlerMethodsForMappingName}.
030 *
031 * <p>Applications can build a URL to a controller method by name with the help
032 * of the static method
033 * {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder#fromMappingName(String)
034 * MvcUriComponentsBuilder#fromMappingName} or in JSPs through the "mvcUrl"
035 * function registered by the Spring tag library.
036 *
037 * @author Rossen Stoyanchev
038 * @since 4.1
039 */
040public interface HandlerMethodMappingNamingStrategy<T> {
041
042        /**
043         * Determine the name for the given HandlerMethod and mapping.
044         * @param handlerMethod the handler method
045         * @param mapping the mapping
046         * @return the name
047         */
048        String getName(HandlerMethod handlerMethod, T mapping);
049
050}