/** * @param method */ private void analyzeFindByMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Lookup findByAnnotation = aMethod.getAnnotation(Lookup.class); String name = findByAnnotation.name(); if(name.trim().length() == 0) { name = method.getName(); } assertUniqueName(lookupWithNamedParameters, Lookup.class, name); if(void.class.equals(method.getReturnType())){ throw new IllegalAnnotationUsageException("The FindBy annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' " + "returns void, which isn't allowed. The method must return something."); } lookupWithNamedParameters.put(name, new LookupMethod(method)); }
/** * @param method */ private void analyzeFindByMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Lookup findByAnnotation = aMethod.getAnnotation(Lookup.class); String name = findByAnnotation.name(); if(name.trim().length() == 0) { name = method.getName(); } assertUniqueName(lookupWithNamedParameters, Lookup.class, name); if(void.class.equals(method.getReturnType())){ throw new IllegalAnnotationUsageException("The FindBy annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' " + "returns void, which isn't allowed. The method must return something."); } lookupWithNamedParameters.put(name, new LookupMethod(method)); }
/** * @param method */ private void analyzeInsertMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Insert annotation = aMethod.getAnnotation(Insert.class); String name = annotation.name(); if(name.length() == 0) { name = method.getName(); } assertUniqueName(insertMethods, Insert.class, name); if(annotation.isDefault() && defaultInsertMethod != null) { throw new IllegalAnnotationUsageException("At least two methods are annotated with the '"+ Insert.class.getName() +"'annotation having the isDefault on true. Only one method per class is allowed to be the default insert method."); } if(method.getParameterTypes().length == 0) { throw new IllegalAnnotationUsageException("The Insert annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' doesn't have any parameters."); } if(method.getParameterTypes().length > 1) { throw new IllegalAnnotationUsageException("The Insert annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' has more then 1 parameter, which isn't allowed."); } boolean returnsEntity = !method.isAnnotationPresent(ReturnsNoEntity.class); EntityMethod insertMethod = new EntityMethod(method, returnsEntity); if(annotation.isDefault()) { defaultInsertMethod = insertMethod; } insertMethods.put(name, insertMethod); }
/** * @param method */ private void analyzeDeleteMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Delete annotation = aMethod.getAnnotation(Delete.class); String name = annotation.name(); if(name.length() == 0) { name = method.getName(); } assertUniqueName(deleteMethods, Delete.class, name); if(annotation.isDefault() && defaultDeleteMethod != null) { throw new IllegalAnnotationUsageException("At least two methods are annotated with the '"+ Delete.class.getName() +"' annotation having the isDefault on true. Only one method per class is allowed to be the default delete method."); } if(method.getParameterTypes().length == 0) { throw new IllegalAnnotationUsageException("The Delete annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' doesn't have a parameter, which it needs."); } if(method.getParameterTypes().length > 1) { throw new IllegalAnnotationUsageException("The Delete annotated method '"+ method +"' the DAO class '"+ daoClass.getName() +"' has more then 1 parameter, which isn't allowed."); } boolean returnsEntity = !method.isAnnotationPresent(ReturnsNoEntity.class); EntityMethod deleteMethod = new EntityMethod(method, returnsEntity); if(annotation.isDefault()) { defaultDeleteMethod = deleteMethod; } deleteMethods.put(name, deleteMethod); }
/** * @param method */ private void analyzeDeleteMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Delete annotation = aMethod.getAnnotation(Delete.class); String name = annotation.name(); if(name.length() == 0) { name = method.getName(); } assertUniqueName(deleteMethods, Delete.class, name); if(annotation.isDefault() && defaultDeleteMethod != null) { throw new IllegalAnnotationUsageException("At least two methods are annotated with the '"+ Delete.class.getName() +"' annotation having the isDefault on true. Only one method per class is allowed to be the default delete method."); } if(method.getParameterTypes().length == 0) { throw new IllegalAnnotationUsageException("The Delete annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' doesn't have a parameter, which it needs."); } if(method.getParameterTypes().length > 1) { throw new IllegalAnnotationUsageException("The Delete annotated method '"+ method +"' the DAO class '"+ daoClass.getName() +"' has more then 1 parameter, which isn't allowed."); } boolean returnsEntity = !method.isAnnotationPresent(ReturnsNoEntity.class); EntityMethod deleteMethod = new EntityMethod(method, returnsEntity); if(annotation.isDefault()) { defaultDeleteMethod = deleteMethod; } deleteMethods.put(name, deleteMethod); }
/** * @param method */ private void analyzeUpdateMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Update annotation = aMethod.getAnnotation(Update.class); String name = annotation.name(); if(name.length() == 0) { name = method.getName(); } assertUniqueName(updateMethods, Update.class, name); if(annotation.isDefault() && defaultUpdateMethod != null) { throw new IllegalAnnotationUsageException("At least two methods are annotated with the '"+ Update.class.getName() +"' having the isDefault on true. Only one method per class is allowed to be the default update method."); } if(method.getParameterTypes().length == 0) { throw new IllegalAnnotationUsageException("The Update annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' doesn't have any parameters."); } if(method.getParameterTypes().length > 1) { throw new IllegalAnnotationUsageException("The Update annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' has more then 1 parameter, which isn't allowed."); } boolean returnsEntity = !method.isAnnotationPresent(ReturnsNoEntity.class); EntityMethod updateMethod = new EntityMethod(method, returnsEntity); if(annotation.isDefault()) { defaultUpdateMethod = updateMethod; } updateMethods.put(name, updateMethod); }
/** * @param method */ private void analyzeUpdateMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Update annotation = aMethod.getAnnotation(Update.class); String name = annotation.name(); if(name.length() == 0) { name = method.getName(); } assertUniqueName(updateMethods, Update.class, name); if(annotation.isDefault() && defaultUpdateMethod != null) { throw new IllegalAnnotationUsageException("At least two methods are annotated with the '"+ Update.class.getName() +"' having the isDefault on true. Only one method per class is allowed to be the default update method."); } if(method.getParameterTypes().length == 0) { throw new IllegalAnnotationUsageException("The Update annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' doesn't have any parameters."); } if(method.getParameterTypes().length > 1) { throw new IllegalAnnotationUsageException("The Update annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' has more then 1 parameter, which isn't allowed."); } boolean returnsEntity = !method.isAnnotationPresent(ReturnsNoEntity.class); EntityMethod updateMethod = new EntityMethod(method, returnsEntity); if(annotation.isDefault()) { defaultUpdateMethod = updateMethod; } updateMethods.put(name, updateMethod); }
/** * @param method */ private void analyzeInsertMethod(final AnnotatedMethod aMethod) { Method method = aMethod.getMethod(); Insert annotation = aMethod.getAnnotation(Insert.class); String name = annotation.name(); if(name.length() == 0) { name = method.getName(); } assertUniqueName(insertMethods, Insert.class, name); if(annotation.isDefault() && defaultInsertMethod != null) { throw new IllegalAnnotationUsageException("At least two methods are annotated with the '"+ Insert.class.getName() +"'annotation having the isDefault on true. Only one method per class is allowed to be the default insert method."); } if(method.getParameterTypes().length == 0) { throw new IllegalAnnotationUsageException("The Insert annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' doesn't have any parameters."); } if(method.getParameterTypes().length > 1) { throw new IllegalAnnotationUsageException("The Insert annotated method '"+ method +"' of the DAO class '"+ daoClass.getName() +"' has more then 1 parameter, which isn't allowed."); } boolean returnsEntity = !method.isAnnotationPresent(ReturnsNoEntity.class); EntityMethod insertMethod = new EntityMethod(method, returnsEntity); if(annotation.isDefault()) { defaultInsertMethod = insertMethod; } insertMethods.put(name, insertMethod); }