Skip to content

Commit 5da51c3

Browse files
committed
code format
1 parent 0256c85 commit 5da51c3

File tree

4 files changed

+79
-31
lines changed

4 files changed

+79
-31
lines changed

extension/src/main/java/com/alibaba/fastjson2/support/retrofit/Retrofit2ConverterFactory.java

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,21 @@ public static Retrofit2ConverterFactory create(FastJsonConfig fastJsonConfig) {
4747
}
4848

4949
@Override
50-
public Converter<ResponseBody, Object> responseBodyConverter(Type type, //
51-
Annotation[] annotations, //
52-
Retrofit retrofit) {
50+
public Converter<ResponseBody, Object> responseBodyConverter(
51+
Type type,
52+
Annotation[] annotations,
53+
Retrofit retrofit
54+
) {
5355
return new ResponseBodyConverter<Object>(type);
5456
}
5557

5658
@Override
57-
public Converter<Object, RequestBody> requestBodyConverter(Type type, //
58-
Annotation[] parameterAnnotations, //
59-
Annotation[] methodAnnotations, //
60-
Retrofit retrofit) {
59+
public Converter<Object, RequestBody> requestBodyConverter(
60+
Type type,
61+
Annotation[] parameterAnnotations,
62+
Annotation[] methodAnnotations,
63+
Retrofit retrofit
64+
) {
6165
return new RequestBodyConverter<Object>();
6266
}
6367

@@ -82,9 +86,21 @@ final class ResponseBodyConverter<T>
8286
public T convert(ResponseBody value) throws IOException {
8387
try {
8488
if (config.isJSONB()) {
85-
return JSONB.parseObject(value.bytes(), type, config.getSymbolTable(), config.getReaderFilters(), config.getReaderFeatures());
89+
return JSONB.parseObject(
90+
value.bytes(),
91+
type,
92+
config.getSymbolTable(),
93+
config.getReaderFilters(),
94+
config.getReaderFeatures()
95+
);
8696
} else {
87-
return JSON.parseObject(value.bytes(), type, config.getDateFormat(), config.getReaderFilters(), config.getReaderFeatures());
97+
return JSON.parseObject(
98+
value.bytes(),
99+
type,
100+
config.getDateFormat(),
101+
config.getReaderFilters(),
102+
config.getReaderFeatures()
103+
);
88104
}
89105
} catch (Exception e) {
90106
throw new IOException("JSON parse error: " + e.getMessage(), e);
@@ -104,9 +120,19 @@ public RequestBody convert(T value) throws IOException {
104120
try {
105121
byte[] content;
106122
if (config.isJSONB()) {
107-
content = JSONB.toBytes(value, config.getSymbolTable(), config.getWriterFilters(), config.getWriterFeatures());
123+
content = JSONB.toBytes(
124+
value,
125+
config.getSymbolTable(),
126+
config.getWriterFilters(),
127+
config.getWriterFeatures()
128+
);
108129
} else {
109-
content = JSON.toJSONBytes(value, config.getDateFormat(), config.getWriterFilters(), config.getWriterFeatures());
130+
content = JSON.toJSONBytes(
131+
value,
132+
config.getDateFormat(),
133+
config.getWriterFilters(),
134+
config.getWriterFeatures()
135+
);
110136
}
111137
return RequestBody.create(MEDIA_TYPE, content);
112138
} catch (Exception e) {

fastjson1-compatible/src/main/java/com/alibaba/fastjson/support/retrofit/Retrofit2ConverterFactory.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ public static Retrofit2ConverterFactory create(FastJsonConfig fastJsonConfig) {
4848
}
4949

5050
@Override
51-
public Converter<ResponseBody, Object> responseBodyConverter(Type type, //
52-
Annotation[] annotations, //
53-
Retrofit retrofit) {
51+
public Converter<ResponseBody, Object> responseBodyConverter(
52+
Type type,
53+
Annotation[] annotations,
54+
Retrofit retrofit) {
5455
return new ResponseBodyConverter<Object>(type);
5556
}
5657

5758
@Override
58-
public Converter<Object, RequestBody> requestBodyConverter(Type type, //
59-
Annotation[] parameterAnnotations, //
60-
Annotation[] methodAnnotations, //
61-
Retrofit retrofit) {
59+
public Converter<Object, RequestBody> requestBodyConverter(
60+
Type type,
61+
Annotation[] parameterAnnotations,
62+
Annotation[] methodAnnotations,
63+
Retrofit retrofit) {
6264
return new RequestBodyConverter<Object>();
6365
}
6466

fastjson1-compatible/src/main/java/com/alibaba/fastjson/support/spring/FastJsonHttpMessageConverter.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,29 @@ public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
7676
}
7777

7878
@Override
79-
public Object read(Type type, //
80-
Class<?> contextClass, //
81-
HttpInputMessage inputMessage //
79+
public Object read(
80+
Type type,
81+
Class<?> contextClass,
82+
HttpInputMessage inputMessage
8283
) throws IOException, HttpMessageNotReadableException {
8384
return readType(getType(type, contextClass), inputMessage);
8485
}
8586

8687
@Override
87-
public void write(Object o, Type type, MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
88+
public void write(
89+
Object o,
90+
Type type,
91+
MediaType contentType,
92+
HttpOutputMessage outputMessage
93+
) throws IOException, HttpMessageNotWritableException {
8894
// support StreamingHttpOutputMessage in spring4.0+
8995
super.write(o, contentType, outputMessage);
9096
}
9197

9298
@Override
93-
protected Object readInternal(Class<?> clazz, //
94-
HttpInputMessage inputMessage //
99+
protected Object readInternal(
100+
Class<?> clazz,
101+
HttpInputMessage inputMessage
95102
) throws IOException, HttpMessageNotReadableException {
96103
return readType(getType(clazz, null), inputMessage);
97104
}
@@ -122,11 +129,18 @@ private Object readType(Type type, HttpInputMessage inputMessage) {
122129
}
123130

124131
@Override
125-
protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
132+
protected void writeInternal(
133+
Object object,
134+
HttpOutputMessage outputMessage
135+
) throws IOException, HttpMessageNotWritableException {
126136
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
127137
HttpHeaders headers = outputMessage.getHeaders();
128138

129-
int len = JSON.writeJSONString(baos, object, fastJsonConfig.getSerializeFilters(), fastJsonConfig.getSerializerFeatures());
139+
int len = JSON.writeJSONString(
140+
baos, object,
141+
fastJsonConfig.getSerializeFilters(),
142+
fastJsonConfig.getSerializerFeatures()
143+
);
130144

131145
if (headers.getContentLength() < 0 && fastJsonConfig.isWriteContentLength()) {
132146
headers.setContentLength(len);
@@ -167,7 +181,10 @@ private static Type getType(Type type, Class<?> contextClass) {
167181
if (contextClass != null) {
168182
ResolvableType resolvedType = ResolvableType.forType(type);
169183
if (type instanceof TypeVariable) {
170-
ResolvableType resolvedTypeVariable = resolveVariable((TypeVariable) type, ResolvableType.forClass(contextClass));
184+
ResolvableType resolvedTypeVariable = resolveVariable(
185+
(TypeVariable) type,
186+
ResolvableType.forClass(contextClass)
187+
);
171188
if (resolvedTypeVariable != ResolvableType.NONE) {
172189
return resolvedTypeVariable.resolve();
173190
}
@@ -179,7 +196,10 @@ private static Type getType(Type type, Class<?> contextClass) {
179196
for (int i = 0; i < typeArguments.length; ++i) {
180197
Type typeArgument = typeArguments[i];
181198
if (typeArgument instanceof TypeVariable) {
182-
ResolvableType resolvedTypeArgument = resolveVariable((TypeVariable) typeArgument, ResolvableType.forClass(contextClass));
199+
ResolvableType resolvedTypeArgument = resolveVariable(
200+
(TypeVariable) typeArgument,
201+
ResolvableType.forClass(contextClass)
202+
);
183203
if (resolvedTypeArgument != ResolvableType.NONE) {
184204
generics[i] = resolvedTypeArgument.resolve();
185205
} else {

fastjson1-compatible/src/main/java/com/alibaba/fastjson/support/spring/FastJsonRedisSerializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public void setFastJsonConfig(FastJsonConfig fastJsonConfig) {
3333
}
3434

3535
@Override
36-
public byte[] serialize(T t) throws SerializationException {
37-
if (t == null) {
36+
public byte[] serialize(T type) throws SerializationException {
37+
if (type == null) {
3838
return new byte[0];
3939
}
4040
try {
41-
return JSON.toJSONBytes(t, fastJsonConfig.getSerializeFilters(), fastJsonConfig.getSerializerFeatures());
41+
return JSON.toJSONBytes(type, fastJsonConfig.getSerializeFilters(), fastJsonConfig.getSerializerFeatures());
4242
} catch (Exception ex) {
4343
throw new SerializationException("Could not serialize: " + ex.getMessage(), ex);
4444
}

0 commit comments

Comments
 (0)