/** * The Java compiler generates something like OuterClass$InnerClass * as name for the inner class. So if a name contains a '$' it is * probably an inner class. * * @param jp the jp * * @return true if joinpoint belongs to an inner class */ public static boolean isInnerClass(JoinPoint jp) { return isInnerClass(jp.getSignature()); }
/** * The Java compiler generates something like OuterClass$InnerClass as name * for the inner class. So if a name contains a '$' it is probably an inner * class. * * @param jp * the jp * * @return true if joinpoint belongs to an inner class */ public static boolean isInnerClass(final JoinPoint jp) { return isInnerClass(jp.getSignature()); }
/** * Normally you get an annotation array with the size of the constructor * parameters. But not for inner classes. Here the first parameter of the * constructor is the embedded class. In this case we must correct the * annotation array * * @param ctorSig * @return */ @MayReturnNull private static Annotation[][] getParameterAnnotations(ConstructorSignature ctorSig) { Constructor<?> ctor = ctorSig.getConstructor(); Annotation[][] annotations = ctor.getParameterAnnotations(); if (isInnerClass(ctorSig)) { Annotation[][] corrected = new Annotation[annotations.length+1][0]; corrected[0] = null; System.arraycopy(annotations, 0, corrected, 1, annotations.length); return corrected; } return annotations; }
/** * Normally you get an annotation array with the size of the constructor * parameters. But not for inner classes. Here the first parameter of the * constructor is the embedded class. In this case we must correct the * annotation array * * @param ctorSig * @return */ @MayReturnNull private static Annotation[][] getParameterAnnotations(final ConstructorSignature ctorSig) { Constructor<?> ctor = ctorSig.getConstructor(); Annotation[][] annotations = ctor.getParameterAnnotations(); if (isInnerClass(ctorSig)) { Annotation[][] corrected = new Annotation[annotations.length + 1][0]; corrected[0] = null; System.arraycopy(annotations, 0, corrected, 1, annotations.length); return corrected; } return annotations; }