001/* 002 * Copyright 2002-2016 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.util; 018 019import java.net.URI; 020import java.util.Map; 021 022/** 023 * Strategy for expanding a URI template with full control over the URI template 024 * syntax and the encoding of variables. Also a convenient central point for 025 * pre-processing all URI templates for example to insert a common base path. 026 * 027 * <p>Supported as a property on the {@code RestTemplate} as well as the 028 * {@code AsyncRestTemplate}. The {@link DefaultUriTemplateHandler} is built 029 * on Spring's URI template support via {@link UriComponentsBuilder}. An 030 * alternative implementation may be used to plug external URI template libraries. 031 * 032 * @author Rossen Stoyanchev 033 * @since 4.2 034 * @see org.springframework.web.client.RestTemplate#setUriTemplateHandler 035 */ 036public interface UriTemplateHandler { 037 038 /** 039 * Expand the given URI template from a map of URI variables. 040 * @param uriTemplate the URI template string 041 * @param uriVariables the URI variables 042 * @return the resulting URI 043 */ 044 URI expand(String uriTemplate, Map<String, ?> uriVariables); 045 046 /** 047 * Expand the given URI template from an array of URI variables. 048 * @param uriTemplate the URI template string 049 * @param uriVariables the URI variable values 050 * @return the resulting URI 051 */ 052 URI expand(String uriTemplate, Object... uriVariables); 053 054}