/** * Find constructor info * * @param classInfo the class info * @param paramTypes the parameter types * @return the constructor info * @throws JoinpointException when no such constructor */ public static ConstructorInfo findConstructorInfo(ClassInfo classInfo, String[] paramTypes) throws JoinpointException { ConstructorInfo[] constructors = classInfo.getDeclaredConstructors(); if (constructors != null) { for (ConstructorInfo constructor : constructors) { if (equals(paramTypes, constructor.getParameterTypes())) return constructor; } throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " in " + Arrays.asList(constructors)); } throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " no constructors"); }
/** * Find constructor info * * @param classInfo the class info * @param paramTypes the parameter types * @return the constructor info * @throws JoinpointException when no such constructor */ public static ConstructorInfo findConstructorInfo(ClassInfo classInfo, String[] paramTypes) throws JoinpointException { ConstructorInfo[] constructors = classInfo.getDeclaredConstructors(); if (constructors != null) { for (int i = 0; i < constructors.length; ++i) { if (equals(paramTypes, constructors[i].getParameterTypes())) return constructors[i]; } throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " in " + Arrays.asList(constructors)); } throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " no constructors"); }
/** * Find method info * * @param classInfo the class info * @param name the method name * @param paramTypes the parameter types * @param isStatic must the method be static * @param isPublic must the method be public * @param strict is strict about method modifiers * @return the method info * @throws JoinpointException when no such method */ public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws JoinpointException { if (classInfo == null) throw new IllegalArgumentException("ClassInfo cannot be null!"); if (paramTypes == null) paramTypes = NO_PARAMS_TYPES; ClassInfo current = classInfo; while (current != null) { MethodInfo result = locateMethodInfo(current, name, paramTypes, isStatic, isPublic, strict); if (result != null) return result; current = current.getSuperclass(); } throw new JoinpointException("Method not found " + name + Arrays.asList(paramTypes) + " for class " + classInfo.getName()); }
/** * Find method info * * @param classInfo the class info * @param name the method name * @param paramTypes the parameter types * @param isStatic must the method be static * @param isPublic must the method be public * @param strict is strict about method modifiers * @return the method info * @throws JoinpointException when no such method */ public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws JoinpointException { if (name == null) throw new IllegalArgumentException("Null name"); if (classInfo == null) throw new IllegalArgumentException("ClassInfo cannot be null!"); if (paramTypes == null) paramTypes = NO_PARAMS_TYPES; ClassInfo current = classInfo; while (current != null) { MethodInfo result = locateMethodInfo(current, name, paramTypes, isStatic, isPublic, strict); if (result != null) return result; current = current.getSuperclass(); } throw new JoinpointException("Method not found " + name + Arrays.asList(paramTypes) + " for class " + classInfo.getName()); }
/** * Find field info * * @param classInfo the class info * @param name the field name * @return the field info * @throws JoinpointException when no such field */ public static FieldInfo findFieldInfo(ClassInfo classInfo, String name) throws JoinpointException { if (classInfo == null) throw new IllegalArgumentException("ClassInfo cannot be null!"); ClassInfo current = classInfo; while (current != null) { FieldInfo result = locateFieldInfo(current, name); if (result != null) return result; current = current.getSuperclass(); } throw new JoinpointException("Field not found '" + name + "' for class " + classInfo.getName()); }
/** * Find field info * * @param classInfo the class info * @param name the field name * @return the field info * @throws JoinpointException when no such field */ public static FieldInfo findFieldInfo(ClassInfo classInfo, String name) throws JoinpointException { if (classInfo == null) throw new IllegalArgumentException("ClassInfo cannot be null!"); ClassInfo current = classInfo; while (current != null) { FieldInfo result = locateFieldInfo(current, name); if (result != null) return result; current = current.getSuperclass(); } throw new JoinpointException("Field not found '" + name + "' for class " + classInfo.getName()); }
throw new JoinpointException("Property " + name + " not found for " + info);