1 | |
package org.apache.onami.autobind.annotations; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
import static org.apache.onami.autobind.annotations.To.Type.INTERFACES; |
21 | |
import static org.apache.onami.autobind.jsr330.Names.named; |
22 | |
|
23 | |
import java.lang.annotation.Annotation; |
24 | |
import java.lang.reflect.Array; |
25 | |
|
26 | |
import javax.inject.Named; |
27 | |
|
28 | |
import org.apache.onami.autobind.annotations.To.Type; |
29 | |
|
30 | |
public class Annotations |
31 | |
{ |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
protected Annotations() |
37 | 0 | { |
38 | |
|
39 | 0 | } |
40 | |
|
41 | |
public static Bind createBind() |
42 | |
{ |
43 | 0 | return createBind( INTERFACES ); |
44 | |
} |
45 | |
|
46 | |
public static Bind createBind( final Type type ) |
47 | |
{ |
48 | 0 | return new Bind() |
49 | 0 | { |
50 | |
|
51 | |
@Override |
52 | |
public Class<? extends Annotation> annotationType() |
53 | |
{ |
54 | 0 | return Bind.class; |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
public Named value() |
59 | |
{ |
60 | 0 | return named( "" ); |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
public AnnotatedWith annotatedWith() { |
65 | 0 | return null; |
66 | |
} |
67 | |
|
68 | |
@Override |
69 | |
public To to() |
70 | |
{ |
71 | 0 | return createTo( type ); |
72 | |
} |
73 | |
|
74 | |
@Override |
75 | |
public boolean multiple() |
76 | |
{ |
77 | 0 | return false; |
78 | |
} |
79 | |
|
80 | |
}; |
81 | |
} |
82 | |
|
83 | |
@SuppressWarnings("unchecked") |
84 | |
public static AnnotatedWith createAnnotatedWith( ) |
85 | |
{ |
86 | 0 | return createAnnotatedWith( (Class<? super Annotation>[]) Array.newInstance(Annotation.class, 0) ); |
87 | |
} |
88 | |
|
89 | |
public static AnnotatedWith createAnnotatedWith( final Class<? super Annotation>... annotations ) |
90 | |
{ |
91 | 0 | return new AnnotatedWith() |
92 | 0 | { |
93 | |
|
94 | |
@Override |
95 | |
public Class<? extends Annotation> annotationType() |
96 | |
{ |
97 | 0 | return AnnotatedWith.class; |
98 | |
} |
99 | |
|
100 | |
@Override |
101 | |
public Class<? super Annotation>[] value() |
102 | |
{ |
103 | 0 | return annotations; |
104 | |
} |
105 | |
|
106 | |
}; |
107 | |
} |
108 | |
|
109 | |
public static To createTo() |
110 | |
{ |
111 | 0 | return createTo( INTERFACES ); |
112 | |
} |
113 | |
|
114 | |
public static To createTo( final Type type ) |
115 | |
{ |
116 | 0 | return new To() |
117 | 0 | { |
118 | |
|
119 | |
@Override |
120 | |
public Class<? extends Annotation> annotationType() |
121 | |
{ |
122 | 0 | return To.class; |
123 | |
} |
124 | |
|
125 | |
@Override |
126 | |
public Type value() |
127 | |
{ |
128 | 0 | return type; |
129 | |
} |
130 | |
|
131 | |
@Override |
132 | |
public Class<? extends Object>[] customs() |
133 | |
{ |
134 | 0 | return new Class<?>[0]; |
135 | |
} |
136 | |
|
137 | |
}; |
138 | |
} |
139 | |
|
140 | |
} |