/** * Checks if the given class has a method with the same signature, taking in to account generic types * @param targetClass * @param method * @return if it contains a method with the same signature. */ public static boolean containsPossiblyGenericMethod(Class<?> targetClass, Method method) { return extractPossiblyGenericMethod(targetClass, method) != null; }
/** * Checks if the given class has a method with the same signature, taking in to account generic types * @param targetClass * @param method * @return if it contains a method with the same signature. */ public static boolean containsPossiblyGenericMethod(Class<?> targetClass, Method method) { return extractPossiblyGenericMethod(targetClass, method) != null; }
private Object invoke(EntityViewDelegateQueryHandler delegate, EntityViewCdiQueryInvocationContext context) { try { Method extract = ClassUtils.extractPossiblyGenericMethod(delegate.getClass(), context.getMethod()); return extract.invoke(delegate, context.getMethodParameters()); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof PersistenceException) { throw (PersistenceException) e.getCause(); } throw new QueryInvocationException(e, context); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
private Object invoke(EntityViewDelegateQueryHandler delegate, EntityViewCdiQueryInvocationContext context) { try { Method extract = ClassUtils.extractPossiblyGenericMethod(delegate.getClass(), context.getMethod()); return extract.invoke(delegate, context.getMethodParameters()); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof PersistenceException) { throw (PersistenceException) e.getCause(); } throw new QueryInvocationException(e, context); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
private Object invoke(EntityViewDelegateQueryHandler delegate, EntityViewCdiQueryInvocationContext context) { try { Method extract = ClassUtils.extractPossiblyGenericMethod(delegate.getClass(), context.getMethod()); return extract.invoke(delegate, context.getMethodParameters()); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof PersistenceException) { throw (PersistenceException) e.getCause(); } throw new QueryInvocationException(e, context); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
private Object invoke(EntityViewDelegateQueryHandler delegate, EntityViewCdiQueryInvocationContext context) { try { Method extract = ClassUtils.extractPossiblyGenericMethod(delegate.getClass(), context.getMethod()); return extract.invoke(delegate, context.getMethodParameters()); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof PersistenceException) { throw (PersistenceException) e.getCause(); } throw new QueryInvocationException(e, context); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
private Object invoke(EntityViewDelegateQueryHandler delegate, EntityViewCdiQueryInvocationContext context) { try { Method extract = ClassUtils.extractPossiblyGenericMethod(delegate.getClass(), context.getMethod()); return extract.invoke(delegate, context.getMethodParameters()); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof PersistenceException) { throw (PersistenceException) e.getCause(); } throw new QueryInvocationException(e, context); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
private Object invoke(DelegateQueryHandler delegate, CdiQueryInvocationContext context) { try { Method extract = ClassUtils.extractPossiblyGenericMethod(delegate.getClass(), context.getMethod()); return extract.invoke(delegate, context.getMethodParameters()); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof PersistenceException) { throw (PersistenceException) e.getCause(); } throw new QueryInvocationException(e, context); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
@Test public void shouldRetrieveMethodBasedOnCastableType() throws Exception { Method m = InnerThree.class.getMethod("getCollection"); Method method = ClassUtils.extractPossiblyGenericMethod(InnerOne.class, m); Assert.assertEquals(InnerOne.class.getMethod("getCollection"), method); }
@Test public void shouldNotRetrieveMethodBasedOnSameReturnType() throws Exception { Method m = InnerTwo.class.getMethod("getCollection"); Method method = ClassUtils.extractPossiblyGenericMethod(InnerOne.class, m); Assert.assertEquals(InnerOne.class.getMethod("getCollection"), method); }