ProblemAdapterFactory implements TypeAdapterFactory { public ProblemAdapterFactory registerSubtype( final URI uri, final Class<? extends Problem> type) { return registerSubType(uri, TypeToken.get(type)); } ProblemAdapterFactory(); @SafeVarargs <E extends Enum<?> & StatusType> ProblemAdapterFactory(
            final Class<? extends E>... statusTypes); private  ProblemAdapterFactory(
            final boolean stackTraces,
            final StatusTypeAdapter statusAdapter,
            final Map<URI, TypeToken<? extends Problem>> subtypes); ProblemAdapterFactory withStackTraces(); ProblemAdapterFactory withStackTraces(final boolean stackTraces); ProblemAdapterFactory registerSubtype(
            final URI uri, final Class<? extends Problem> type); ProblemAdapterFactory registerSubType(
            final URI uri, final TypeToken<? extends Problem> type); @Override @SuppressWarnings("unchecked") TypeAdapter<T> create(final Gson gson, final TypeToken<T> type);  }
@SuppressWarnings("ResultOfMethodCallIgnored") @Test void shouldNotThrowForDuplicateSubtype() { assertDoesNotThrow(() -> { ProblemAdapterFactory factory = new ProblemAdapterFactory(); factory.registerSubtype(OutOfStockException.TYPE, OutOfStockException.class) .registerSubtype(InsufficientFundsProblem.TYPE, OutOfStockException.class); }); }
@SuppressWarnings("ResultOfMethodCallIgnored") @Test void shouldThrowForDuplicateURI() { assertThrows(IllegalArgumentException.class, () -> { ProblemAdapterFactory factory = new ProblemAdapterFactory(); factory.registerSubtype(OutOfStockException.TYPE, OutOfStockException.class) .registerSubtype(OutOfStockException.TYPE, InsufficientFundsProblem.class); }); }