Skip to content

Commit cf5cade

Browse files
author
Adrian Cole
committed
Reformats code according to Google Java Style
Files had various formatting differences, as did pull requests. Rather than create our own style, this inherits and requires the well documented Google Java Style.
1 parent f2c61fe commit cf5cade

84 files changed

Lines changed: 1606 additions & 1309 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Adds `Feign.Builder.build()`
88
* Opens constructor for Gson and Jackson codecs which accepts type adapters
99
* Adds EmptyTarget for interfaces who exclusively declare URI methods
10+
* Reformats code according to [Google Java Style](https://google-styleguide.googlecode.com/svn/trunk/javaguide.html)
1011

1112
### Version 7.1
1213
* Introduces feign.@Param to annotate template parameters. Users must migrate from `javax.inject.@Named` to `feign.@Param` before updating to Feign 8.0.

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing to Feign
2+
3+
If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request (on a branch other than `master` or `gh-pages`).
4+
5+
When submitting code, please ensure you follow the [Google Style Guide](http://google-styleguide.googlecode.com/svn/trunk/javaguide.html). For example, you can format code with Intellij using [this file](https://google-styleguide.googlecode.com/svn/trunk/intellij-java-google-style.xml).
6+
7+
## License
8+
9+
By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/Netflix/Feign/blob/master/LICENSE
10+
11+
All files are released with the Apache 2.0 license.
12+
13+
If you are adding a new file it should have a header like this:
14+
15+
```
16+
/**
17+
* Copyright 2013 Netflix, Inc.
18+
*
19+
* Licensed under the Apache License, Version 2.0 (the "License");
20+
* you may not use this file except in compliance with the License.
21+
* You may obtain a copy of the License at
22+
*
23+
* http://www.apache.org/licenses/LICENSE-2.0
24+
*
25+
* Unless required by applicable law or agreed to in writing, software
26+
* distributed under the License is distributed on an "AS IS" BASIS,
27+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28+
* See the License for the specific language governing permissions and
29+
* limitations under the License.
30+
*/
31+
```

core/src/main/java/feign/Body.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
@Target(METHOD)
2626
@Retention(RUNTIME)
2727
public @interface Body {
28+
2829
String value();
2930
}

core/src/main/java/feign/Client.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
/** Submits HTTP {@link Request requests}. Implementations are expected to be thread-safe. */
3838
public interface Client {
39+
3940
/**
4041
* Executes a request against its {@link Request#url() url} and returns a response.
4142
*
@@ -47,6 +48,7 @@ public interface Client {
4748
Response execute(Request request, Options options) throws IOException;
4849

4950
public static class Default implements Client {
51+
5052
private final SSLSocketFactory sslContextFactory;
5153
private final HostnameVerifier hostnameVerifier;
5254

@@ -87,7 +89,9 @@ HttpURLConnection convertAndSend(Request request, Options options) throws IOExce
8789
boolean hasAcceptHeader = false;
8890
Integer contentLength = null;
8991
for (String field : request.headers().keySet()) {
90-
if (field.equalsIgnoreCase("Accept")) hasAcceptHeader = true;
92+
if (field.equalsIgnoreCase("Accept")) {
93+
hasAcceptHeader = true;
94+
}
9195
for (String value : request.headers().get(field)) {
9296
if (field.equals(CONTENT_LENGTH)) {
9397
if (!gzipEncodedRequest) {
@@ -100,7 +104,9 @@ HttpURLConnection convertAndSend(Request request, Options options) throws IOExce
100104
}
101105
}
102106
// Some servers choke on the default accept string.
103-
if (!hasAcceptHeader) connection.addRequestProperty("Accept", "*/*");
107+
if (!hasAcceptHeader) {
108+
connection.addRequestProperty("Accept", "*/*");
109+
}
104110

105111
if (request.body() != null) {
106112
if (contentLength != null) {
@@ -132,11 +138,15 @@ Response convertResponse(HttpURLConnection connection) throws IOException {
132138
Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>();
133139
for (Map.Entry<String, List<String>> field : connection.getHeaderFields().entrySet()) {
134140
// response message
135-
if (field.getKey() != null) headers.put(field.getKey(), field.getValue());
141+
if (field.getKey() != null) {
142+
headers.put(field.getKey(), field.getValue());
143+
}
136144
}
137145

138146
Integer length = connection.getContentLength();
139-
if (length == -1) length = null;
147+
if (length == -1) {
148+
length = null;
149+
}
140150
InputStream stream;
141151
if (status >= 400) {
142152
stream = connection.getErrorStream();

core/src/main/java/feign/Contract.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ abstract class BaseContract implements Contract {
3939
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> declaring) {
4040
List<MethodMetadata> metadata = new ArrayList<MethodMetadata>();
4141
for (Method method : declaring.getDeclaredMethods()) {
42-
if (method.getDeclaringClass() == Object.class) continue;
42+
if (method.getDeclaringClass() == Object.class) {
43+
continue;
44+
}
4345
metadata.add(parseAndValidatateMetadata(method));
4446
}
4547
return metadata;
@@ -100,7 +102,9 @@ protected abstract boolean processAnnotationsOnParameter(
100102
MethodMetadata data, Annotation[] annotations, int paramIndex);
101103

102104
protected Collection<String> addTemplatedParam(Collection<String> possiblyNull, String name) {
103-
if (possiblyNull == null) possiblyNull = new ArrayList<String>();
105+
if (possiblyNull == null) {
106+
possiblyNull = new ArrayList<String>();
107+
}
104108
possiblyNull.add(String.format("{%s}", name));
105109
return possiblyNull;
106110
}
@@ -201,10 +205,14 @@ protected boolean processAnnotationsOnParameter(
201205

202206
private <K, V> boolean searchMapValues(Map<K, Collection<V>> map, V search) {
203207
Collection<Collection<V>> values = map.values();
204-
if (values == null) return false;
208+
if (values == null) {
209+
return false;
210+
}
205211

206212
for (Collection<V> entry : values) {
207-
if (entry.contains(search)) return true;
213+
if (entry.contains(search)) {
214+
return true;
215+
}
208216
}
209217

210218
return false;

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@
3333
*/
3434
public abstract class Feign {
3535

36-
/**
37-
* Returns a new instance of an HTTP API, defined by annotations in the {@link Feign Contract},
38-
* for the specified {@code target}. You should cache this result.
39-
*/
40-
public abstract <T> T newInstance(Target<T> target);
41-
4236
public static Builder builder() {
4337
return new Builder();
4438
}
@@ -67,13 +61,23 @@ public static String configKey(Method method) {
6761
StringBuilder builder = new StringBuilder();
6862
builder.append(method.getDeclaringClass().getSimpleName());
6963
builder.append('#').append(method.getName()).append('(');
70-
for (Class<?> param : method.getParameterTypes())
64+
for (Class<?> param : method.getParameterTypes()) {
7165
builder.append(param.getSimpleName()).append(',');
72-
if (method.getParameterTypes().length > 0) builder.deleteCharAt(builder.length() - 1);
66+
}
67+
if (method.getParameterTypes().length > 0) {
68+
builder.deleteCharAt(builder.length() - 1);
69+
}
7370
return builder.append(')').toString();
7471
}
7572

73+
/**
74+
* Returns a new instance of an HTTP API, defined by annotations in the {@link Feign Contract},
75+
* for the specified {@code target}. You should cache this result.
76+
*/
77+
public abstract <T> T newInstance(Target<T> target);
78+
7679
public static class Builder {
80+
7781
private final List<RequestInterceptor> requestInterceptors =
7882
new ArrayList<RequestInterceptor>();
7983
private Logger.Level logLevel = Logger.Level.NONE;

core/src/main/java/feign/FeignException.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121

2222
/** Origin exception type for all Http Apis. */
2323
public class FeignException extends RuntimeException {
24+
25+
private static final long serialVersionUID = 0;
26+
27+
protected FeignException(String message, Throwable cause) {
28+
super(message, cause);
29+
}
30+
31+
protected FeignException(String message) {
32+
super(message);
33+
}
34+
2435
static FeignException errorReading(Request request, Response ignored, IOException cause) {
2536
return new FeignException(
2637
format("%s %s %s", cause.getMessage(), request.method(), request.url()), cause);
@@ -44,14 +55,4 @@ static FeignException errorExecuting(Request request, IOException cause) {
4455
cause,
4556
null);
4657
}
47-
48-
protected FeignException(String message, Throwable cause) {
49-
super(message, cause);
50-
}
51-
52-
protected FeignException(String message) {
53-
super(message);
54-
}
55-
56-
private static final long serialVersionUID = 0;
5758
}

core/src/main/java/feign/Headers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@
5151
@Target(METHOD)
5252
@Retention(RUNTIME)
5353
public @interface Headers {
54+
5455
String[] value();
5556
}

core/src/main/java/feign/InvocationHandlerFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@
2222
/** Controls reflective method dispatch. */
2323
public interface InvocationHandlerFactory {
2424

25+
InvocationHandler create(Target target, Map<Method, MethodHandler> dispatch);
26+
2527
/**
2628
* Like {@link InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[])}, except for a
2729
* single method.
2830
*/
2931
interface MethodHandler {
32+
3033
Object invoke(Object[] argv) throws Throwable;
3134
}
3235

33-
InvocationHandler create(Target target, Map<Method, MethodHandler> dispatch);
34-
3536
static final class Default implements InvocationHandlerFactory {
37+
3638
@Override
3739
public InvocationHandler create(Target target, Map<Method, MethodHandler> dispatch) {
3840
return new ReflectiveFeign.FeignInvocationHandler(target, dispatch);

0 commit comments

Comments
 (0)