Skip to content

Commit bb0f292

Browse files
authored
Clarifies documentation around configKey (OpenFeign#437)
This adds more javadoc around configKey, including examples of how it is used. See OpenFeign#434
1 parent cc650a0 commit bb0f292

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

core/src/main/java/feign/Feign.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,28 @@ public static Builder builder() {
4040
}
4141

4242
/**
43-
* <br> Configuration keys are formatted as unresolved <a href= "http://docs.oracle.com/javase/6/docs/jdk/api/javadoc/doclet/com/sun/javadoc/SeeTag.html"
44-
* >see tags</a>. <br> For example. <ul> <li>{@code Route53}: would match a class such as {@code
45-
* denominator.route53.Route53} <li>{@code Route53#list()}: would match a method such as {@code
46-
* denominator.route53.Route53#list()} <li>{@code Route53#listAt(Marker)}: would match a method
47-
* such as {@code denominator.route53.Route53#listAt(denominator.route53.Marker)} <li>{@code
48-
* Route53#listByNameAndType(String, String)}: would match a method such as {@code
49-
* denominator.route53.Route53#listAt(String, String)} </ul> <br> Note that there is no whitespace
50-
* expected in a key!
43+
* Configuration keys are formatted as unresolved <a href= "http://docs.oracle.com/javase/6/docs/jdk/api/javadoc/doclet/com/sun/javadoc/SeeTag.html"
44+
* >see tags</a>. This method exposes that format, in case you need to create the same value as
45+
* {@link MethodMetadata#configKey()} for correlation purposes.
46+
*
47+
* <p>Here are some sample encodings:
48+
*
49+
* <pre>
50+
* <ul>
51+
* <li>{@code Route53}: would match a class {@code route53.Route53}</li>
52+
* <li>{@code Route53#list()}: would match a method {@code route53.Route53#list()}</li>
53+
* <li>{@code Route53#listAt(Marker)}: would match a method {@code
54+
* route53.Route53#listAt(Marker)}</li>
55+
* <li>{@code Route53#listByNameAndType(String, String)}: would match a method {@code
56+
* route53.Route53#listAt(String, String)}</li>
57+
* </ul>
58+
* </pre>
59+
*
60+
* Note that there is no whitespace expected in a key!
5161
*
5262
* @param targetType {@link feign.Target#type() type} of the Feign interface.
5363
* @param method invoked method, present on {@code type} or its super.
64+
* @see MethodMetadata#configKey()
5465
*/
5566
public static String configKey(Class targetType, Method method) {
5667
StringBuilder builder = new StringBuilder();
@@ -136,9 +147,9 @@ public Builder decoder(Decoder decoder) {
136147
* This flag indicates that the {@link #decoder(Decoder) decoder} should process responses with
137148
* 404 status, specifically returning null or empty instead of throwing {@link FeignException}.
138149
*
139-
* <p/> All first-party (ex gson) decoders return well-known empty values defined by
140-
* {@link Util#emptyValueOf}. To customize further, wrap an existing
141-
* {@link #decoder(Decoder) decoder} or make your own.
150+
* <p/> All first-party (ex gson) decoders return well-known empty values defined by {@link
151+
* Util#emptyValueOf}. To customize further, wrap an existing {@link #decoder(Decoder) decoder}
152+
* or make your own.
142153
*
143154
* <p/> This flag only works with 404, as opposed to all or arbitrary status codes. This was an
144155
* explicit decision: 404 -> empty is safe, common and doesn't complicate redirection, retry or

core/src/main/java/feign/MethodMetadata.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public final class MethodMetadata implements Serializable {
4848
}
4949

5050
/**
51+
* Used as a reference to this method. For example, {@link Logger#log(String, String, Object...)
52+
* logging} or {@link ReflectiveFeign reflective dispatch}.
53+
*
5154
* @see Feign#configKey(Class, java.lang.reflect.Method)
5255
*/
5356
public String configKey() {
@@ -145,8 +148,8 @@ public Map<Integer, Class<? extends Expander>> indexToExpanderClass() {
145148
}
146149

147150
/**
148-
* After {@link #indexToExpanderClass} is populated, this is set by contracts that support
149-
* runtime injection.
151+
* After {@link #indexToExpanderClass} is populated, this is set by contracts that support runtime
152+
* injection.
150153
*/
151154
public MethodMetadata indexToExpander(Map<Integer, Expander> indexToExpander) {
152155
this.indexToExpander = indexToExpander;

0 commit comments

Comments
 (0)