MCPcopy
hub / github.com/google/gson / getDelegateAdapter

Method getDelegateAdapter

gson/src/main/java/com/google/gson/Gson.java:451–480  ·  view source on GitHub ↗

This method is used to get an alternate type adapter for the specified type. This is used to access a type adapter that is overridden by a {@link TypeAdapterFactory} that you may have registered. This feature is typically used when you want to register a type adapter that does a little bit of work b

(TypeAdapterFactory skipPast, TypeToken<T> type)

Source from the content-addressed store, hash-verified

449 * @since 2.2
450 */
451 public <T> TypeAdapter<T> getDelegateAdapter(TypeAdapterFactory skipPast, TypeToken<T> type) {
452 Objects.requireNonNull(skipPast, "skipPast must not be null");
453 Objects.requireNonNull(type, "type must not be null");
454
455 if (jsonAdapterFactory.isClassJsonAdapterFactory(type, skipPast)) {
456 skipPast = jsonAdapterFactory;
457 }
458
459 boolean skipPastFound = false;
460 for (TypeAdapterFactory factory : factories) {
461 if (!skipPastFound) {
462 if (factory == skipPast) {
463 skipPastFound = true;
464 }
465 continue;
466 }
467
468 TypeAdapter<T> candidate = factory.create(this, type);
469 if (candidate != null) {
470 return candidate;
471 }
472 }
473
474 if (skipPastFound) {
475 throw new IllegalArgumentException("GSON cannot serialize or deserialize " + type);
476 } else {
477 // Probably a factory from @JsonAdapter on a field
478 return getAdapter(type);
479 }
480 }
481
482 /**
483 * This method serializes the specified object into its equivalent representation as a tree of

Callers 14

createMethod · 0.80
createMethod · 0.80
delegateMethod · 0.80
createMethod · 0.80
createMethod · 0.80
createMethod · 0.80
createMethod · 0.80
delegateMethod · 0.80
delegateMethod · 0.80
delegateMethod · 0.80
createMethod · 0.80

Calls 3

getAdapterMethod · 0.95
createMethod · 0.65

Tested by 9

createMethod · 0.64
createMethod · 0.64
delegateMethod · 0.64
createMethod · 0.64
createMethod · 0.64
createMethod · 0.64
createMethod · 0.64
delegateMethod · 0.64