@Test void testOptionalMatchesExpectedType() throws NoSuchMethodException { Method methodToTest = methodOf(getClass(), "someOptionalQueryResponse"); Type methodReturnType = methodToTest.getGenericReturnType(); assertEquals(Boolean.TRUE, ResponseTypes.instanceOf(QueryResponse.class).matches(methodReturnType)); }
@Override public boolean matches(Type responseType) { Type unwrapped = ReflectionUtils.unwrapIfType(responseType, Future.class, Optional.class); return isGenericAssignableFrom(unwrapped) || isAssignableFrom(unwrapped); }
OptionalResponseType extends AbstractResponseType<Optional<R>> { @Override public boolean matches(Type responseType) { Type unwrapped = ReflectionUtils.unwrapIfType(responseType, Future.class, Optional.class); return isGenericAssignableFrom(unwrapped) || isAssignableFrom(unwrapped); } }
OptionalResponseType extends AbstractResponseType<Optional<R>> { @Override public boolean matches(Type responseType) { Type unwrapped = ReflectionUtils.unwrapIfType(responseType, Future.class, Optional.class); return isGenericAssignableFrom(unwrapped) || isAssignableFrom(unwrapped); } @JsonCreator @ConstructorProperties({"expectedResponseType"})  OptionalResponseType(@JsonProperty("expectedResponseType") Class<R> expectedResponseType); }
OptionalResponseType extends AbstractResponseType<Optional<R>> { @Override public boolean matches(Type responseType) { Type unwrapped = ReflectionUtils.unwrapIfType(responseType, Future.class, Optional.class); return isGenericAssignableFrom(unwrapped) || isAssignableFrom(unwrapped); } @JsonCreator @ConstructorProperties({"expectedResponseType"})  OptionalResponseType(@JsonProperty("expectedResponseType") Class<R> expectedResponseType); @Override boolean matches(Type responseType); @SuppressWarnings("unchecked") @Override Optional<R> convert(Object response); @SuppressWarnings("unchecked") @Override Class responseMessagePayloadType(); @Override ResponseType<?> forSerialization(); @Override String toString(); }
OptionalResponseType extends AbstractResponseType<Optional<R>> { @Override public boolean matches(Type responseType) { Type unwrapped = ReflectionUtils.unwrapIfType(responseType, Future.class, Optional.class); return isGenericAssignableFrom(unwrapped) || isAssignableFrom(unwrapped); } @JsonCreator @ConstructorProperties({"expectedResponseType"})  OptionalResponseType(@JsonProperty("expectedResponseType") Class<R> expectedResponseType); @Override boolean matches(Type responseType); @SuppressWarnings("unchecked") @Override Optional<R> convert(Object response); @SuppressWarnings("unchecked") @Override Class responseMessagePayloadType(); @Override ResponseType<?> forSerialization(); @Override String toString();  }