private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); // Get the superclass's overriden method annotations if (superClass != null) { fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass( superClass) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get the superinterfaces' overriden method annotations for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass(c) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get its own annotations. They have preference to inherited annotations. for (final Annotation annotation : getMethod().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
/** * @param result map of classes to annotations * @param baseClass is the superclass or one of the superinterfaces. */ private void fillAnnotationsForOneClass(final HashMap<Class<?>, Annotation> result, final Class<?> baseClass) { addAnnotations(result, AnnotationManager.getAnnotatedClass(baseClass).getAllAnnotations()); }
if(annotatedClass.getAnnotation(Dao.class) == null) { throw new AnnotationNotFoundException("The class '"+ daoClass.getName() +"' isn't annotated with the '"+ Dao.class.getName() +"' annotation. Only class annotated with that annotation can be used as annotated DAO."); AnnotatedMethod[] annotatedMethods = annotatedClass.getAnnotatedMethods(); for(final AnnotatedMethod method : annotatedMethods) { if(method.getAllAnnotations().length > 0) {
/** * */ private void analyzeParameters() { final AnnotatedMethod aMethod = AnnotationManager.getAnnotatedClass(method.getDeclaringClass()).getAnnotatedMethod(method); final Annotation[][] parameterAnnotations = aMethod.getParameterAnnotations(); int parameterSize = aMethod.getMethod().getParameterTypes().length; for(int i = 0; i < parameterAnnotations.length; i++) { for(final Annotation annotation : parameterAnnotations[i]) { if(Param.class.equals(annotation.annotationType())) { namedParameters = true; final Param param = (Param) annotation; final String name = param.value().trim(); if(name.length() == 0) { throw new RuntimeException("Illegal empty parameter value encounterd on parameter " + i + " of method '" + method + "' from class '" + method.getDeclaringClass().getName() +"'."); } if(parameterPositions == null) { parameterPositions = new HashMap<String, Integer>(); } parameterPositions.put(param.value(), i); break; } } } if(namedParameters && parameterPositions.size() != parameterSize) { throw new RuntimeException("Not all the parameters of the method '" + method.getDeclaringClass().getName() + "." + method + "' are annotated with the '" + Param.class.getName() + "' annotation." + " All the parameters of the method need to be have the '" + Param.class.getName() + "' annotation when using the annotation on a method."); } }
if(annotatedClass.isAnnotationPresent(org.milyn.scribe.annotation.Dao.class)) {
if(annotatedClass.getAnnotation(Dao.class) == null) { throw new AnnotationNotFoundException("The class '"+ daoClass.getName() +"' isn't annotated with the '"+ Dao.class.getName() +"' annotation. Only class annotated with that annotation can be used as annotated DAO."); AnnotatedMethod[] annotatedMethods = annotatedClass.getAnnotatedMethods(); for(final AnnotatedMethod method : annotatedMethods) { if(method.getAllAnnotations().length > 0) {
/** * */ private void analyzeParameters() { final AnnotatedMethod aMethod = AnnotationManager.getAnnotatedClass(method.getDeclaringClass()).getAnnotatedMethod(method); final Annotation[][] parameterAnnotations = aMethod.getParameterAnnotations(); int parameterSize = aMethod.getMethod().getParameterTypes().length; for(int i = 0; i < parameterAnnotations.length; i++) { for(final Annotation annotation : parameterAnnotations[i]) { if(Param.class.equals(annotation.annotationType())) { namedParameters = true; final Param param = (Param) annotation; final String name = param.value().trim(); if(name.length() == 0) { throw new RuntimeException("Illegal empty parameter value encounterd on parameter " + i + " of method '" + method + "' from class '" + method.getDeclaringClass().getName() +"'."); } if(parameterPositions == null) { parameterPositions = new HashMap<String, Integer>(); } parameterPositions.put(param.value(), i); break; } } } if(namedParameters && parameterPositions.size() != parameterSize) { throw new RuntimeException("Not all the parameters of the method '" + method.getDeclaringClass().getName() + "." + method + "' are annotated with the '" + Param.class.getName() + "' annotation." + " All the parameters of the method need to be have the '" + Param.class.getName() + "' annotation when using the annotation on a method."); } }
if(annotatedClass.isAnnotationPresent(org.milyn.scribe.annotation.Dao.class)) {
private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); // Get the superclass's overriden method annotations if (superClass != null) { fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass( superClass) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get the superinterfaces' overriden method annotations for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass(c) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get its own annotations. They have preference to inherited annotations. for (final Annotation annotation : getMethod().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
/** * @param result map of classes to annotations * @param baseClass is the superclass or one of the superinterfaces. */ private void fillAnnotationsForOneClass(final HashMap<Class<?>, Annotation> result, final Class<?> baseClass) { addAnnotations(result, AnnotationManager.getAnnotatedClass(baseClass).getAllAnnotations()); }
private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); // Get the superclass's overriden method annotations if (superClass != null) { fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass( superClass) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get the superinterfaces' overriden method annotations for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass(c) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get its own annotations. They have preference to inherited annotations. for (final Annotation annotation : getMethod().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
/** * @param result map of classes to annotations * @param baseClass is the superclass or one of the superinterfaces. */ private void fillAnnotationsForOneClass(final HashMap<Class<?>, Annotation> result, final Class<?> baseClass) { addAnnotations(result, AnnotationManager.getAnnotatedClass(baseClass).getAllAnnotations()); }
final Map<Class<?>, Annotation>[] mapResult = new Map[method.getParameterAnnotations().length]; final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); if (superClass != null) { final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes());
final Map<Class<?>, Annotation>[] mapResult = new Map[method.getParameterAnnotations().length]; final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); if (superClass != null) { final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes());
final Map<Class<?>, Annotation>[] mapResult = new Map[method.getParameterAnnotations().length]; final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); if (superClass != null) { final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes());