import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ClassPreamble {
String author();
for (Class<?> cl : packageClasses) {
ClassPreamble classPreamble = cl.getAnnotation(ClassPreamble.class);
- if (classPreamble == null)
+ if (classPreamble == null) {
System.out.println("No annotation for " + cl.getName());
continue;
-
- //System.out.println("Annotation date = " + classPreamble.date());
+ }
+ System.out.println(cl.getName() + " class annotation date = " + classPreamble.date());
}
}
}
--- /dev/null
+import java.util.Comparator;
+
+class IStrComparator implements Comparator<String> {
+ private String wordToCompare;
+
+ IStrComparator(String w) {
+ wordToCompare = w;
+ }
+
+ public int compare(String str1, String str2) {
+ return str1.compareTo(str2);
+ }
+
+}
* @param String[] args main() function arguments array
*/
public static void main(String[] args) {
+ //TreeMap<String, Integer> tm = new TreeMap<String, Integer>(new StrComparator());
+ // default TreeMap comparator keep alphabetical order
TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
File f = new File("test_file.txt");
try {
# NAME = Camilo Juan
CLASSES = \
+ StrComparator.java \
+ IStrComparator.java \
Main.java
#
--- /dev/null
+import java.util.Comparator;
+
+class StrComparator implements Comparator<String> {
+
+ public int compare(String str1, String str2) {
+ return str1.compareTo(str2);
+ }
+
+}