@SuppressWarnings("unused") @Test void testConvertThrowsExceptionForResponseOfDifferentArrayType() { QueryResponseInterface[] testResponse = new QueryResponseInterface[]{new QueryResponseInterface() { }}; assertThrows(Exception.class, () -> testSubject.convert(testResponse)); }
@SuppressWarnings("unchecked") @Override public List<R> convert(Object response) { Class<?> responseType = response.getClass(); if (isArrayOfExpectedType(responseType)) { return Arrays.asList((R[]) response); } else if (isIterableOfExpectedType(response)) { return convertToList((Iterable) response); } throw new IllegalArgumentException("Retrieved response [" + responseType + "] is not convertible to a List of " + "the expected response type [" + expectedResponseType + "]"); }
MultipleInstancesResponseType extends AbstractResponseType<List<R>> { @SuppressWarnings("unchecked") @Override public List<R> convert(Object response) { Class<?> responseType = response.getClass(); if (isArrayOfExpectedType(responseType)) { return Arrays.asList((R[]) response); } else if (isIterableOfExpectedType(response)) { return convertToList((Iterable) response); } throw new IllegalArgumentException("Retrieved response [" + responseType + "] is not convertible to a List of " + "the expected response type [" + expectedResponseType + "]"); } }
MultipleInstancesResponseType extends AbstractResponseType<List<R>> { @SuppressWarnings("unchecked") @Override public List<R> convert(Object response) { Class<?> responseType = response.getClass(); if (isArrayOfExpectedType(responseType)) { return Arrays.asList((R[]) response); } else if (isIterableOfExpectedType(response)) { return convertToList((Iterable) response); } throw new IllegalArgumentException("Retrieved response [" + responseType + "] is not convertible to a List of " + "the expected response type [" + expectedResponseType + "]"); } @JsonCreator @ConstructorProperties({"expectedResponseType"})  MultipleInstancesResponseType(@JsonProperty("expectedResponseType") Class<R> expectedCollectionGenericType); }
MultipleInstancesResponseType extends AbstractResponseType<List<R>> { @SuppressWarnings("unchecked") @Override public List<R> convert(Object response) { Class<?> responseType = response.getClass(); if (isArrayOfExpectedType(responseType)) { return Arrays.asList((R[]) response); } else if (isIterableOfExpectedType(response)) { return convertToList((Iterable) response); } throw new IllegalArgumentException("Retrieved response [" + responseType + "] is not convertible to a List of " + "the expected response type [" + expectedResponseType + "]"); } @JsonCreator @ConstructorProperties({"expectedResponseType"})  MultipleInstancesResponseType(@JsonProperty("expectedResponseType") Class<R> expectedCollectionGenericType); @Override boolean matches(Type responseType); @SuppressWarnings("unchecked") // Suppress cast to array R, since in proper use of this function it is allowed @Override List<R> convert(Object response); @SuppressWarnings("unchecked") @Override Class responseMessagePayloadType(); @Override String toString(); }
MultipleInstancesResponseType extends AbstractResponseType<List<R>> { @SuppressWarnings("unchecked") @Override public List<R> convert(Object response) { Class<?> responseType = response.getClass(); if (isArrayOfExpectedType(responseType)) { return Arrays.asList((R[]) response); } else if (isIterableOfExpectedType(response)) { return convertToList((Iterable) response); } throw new IllegalArgumentException("Retrieved response [" + responseType + "] is not convertible to a List of " + "the expected response type [" + expectedResponseType + "]"); } @JsonCreator @ConstructorProperties({"expectedResponseType"})  MultipleInstancesResponseType(@JsonProperty("expectedResponseType") Class<R> expectedCollectionGenericType); @Override boolean matches(Type responseType); @SuppressWarnings("unchecked") // Suppress cast to array R, since in proper use of this function it is allowed @Override List<R> convert(Object response); @SuppressWarnings("unchecked") @Override Class responseMessagePayloadType(); @Override String toString();  }