OperationUtil { public static ValidationResult isValid(final Class<?> output, final Class<?> input) { ValidationResult result = new ValidationResult(); if (null != input && null != output && !UnknownGenericType.class.equals(output) && !UnknownGenericType.class.equals(input) && !input.isAssignableFrom(output)) { result.addError("Incompatible output, input types. " + output + ": " + output.getName() + ", input: " + input.getName()); } return result; } private  OperationUtil(); static Class<?> getInputType(final Input input); static Class<?> getInputType(final Class<? extends Input> input); static Class<?> getOutputType(final Output output); static Class<?> getOutputType(final Class<? extends Output> output); static ValidationResult isValid(final Class<?> output, final Class<?> input);  }
@Test public void shouldValidateOutputInputTypes() { assertTrue(OperationUtil.isValid(Iterable.class, Iterable.class).isValid()); assertTrue(OperationUtil.isValid(CloseableIterable.class, Iterable.class).isValid()); assertTrue(OperationUtil.isValid(Iterable.class, Object.class).isValid()); assertTrue(OperationUtil.isValid(OperationUtil.UnknownGenericType.class, Object.class).isValid()); assertTrue(OperationUtil.isValid(Object.class, OperationUtil.UnknownGenericType.class).isValid()); assertTrue(OperationUtil.isValid(OperationUtil.UnknownGenericType.class, OperationUtil.UnknownGenericType.class).isValid()); assertFalse(OperationUtil.isValid(Object.class, CloseableIterable.class).isValid()); }