Biblioteca Java - Blame information for rev 32

Subversion Repositories:
Rev:
Rev Author Line No. Line
32 mihai 1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 package exempleadnotari;
7  
8 import java.lang.annotation.Annotation;
9 import java.lang.annotation.ElementType;
10 import java.lang.annotation.Retention;
11 import java.lang.annotation.RetentionPolicy;
12 import java.lang.annotation.Target;
13 import java.lang.reflect.Method;
14  
15 /**
16  *
17  * @author Mihai Hulea mihai.hulea@aut.utcluj.ro
18  */
19 @Owner(
20     value = "546",
21     name="User",
22     age=37,
23     newNames={"Alin", "Dan"}
24 )
25 public class ExempleAdnotari {
26  
27     public static void displayOwnerDetails() throws Exception{
28         for (Annotation annotation : ExempleAdnotari.class.getAnnotations()) {
29             Class<?> type = annotation.annotationType();
30             System.out.println("Values of " + type.getName());
31  
32             for (Method method : type.getDeclaredMethods()) {
33                 System.out.println(" " + method.getName() + ": " +
34                                          method.invoke(annotation, null));
35             }
36         }
37  
38     }
39  
40     /**
41      * @param args the command line arguments
42      */
43     public static void main(String[] args) throws Exception {
44         ExempleAdnotari.displayOwnerDetails();
45     }
46  
47 }
48  
49 @Retention(RetentionPolicy.RUNTIME)
50 @Target({ElementType.TYPE})
51 @interface Owner {
52     String   value() default "";
53     String   name();
54     int      age();
55     String[] newNames();
56 }