public int compare(AnnotatedCallable<? super T> arg0, AnnotatedCallable<? super T> arg1) { // compare the names first int result = (arg0.getJavaMember().getName().compareTo(arg1.getJavaMember().getName())); if (result != 0) { return result; } result = arg0.getJavaMember().getDeclaringClass().getName().compareTo(arg1.getJavaMember() .getDeclaringClass().getName()); if (result != 0) { return result; } result = arg0.getParameters().size() - arg1.getParameters().size(); return result; }
/** * Generates a deterministic signature for an {@link AnnotatedCallable}. Two * <code>AnnotatedCallable</code>s that have the same annotations and * underlying callable will generate the same signature. */ public static <X> String createCallableId(AnnotatedCallable<X> method) { StringBuilder builder = new StringBuilder(); builder.append(method.getJavaMember().getDeclaringClass().getName()); builder.append('.'); builder.append(method.getJavaMember().getName()); builder.append(createAnnotationCollectionId(method.getAnnotations())); builder.append(createParameterListId(method.getParameters())); return builder.toString(); }
/** * <p> * Compare {@link AnnotatedCallable}s for equality. * </p> * <p/> * <p> * Two {@link AnnotatedCallable}s are considered equal if they have the same * underlying callable and annotations. * </p> */ public static boolean compareAnnotatedCallable(AnnotatedCallable<?> m1, AnnotatedCallable<?> m2) { if (!m1.getJavaMember().equals(m2.getJavaMember())) { return false; } if (!compareAnnotated(m1, m2)) { return false; } return compareAnnotatedParameters(m1.getParameters(), m2.getParameters()); }
private static <X> boolean hasMethodParameters(AnnotatedCallable<X> callable) { for (AnnotatedParameter<X> parameter : callable.getParameters()) { if (!parameter.getAnnotations().isEmpty()) { return true; } } return false; }
/** * Constructor */ public AnnotatedParameterImpl(AnnotatedCallable<X> declaringCallable, Class<?> type, int position, AnnotationStore annotations, Type genericType, Type typeOverride) { super(type, annotations, genericType, typeOverride); this.declaringCallable = declaringCallable; this.position = position; }
@Override public AnnotatedCallable<X> getDeclaringCallable() { return null; }
@Override public AnnotatedCallable<Object> getDeclaringCallable() { return null; }
/** * {@inheritDoc} */ @Override public AnnotatedCallable<X> getDeclaringCallable() { return declaringCallable; }