Browse Source

Remove group stuff as only one argument is ever faked

tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
1b169985c8

+ 4
- 11
src/com/dmdirc/parser/irc/callbacks/CallbackObject.java View File

31
 import java.lang.reflect.InvocationTargetException;
31
 import java.lang.reflect.InvocationTargetException;
32
 import java.lang.reflect.Method;
32
 import java.lang.reflect.Method;
33
 import java.util.ArrayList;
33
 import java.util.ArrayList;
34
-import java.util.Arrays;
35
 import java.util.HashMap;
34
 import java.util.HashMap;
36
 import java.util.List;
35
 import java.util.List;
37
 import java.util.Map;
36
 import java.util.Map;
180
             for (Annotation ann : anns) {
179
             for (Annotation ann : anns) {
181
                 if (ann.annotationType().equals(FakableArgument.class)
180
                 if (ann.annotationType().equals(FakableArgument.class)
182
                         && args[i] == null) {
181
                         && args[i] == null) {
183
-                    args[i] = getFakeArg(args,
184
-                            type.getMethods()[0].getParameterTypes()[i],
185
-                            ((FakableArgument) ann).group());
182
+                    args[i] = getFakeArg(args, type.getMethods()[0].getParameterTypes()[i]);
186
                 }
183
                 }
187
             }
184
             }
188
 
185
 
193
     /**
190
     /**
194
      * Tries to create fake argument of the specified target class, by using
191
      * Tries to create fake argument of the specified target class, by using
195
      * {@link FakableSource} denoted parameters from the specified arg array.
192
      * {@link FakableSource} denoted parameters from the specified arg array.
196
-     * Parameters are only used if their groups value contains the specified
197
-     * group.
198
      *
193
      *
199
      * If an argument is missing, the method attempts to create a fake instance
194
      * If an argument is missing, the method attempts to create a fake instance
200
      * by recursing into this method again. Note that this could cause an
195
      * by recursing into this method again. Note that this could cause an
206
      *
201
      *
207
      * @param args The arguments array to use for sources
202
      * @param args The arguments array to use for sources
208
      * @param target The class that should be constructed
203
      * @param target The class that should be constructed
209
-     * @param group The group of arguments to use
210
      * @return An instance of the target class, or null on failure
204
      * @return An instance of the target class, or null on failure
211
      */
205
      */
212
-    protected Object getFakeArg(final Object[] args, final Class<?> target, final String group) {
206
+    protected Object getFakeArg(final Object[] args, final Class<?> target) {
213
         final Map<Class, Object> sources = new HashMap<Class, Object>();
207
         final Map<Class, Object> sources = new HashMap<Class, Object>();
214
         int i = 0;
208
         int i = 0;
215
 
209
 
216
         for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
210
         for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
217
             for (Annotation ann : anns) {
211
             for (Annotation ann : anns) {
218
-                if (ann.annotationType().equals(FakableSource.class)
219
-                        && Arrays.asList(((FakableSource) ann).group()).contains(group)) {
212
+                if (ann.annotationType().equals(FakableSource.class)) {
220
                     sources.put(type.getMethods()[0].getParameterTypes()[i], args[i]);
213
                     sources.put(type.getMethods()[0].getParameterTypes()[i], args[i]);
221
                 }
214
                 }
222
             }
215
             }
234
             for (Class<?> needed : ctor.getParameterTypes()) {
227
             for (Class<?> needed : ctor.getParameterTypes()) {
235
                 if (sources.containsKey(needed)) {
228
                 if (sources.containsKey(needed)) {
236
                     params[i] = sources.get(needed);
229
                     params[i] = sources.get(needed);
237
-                } else if ((param = getFakeArg(args, needed, group)) != null) {
230
+                } else if ((param = getFakeArg(args, needed)) != null) {
238
                     params[i] = param;
231
                     params[i] = param;
239
                 } else {
232
                 } else {
240
                     failed = true;
233
                     failed = true;

+ 0
- 8
src/com/dmdirc/parser/irc/callbacks/FakableArgument.java View File

37
 @Target(ElementType.PARAMETER)
37
 @Target(ElementType.PARAMETER)
38
 public @interface FakableArgument {
38
 public @interface FakableArgument {
39
 
39
 
40
-    /**
41
-     * A group name used to differentiate between multiple fakable arguments
42
-     * in the same method.
43
-     *
44
-     * @return The name of the group for multiple fakable arguments
45
-     */
46
-    String group() default "default";
47
-
48
 }
40
 }

+ 0
- 8
src/com/dmdirc/parser/irc/callbacks/FakableSource.java View File

38
 @Target(ElementType.PARAMETER)
38
 @Target(ElementType.PARAMETER)
39
 public @interface FakableSource {
39
 public @interface FakableSource {
40
 
40
 
41
-    /**
42
-     * A group name used to differentiate between multiple fakable arguments
43
-     * in the same method.
44
-     *
45
-     * @return The name of the groups for multiple fakable arguments
46
-     */
47
-    String[] group() default {"default"};
48
-
49
 }
41
 }

Loading…
Cancel
Save