Skip to content

Commit 40aae12

Browse files
committed
Format and remove extra public modifier
1 parent ba6d6d6 commit 40aae12

File tree

1 file changed

+50
-68
lines changed

1 file changed

+50
-68
lines changed

http-client/src/main/java/io/avaje/http/client/Jackson3BodyAdapter.java

Lines changed: 50 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -41,98 +41,80 @@ public Jackson3BodyAdapter() {
4141
@SuppressWarnings("unchecked")
4242
@Override
4343
public <T> BodyWriter<T> beanWriter(Class<?> cls) {
44-
return (BodyWriter<T>)
45-
beanWriterCache.computeIfAbsent(
46-
cls,
47-
aClass -> {
48-
try {
49-
return new JWriter<>(mapper.writerFor(cls));
50-
} catch (Exception e) {
51-
throw new RuntimeException(e);
52-
}
53-
});
44+
return (BodyWriter<T>) beanWriterCache.computeIfAbsent(cls, aClass -> {
45+
try {
46+
return new JWriter<>(mapper.writerFor(cls));
47+
} catch (Exception e) {
48+
throw new RuntimeException(e);
49+
}
50+
});
5451
}
5552

5653
@SuppressWarnings("unchecked")
5754
@Override
5855
public <T> BodyReader<T> beanReader(Class<T> cls) {
59-
return (BodyReader<T>)
60-
beanReaderCache.computeIfAbsent(
61-
cls,
62-
aClass -> {
63-
try {
64-
return new JReader<>(mapper.readerFor(cls));
65-
} catch (Exception e) {
66-
throw new RuntimeException(e);
67-
}
68-
});
56+
return (BodyReader<T>) beanReaderCache.computeIfAbsent(cls, aClass -> {
57+
try {
58+
return new JReader<>(mapper.readerFor(cls));
59+
} catch (Exception e) {
60+
throw new RuntimeException(e);
61+
}
62+
});
6963
}
7064

7165
@SuppressWarnings("unchecked")
7266
@Override
7367
public <T> BodyWriter<T> beanWriter(Type cls) {
74-
return (BodyWriter<T>)
75-
beanWriterCache.computeIfAbsent(
76-
cls,
77-
aClass -> {
78-
try {
79-
return new JWriter<>(mapper.writerFor(mapper.getTypeFactory().constructType(cls)));
80-
} catch (Exception e) {
81-
throw new RuntimeException(e);
82-
}
83-
});
68+
return (BodyWriter<T>) beanWriterCache.computeIfAbsent(cls, aClass -> {
69+
try {
70+
return new JWriter<>(mapper.writerFor(mapper.getTypeFactory().constructType(cls)));
71+
} catch (Exception e) {
72+
throw new RuntimeException(e);
73+
}
74+
});
8475
}
8576

8677
@SuppressWarnings("unchecked")
8778
@Override
8879
public <T> BodyReader<T> beanReader(Type cls) {
89-
return (BodyReader<T>)
90-
beanReaderCache.computeIfAbsent(
91-
cls,
92-
aClass -> {
93-
try {
94-
return new JReader<>(mapper.readerFor(mapper.getTypeFactory().constructType(cls)));
95-
} catch (Exception e) {
96-
throw new RuntimeException(e);
97-
}
98-
});
80+
return (BodyReader<T>) beanReaderCache.computeIfAbsent(cls, aClass -> {
81+
try {
82+
return new JReader<>(mapper.readerFor(mapper.getTypeFactory().constructType(cls)));
83+
} catch (Exception e) {
84+
throw new RuntimeException(e);
85+
}
86+
});
9987
}
10088

10189
@SuppressWarnings("unchecked")
10290
@Override
10391
public <T> BodyReader<List<T>> listReader(Class<T> cls) {
104-
return (BodyReader<List<T>>)
105-
listReaderCache.computeIfAbsent(
106-
cls,
107-
aClass -> {
108-
try {
109-
final CollectionType collectionType =
110-
mapper.getTypeFactory().constructCollectionType(List.class, cls);
111-
final ObjectReader reader = mapper.readerFor(collectionType);
112-
return new JReader<>(reader);
113-
} catch (Exception e) {
114-
throw new RuntimeException(e);
115-
}
116-
});
92+
return (BodyReader<List<T>>) listReaderCache.computeIfAbsent(cls, aClass -> {
93+
try {
94+
final CollectionType collectionType =
95+
mapper.getTypeFactory().constructCollectionType(List.class, cls);
96+
final ObjectReader reader = mapper.readerFor(collectionType);
97+
return new JReader<>(reader);
98+
} catch (Exception e) {
99+
throw new RuntimeException(e);
100+
}
101+
});
117102
}
118103

119104
@SuppressWarnings("unchecked")
120105
@Override
121106
public <T> BodyReader<List<T>> listReader(Type type) {
122-
return (BodyReader<List<T>>)
123-
listReaderCache.computeIfAbsent(
124-
type,
125-
aType -> {
126-
try {
127-
var javaType = mapper.getTypeFactory().constructType(aType);
128-
final CollectionType collectionType =
129-
mapper.getTypeFactory().constructCollectionType(List.class, javaType);
130-
final ObjectReader reader = mapper.readerFor(collectionType);
131-
return new JReader<>(reader);
132-
} catch (Exception e) {
133-
throw new RuntimeException(e);
134-
}
135-
});
107+
return (BodyReader<List<T>>) listReaderCache.computeIfAbsent(type, aType -> {
108+
try {
109+
var javaType = mapper.getTypeFactory().constructType(aType);
110+
final CollectionType collectionType =
111+
mapper.getTypeFactory().constructCollectionType(List.class, javaType);
112+
final ObjectReader reader = mapper.readerFor(collectionType);
113+
return new JReader<>(reader);
114+
} catch (Exception e) {
115+
throw new RuntimeException(e);
116+
}
117+
});
136118
}
137119

138120
private static final class JReader<T> implements BodyReader<T> {
@@ -158,7 +140,7 @@ private static final class JWriter<T> implements BodyWriter<T> {
158140

159141
private final ObjectWriter writer;
160142

161-
public JWriter(ObjectWriter writer) {
143+
JWriter(ObjectWriter writer) {
162144
this.writer = writer;
163145
}
164146

0 commit comments

Comments
 (0)