Skip to content

Commit 163027e

Browse files
committed
Apply checkstyle changes to spring-graphql
See gh-943
1 parent b66eb64 commit 163027e

File tree

219 files changed

+1297
-983
lines changed

Some content is hidden

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

219 files changed

+1297
-983
lines changed

spring-graphql/src/main/java/org/springframework/graphql/GraphQlRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface GraphQlRequest {
6161
/**
6262
* Convert the request to a {@link Map} as defined in
6363
* <a href="https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md">GraphQL over HTTP</a> and
64-
* <a href="https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md">GraphQL over WebSocket</a>:
64+
* <a href="https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md">GraphQL over WebSocket</a>.
6565
* <table>
6666
* <tr><th>Key</th><th>Value</th></tr>
6767
* <tr><td>query</td><td>{@link #getDocument() document}</td></tr>

spring-graphql/src/main/java/org/springframework/graphql/ResponseError.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2020-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.graphql;
218

319
import java.util.List;

spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface ResponseField {
4343
* </ul>
4444
* @deprecated as of 1.0.3 in favor of checking via {@link #getValue()}
4545
*/
46-
@Deprecated
46+
@Deprecated(since = "1.0.3", forRemoval = true)
4747
boolean hasValue();
4848

4949
/**
@@ -90,7 +90,7 @@ public interface ResponseField {
9090
* @deprecated since 1.0.3 in favor of {@link #getErrors()}
9191
*/
9292
@Nullable
93-
@Deprecated
93+
@Deprecated(since = "1.0.3", forRemoval = true)
9494
ResponseError getError();
9595

9696
/**

spring-graphql/src/main/java/org/springframework/graphql/client/AbstractGraphQlClientBuilder.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* agnostic {@code GraphQlClient}. A transport specific extension can then wrap
4747
* this default tester by extending {@link AbstractDelegatingGraphQlClient}.
4848
*
49+
* @param <B> the builder type
4950
* @author Rossen Stoyanchev
5051
* @since 1.0.0
5152
* @see AbstractDelegatingGraphQlClient
@@ -114,6 +115,8 @@ private <T extends B> T self() {
114115
* Transport-specific subclasses can provide their JSON {@code Encoder} and
115116
* {@code Decoder} for use at the client level, for mapping response data
116117
* to some target entity type.
118+
* @param encoder the JSON encoder to use
119+
* @param decoder the JSON decoder to use
117120
*/
118121
protected void setJsonCodecs(Encoder<?> encoder, Decoder<?> decoder) {
119122
this.jsonEncoder = encoder;
@@ -122,6 +125,7 @@ protected void setJsonCodecs(Encoder<?> encoder, Decoder<?> decoder) {
122125

123126
/**
124127
* Variant of {@link #setJsonCodecs} for setting each codec individually.
128+
* @param encoder the JSON encoder to use
125129
*/
126130
protected void setJsonEncoder(Encoder<?> encoder) {
127131
this.jsonEncoder = encoder;
@@ -137,6 +141,7 @@ protected Encoder<?> getJsonEncoder() {
137141

138142
/**
139143
* Variant of {@link #setJsonCodecs} for setting each codec individually.
144+
* @param decoder the JSON decoder to use
140145
*/
141146
protected void setJsonDecoder(Decoder<?> decoder) {
142147
this.jsonDecoder = decoder;
@@ -161,12 +166,13 @@ protected List<GraphQlClientInterceptor> getInterceptors() {
161166
/**
162167
* Build the default transport-agnostic client that subclasses can then wrap
163168
* with {@link AbstractDelegatingGraphQlClient}.
169+
* @param transport the GraphQL transport to be used by the client
164170
*/
165171
protected GraphQlClient buildGraphQlClient(GraphQlTransport transport) {
166172

167173
if (jackson2Present) {
168-
this.jsonEncoder = (this.jsonEncoder == null ? DefaultJackson2Codecs.encoder() : this.jsonEncoder);
169-
this.jsonDecoder = (this.jsonDecoder == null ? DefaultJackson2Codecs.decoder() : this.jsonDecoder);
174+
this.jsonEncoder = (this.jsonEncoder == null) ? DefaultJackson2Codecs.encoder() : this.jsonEncoder;
175+
this.jsonDecoder = (this.jsonDecoder == null) ? DefaultJackson2Codecs.decoder() : this.jsonDecoder;
170176
}
171177

172178
return new DefaultGraphQlClient(
@@ -177,32 +183,32 @@ protected GraphQlClient buildGraphQlClient(GraphQlTransport transport) {
177183
* Return a {@code Consumer} to initialize new builders from "this" builder.
178184
*/
179185
protected Consumer<AbstractGraphQlClientBuilder<?>> getBuilderInitializer() {
180-
return builder -> {
181-
builder.interceptors(interceptorList -> interceptorList.addAll(interceptors));
182-
builder.documentSource(documentSource);
186+
return (builder) -> {
187+
builder.interceptors((interceptorList) -> interceptorList.addAll(this.interceptors));
188+
builder.documentSource(this.documentSource);
183189
builder.setJsonCodecs(getEncoder(), getDecoder());
184190
};
185191
}
186192

187193
private Chain createExecuteChain(GraphQlTransport transport) {
188194

189-
Chain chain = request -> transport.execute(request).map(response ->
195+
Chain chain = (request) -> transport.execute(request).map((response) ->
190196
new DefaultClientGraphQlResponse(request, response, getEncoder(), getDecoder()));
191197

192198
return this.interceptors.stream()
193199
.reduce(GraphQlClientInterceptor::andThen)
194-
.map(interceptor -> (Chain) (request) -> interceptor.intercept(request, chain))
200+
.map((interceptor) -> (Chain) (request) -> interceptor.intercept(request, chain))
195201
.orElse(chain);
196202
}
197203

198204
private SubscriptionChain createExecuteSubscriptionChain(GraphQlTransport transport) {
199205

200-
SubscriptionChain chain = request -> transport.executeSubscription(request)
201-
.map(response -> new DefaultClientGraphQlResponse(request, response, getEncoder(), getDecoder()));
206+
SubscriptionChain chain = (request) -> transport.executeSubscription(request)
207+
.map((response) -> new DefaultClientGraphQlResponse(request, response, getEncoder(), getDecoder()));
202208

203209
return this.interceptors.stream()
204210
.reduce(GraphQlClientInterceptor::andThen)
205-
.map(interceptor -> (SubscriptionChain) (request) -> interceptor.interceptSubscription(request, chain))
211+
.map((interceptor) -> (SubscriptionChain) (request) -> interceptor.interceptSubscription(request, chain))
206212
.orElse(chain);
207213
}
208214

spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponse.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ public interface ClientGraphQlResponse extends GraphQlResponse {
3232
/**
3333
* {@inheritDoc}
3434
*/
35+
@Override
3536
ClientResponseField field(String path);
3637

3738
/**
3839
* Decode the full response map to the given target type.
40+
* @param <D> the target type
3941
* @param type the target class
4042
* @return the decoded value, or never {@code null}
4143
* @throws FieldAccessException if the response is not {@link #isValid() valid}
@@ -44,7 +46,8 @@ public interface ClientGraphQlResponse extends GraphQlResponse {
4446

4547
/**
4648
* Variant of {@link #toEntity(Class)} with a {@link ParameterizedTypeReference}.
47-
* @param type the target type
49+
* @param <D> the target type
50+
* @param type the target parameterized type
4851
* @return the decoded value, or never {@code null}
4952
* @throws FieldAccessException if the response is not {@link #isValid() valid}
5053
*/

spring-graphql/src/main/java/org/springframework/graphql/client/ClientResponseField.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface ClientResponseField extends ResponseField {
3434

3535
/**
3636
* Decode the field to an entity of the given type.
37+
* @param <D> the entity type
3738
* @param entityType the type to convert to
3839
* @return the decoded entity, or {@code null} if the field is {@code null}
3940
* but otherwise there are no errors
@@ -46,12 +47,15 @@ public interface ClientResponseField extends ResponseField {
4647

4748
/**
4849
* Variant of {@link #toEntity(Class)} with a {@link ParameterizedTypeReference}.
50+
* @param <D> the entity type
51+
* @param entityType the type to convert to
4952
*/
5053
@Nullable
5154
<D> D toEntity(ParameterizedTypeReference<D> entityType);
5255

5356
/**
5457
* Variant of {@link #toEntity(Class)} to decode to a list of entities.
58+
* @param <D> the entity type
5559
* @param elementType the type of elements in the list
5660
* @return the list of decoded entities, or an empty list if the field is
5761
* {@code null} but otherwise there are no errors
@@ -61,15 +65,16 @@ public interface ClientResponseField extends ResponseField {
6165
*/
6266
<D> List<D> toEntityList(Class<D> elementType);
6367

64-
/**
65-
* Variant of {@link #toEntity(Class)} to decode to a list of entities.
66-
* @param elementType the type of elements in the list
67-
* @return the list of decoded entities, or an empty list if the field is
68-
* {@code null} but otherwise there are no errors
69-
* @throws FieldAccessException if the target field is {@code null} and the
70-
* response is not {@link GraphQlResponse#isValid() valid} or the field has
71-
* {@link ResponseField#getErrors() errors}.
72-
*/
68+
/**
69+
* Variant of {@link #toEntity(Class)} to decode to a list of entities.
70+
* @param <D> the entity type
71+
* @param elementType the type of elements in the list
72+
* @return the list of decoded entities, or an empty list if the field is
73+
* {@code null} but otherwise there are no errors
74+
* @throws FieldAccessException if the target field is {@code null} and the
75+
* response is not {@link GraphQlResponse#isValid() valid} or the field has
76+
* {@link ResponseField#getErrors() errors}.
77+
*/
7378
<D> List<D> toEntityList(ParameterizedTypeReference<D> elementType);
7479

7580
}

spring-graphql/src/main/java/org/springframework/graphql/client/CodecDelegate.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.graphql.client;
1718

1819
import java.util.List;
@@ -37,7 +38,6 @@
3738
* Helper class for encoding and decoding GraphQL messages.
3839
*
3940
* @author Rossen Stoyanchev
40-
* @since 1.0.0
4141
*/
4242
final class CodecDelegate {
4343

@@ -60,14 +60,14 @@ final class CodecDelegate {
6060

6161
static Encoder<?> findJsonEncoder(CodecConfigurer configurer) {
6262
return findJsonEncoder(configurer.getWriters().stream()
63-
.filter(writer -> writer instanceof EncoderHttpMessageWriter)
64-
.map(writer -> ((EncoderHttpMessageWriter<?>) writer).getEncoder()));
63+
.filter((writer) -> writer instanceof EncoderHttpMessageWriter)
64+
.map((writer) -> ((EncoderHttpMessageWriter<?>) writer).getEncoder()));
6565
}
6666

6767
static Decoder<?> findJsonDecoder(CodecConfigurer configurer) {
6868
return findJsonDecoder(configurer.getReaders().stream()
69-
.filter(reader -> reader instanceof DecoderHttpMessageReader)
70-
.map(reader -> ((DecoderHttpMessageReader<?>) reader).getDecoder()));
69+
.filter((reader) -> reader instanceof DecoderHttpMessageReader)
70+
.map((reader) -> ((DecoderHttpMessageReader<?>) reader).getDecoder()));
7171
}
7272

7373
static Encoder<?> findJsonEncoder(List<Encoder<?>> encoders) {
@@ -80,26 +80,26 @@ static Decoder<?> findJsonDecoder(List<Decoder<?>> decoders) {
8080

8181
private static Encoder<?> findJsonEncoder(Stream<Encoder<?>> stream) {
8282
return stream
83-
.filter(encoder -> encoder.canEncode(MESSAGE_TYPE, MediaType.APPLICATION_JSON))
83+
.filter((encoder) -> encoder.canEncode(MESSAGE_TYPE, MediaType.APPLICATION_JSON))
8484
.findFirst()
8585
.orElseThrow(() -> new IllegalArgumentException("No JSON Encoder"));
8686
}
8787

8888
private static Decoder<?> findJsonDecoder(Stream<Decoder<?>> decoderStream) {
8989
return decoderStream
90-
.filter(decoder -> decoder.canDecode(MESSAGE_TYPE, MediaType.APPLICATION_JSON))
90+
.filter((decoder) -> decoder.canDecode(MESSAGE_TYPE, MediaType.APPLICATION_JSON))
9191
.findFirst()
9292
.orElseThrow(() -> new IllegalArgumentException("No JSON Decoder"));
9393
}
9494

9595

96-
public CodecConfigurer getCodecConfigurer() {
96+
CodecConfigurer getCodecConfigurer() {
9797
return this.codecConfigurer;
9898
}
9999

100100

101101
@SuppressWarnings("unchecked")
102-
public <T> WebSocketMessage encode(WebSocketSession session, GraphQlWebSocketMessage message) {
102+
<T> WebSocketMessage encode(WebSocketSession session, GraphQlWebSocketMessage message) {
103103

104104
DataBuffer buffer = ((Encoder<T>) this.encoder).encodeValue(
105105
(T) message, session.bufferFactory(), MESSAGE_TYPE, MimeTypeUtils.APPLICATION_JSON, null);
@@ -108,7 +108,7 @@ public <T> WebSocketMessage encode(WebSocketSession session, GraphQlWebSocketMes
108108
}
109109

110110
@SuppressWarnings("ConstantConditions")
111-
public GraphQlWebSocketMessage decode(WebSocketMessage webSocketMessage) {
111+
GraphQlWebSocketMessage decode(WebSocketMessage webSocketMessage) {
112112
DataBuffer buffer = DataBufferUtils.retain(webSocketMessage.getPayload());
113113
return (GraphQlWebSocketMessage) this.decoder.decode(buffer, MESSAGE_TYPE, null, null);
114114
}

spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlRequest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* Default implementation of {@link ClientGraphQlRequest}.
2828
*
2929
* @author Rossen Stoyanchev
30-
* @since 1.0.0
3130
*/
3231
final class DefaultClientGraphQlRequest extends DefaultGraphQlRequest implements ClientGraphQlRequest {
3332

spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponse.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
* Default implementation of {@link ClientGraphQlResponse}.
2727
*
2828
* @author Rossen Stoyanchev
29-
* @since 1.0.0
3029
*/
3130
final class DefaultClientGraphQlResponse extends ResponseMapGraphQlResponse implements ClientGraphQlResponse {
3231

spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientResponseField.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* support for decoding.
4141
*
4242
* @author Rossen Stoyanchev
43-
* @since 1.0.0
4443
*/
4544
final class DefaultClientResponseField implements ClientResponseField {
4645

@@ -55,7 +54,7 @@ final class DefaultClientResponseField implements ClientResponseField {
5554
}
5655

5756

58-
@SuppressWarnings("deprecation")
57+
@SuppressWarnings("removal")
5958
@Override
6059
public boolean hasValue() {
6160
return (this.field.getValue() != null);
@@ -76,7 +75,7 @@ public <T> T getValue() {
7675
return this.field.getValue();
7776
}
7877

79-
@SuppressWarnings("deprecation")
78+
@SuppressWarnings("removal")
8079
@Override
8180
public ResponseError getError() {
8281
return this.field.getError();
@@ -100,13 +99,13 @@ public <D> D toEntity(ParameterizedTypeReference<D> entityType) {
10099
@Override
101100
public <D> List<D> toEntityList(Class<D> elementType) {
102101
List<D> list = toEntity(ResolvableType.forClassWithGenerics(List.class, elementType));
103-
return (list != null ? list : Collections.emptyList());
102+
return (list != null) ? list : Collections.emptyList();
104103
}
105104

106105
@Override
107106
public <D> List<D> toEntityList(ParameterizedTypeReference<D> elementType) {
108107
List<D> list = toEntity(ResolvableType.forClassWithGenerics(List.class, ResolvableType.forType(elementType)));
109-
return (list != null ? list : Collections.emptyList());
108+
return (list != null) ? list : Collections.emptyList();
110109
}
111110

112111
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)