/* * Copyright 2013 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package feign; import java.io.Serializable; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import feign.Param.Expander; public final class MethodMetadata implements Serializable { private static final long serialVersionUID = 1L; private String configKey; private transient Type returnType; private Integer urlIndex; private Integer bodyIndex; private Integer headerMapIndex; private Integer queryMapIndex; private boolean queryMapEncoded; private transient Type bodyType; private RequestTemplate template = new RequestTemplate(); private List<String> formParams = new ArrayList<String>(); private Map<Integer, Collection<String>> indexToName = new LinkedHashMap<Integer, Collection<String>>(); private Map<Integer, Class<? extends Expander>> indexToExpanderClass = new LinkedHashMap<Integer, Class<? extends Expander>>(); private Map<Integer, Boolean> indexToEncoded = new LinkedHashMap<Integer, Boolean>(); private transient Map<Integer, Expander> indexToExpander; MethodMetadata() { } /** * Used as a reference to this method. For example, {@link Logger#log(String, String, Object...) * logging} or {@link ReflectiveFeign reflective dispatch}. * * @see Feign#configKey(Class, java.lang.reflect.Method) */ public String configKey() { return configKey; } public MethodMetadata configKey(String configKey) { this.configKey = configKey; return this; } public Type returnType() { return returnType; } public MethodMetadata returnType(Type returnType) { this.returnType = returnType; return this; } public Integer urlIndex() { return urlIndex; } public MethodMetadata urlIndex(Integer urlIndex) { this.urlIndex = urlIndex; return this; } public Integer bodyIndex() { return bodyIndex; } public MethodMetadata bodyIndex(Integer bodyIndex) { this.bodyIndex = bodyIndex; return this; } public Integer headerMapIndex() { return headerMapIndex; } public MethodMetadata headerMapIndex(Integer headerMapIndex) { this.headerMapIndex = headerMapIndex; return this; } public Integer queryMapIndex() { return queryMapIndex; } public MethodMetadata queryMapIndex(Integer queryMapIndex) { this.queryMapIndex = queryMapIndex; return this; } public boolean queryMapEncoded() { return queryMapEncoded; } public MethodMetadata queryMapEncoded(boolean queryMapEncoded) { this.queryMapEncoded = queryMapEncoded; return this; } /** * Type corresponding to {@link #bodyIndex()}. */ public Type bodyType() { return bodyType; } public MethodMetadata bodyType(Type bodyType) { this.bodyType = bodyType; return this; } public RequestTemplate template() { return template; } public List<String> formParams() { return formParams; } public Map<Integer, Collection<String>> indexToName() { return indexToName; } public Map<Integer, Boolean> indexToEncoded() { return indexToEncoded; } /** * If {@link #indexToExpander} is null, classes here will be instantiated by newInstance. */ public Map<Integer, Class<? extends Expander>> indexToExpanderClass() { return indexToExpanderClass; } /** * After {@link #indexToExpanderClass} is populated, this is set by contracts that support runtime * injection. */ public MethodMetadata indexToExpander(Map<Integer, Expander> indexToExpander) { this.indexToExpander = indexToExpander; return this; } /** * When not null, this value will be used instead of {@link #indexToExpander()}. */ public Map<Integer, Expander> indexToExpander() { return indexToExpander; } }