MCPcopy Index your code
hub / github.com/OpenFeign/feign / enrich

Method enrich

core/src/main/java/feign/BaseBuilder.java:262–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260 }
261
262 @SuppressWarnings("unchecked")
263 B enrich() {
264 if (capabilities.isEmpty()) {
265 return thisB;
266 }
267
268 try {
269 B clone = (B) thisB.clone();
270
271 getFieldsToEnrich()
272 .forEach(
273 field -> {
274 field.setAccessible(true);
275 try {
276 final Object originalValue = field.get(clone);
277 final Object enriched;
278 if (originalValue instanceof List) {
279 Type ownerType =
280 ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0];
281 enriched =
282 ((List) originalValue)
283 .stream()
284 .map(
285 value ->
286 Capability.enrich(
287 value, (Class<?>) ownerType, capabilities))
288 .collect(Collectors.toList());
289 } else {
290 enriched = Capability.enrich(originalValue, field.getType(), capabilities);
291 }
292 field.set(clone, enriched);
293 } catch (IllegalArgumentException | IllegalAccessException e) {
294 throw new RuntimeException("Unable to enrich field " + field, e);
295 } finally {
296 field.setAccessible(false);
297 }
298 });
299
300 // enrich each request interceptor, then enrich the list as a whole
301 RequestInterceptor[] requestArray =
302 clone.requestInterceptors.toArray(new RequestInterceptor[0]);
303 for (int i = 0; i < requestArray.length; i++) {
304 requestArray[i] =
305 (RequestInterceptor)
306 Capability.enrich(requestArray[i], RequestInterceptor.class, capabilities);
307 }
308 RequestInterceptors requestInterceptors =
309 (RequestInterceptors)
310 Capability.enrich(
311 new RequestInterceptors(Arrays.asList(requestArray)),
312 RequestInterceptors.class,
313 capabilities);
314 clone.requestInterceptors = requestInterceptors.interceptors();
315
316 // enrich each response interceptor, then enrich the list as a whole
317 ResponseInterceptor[] responseArray =
318 clone.responseInterceptors.toArray(new ResponseInterceptor[0]);
319 for (int i = 0; i < responseArray.length; i++) {

Callers 1

buildMethod · 0.95

Calls 13

getFieldsToEnrichMethod · 0.95
enrichMethod · 0.95
interceptorsMethod · 0.95
interceptorsMethod · 0.95
interceptorsMethod · 0.95
isEmptyMethod · 0.80
toArrayMethod · 0.80
cloneMethod · 0.65
getMethod · 0.65
mapMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected