2015-09-07 11:44:36 -06:00
|
|
|
// annotations/UseCaseTracker.java
|
2015-12-15 11:47:04 -08:00
|
|
|
// (c)2016 MindView LLC: see Copyright.txt
|
2015-11-15 15:51:35 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
|
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
2015-06-15 17:47:35 -07:00
|
|
|
import java.lang.reflect.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
public class UseCaseTracker {
|
|
|
|
public static void
|
|
|
|
trackUseCases(List<Integer> useCases, Class<?> cl) {
|
|
|
|
for(Method m : cl.getDeclaredMethods()) {
|
|
|
|
UseCase uc = m.getAnnotation(UseCase.class);
|
|
|
|
if(uc != null) {
|
|
|
|
System.out.println("Found Use Case:" + uc.id() +
|
|
|
|
" " + uc.description());
|
|
|
|
useCases.remove(new Integer(uc.id()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i : useCases) {
|
2016-01-25 18:05:55 -08:00
|
|
|
System.out.println(
|
|
|
|
"Warning: Missing use case-" + i);
|
2015-06-15 17:47:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void main(String[] args) {
|
2015-11-03 12:00:44 -08:00
|
|
|
// <* Can't use Arrays.asList() for some reason *>
|
2015-06-15 17:47:35 -07:00
|
|
|
List<Integer> useCases = new ArrayList<>();
|
|
|
|
Collections.addAll(useCases, 47, 48, 49, 50);
|
|
|
|
trackUseCases(useCases, PasswordUtils.class);
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
}
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
Found Use Case:49 New passwords can't equal previously used
|
|
|
|
ones
|
|
|
|
Found Use Case:47 Passwords must contain at least one
|
|
|
|
numeric
|
|
|
|
Found Use Case:48 no description
|
|
|
|
Warning: Missing use case-50
|
2015-09-07 11:44:36 -06:00
|
|
|
*/
|