1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.tinyjee.maven.dim.extensions;
18
19 import com.thoughtworks.qdox.model.*;
20 import org.apache.maven.doxia.logging.Log;
21 import org.codehaus.plexus.util.FileUtils;
22 import org.tinyjee.maven.dim.spi.Globals;
23 import org.tinyjee.maven.dim.utils.AbstractAliasHandler;
24 import org.tinyjee.maven.dim.utils.JavaClassLoader;
25 import org.tinyjee.maven.dim.utils.PrintableMap;
26 import org.tinyjee.maven.dim.utils.SelectableJavaEntitiesList;
27
28 import java.io.File;
29 import java.io.IOException;
30 import java.net.URISyntaxException;
31 import java.net.URL;
32 import java.util.*;
33
34 import static java.lang.Boolean.parseBoolean;
35 import static java.lang.String.valueOf;
36 import static java.util.Collections.emptyMap;
37 import static org.tinyjee.maven.dim.spi.ResourceResolver.findAllSources;
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 public class JavaSourceLoader extends HashMap<String, Object> {
84
85 private static final long serialVersionUID = -4069212921446859127L;
86
87 private static final String JAVA_EXT = ".java";
88
89
90
91
92 public static class AliasHandler extends AbstractAliasHandler {
93
94
95
96
97 public AliasHandler() {
98 super(PARAM_ALIAS, PARAM_JAVA_SOURCE, JavaSourceLoader.class.getName());
99 }
100 }
101
102
103
104
105
106
107
108
109 public static final String PARAM_ALIAS = "source-java";
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 public static final String PARAM_JAVA_SOURCE = "java-source";
131
132
133
134
135
136
137
138
139 public static final String PARAM_API_DOCS = "apidocs";
140
141
142
143
144
145
146 public static final String PARAM_OVERWRITE = "overwrite";
147
148
149
150
151
152 public static final String OUT_PARAM_NAME = "name";
153
154
155
156
157 public static final String OUT_PARAM_SIMPLE_NAME = "simpleName";
158
159
160
161
162
163 public static final String OUT_PARAM_CLASS = "class";
164
165
166
167
168
169 public static final String OUT_PARAM_JAVA_CLASS = "javaClass";
170
171
172
173
174
175
176
177
178
179 public static final String OUT_PARAM_SELECTOR = "select";
180
181
182
183
184 public static final String OUT_PARAM_COMMENT = "comment";
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 public static final String OUT_PARAM_TAGS = "tags";
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222 public static final String OUT_PARAM_ANNOTATIONS = "annotations";
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 public static final String OUT_PARAM_FIELDS = "fields";
238
239
240
241
242 public static final String OUT_PARAM_FIELDS_MAP = "fieldsMap";
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257 public static final String OUT_PARAM_DECLARED_FIELDS = "declaredFields";
258
259
260
261
262 public static final String OUT_PARAM_DECLARED_FIELDS_MAP = "declaredFieldsMap";
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277 public static final String OUT_PARAM_CONSTANTS = "constants";
278
279
280
281
282 public static final String OUT_PARAM_CONSTANTS_MAP = "constantsMap";
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297 public static final String OUT_PARAM_DECLARED_CONSTANTS = "declaredConstants";
298
299
300
301
302 public static final String OUT_PARAM_DECLARED_CONSTANTS_MAP = "declaredConstantsMap";
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325 public static final String OUT_PARAM_PROPERTIES = "properties";
326
327
328
329
330 public static final String OUT_PARAM_PROPERTIES_MAP = "propertiesMap";
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346 public static final String OUT_PARAM_INTERFACE_METHODS = "interfaceMethods";
347
348
349
350
351 public static final String OUT_PARAM_INTERFACE_METHODS_MAP = "interfaceMethodsMap";
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367 public static final String OUT_PARAM_METHODS = "methods";
368
369
370
371
372 public static final String OUT_PARAM_METHODS_MAP = "methodsMap";
373
374
375
376
377
378 public interface Selector {
379
380
381
382
383
384 SelectableMappedJavaEntitiesList getPackageClasses();
385
386
387
388
389
390
391 SelectableMappedJavaEntitiesList getClassesBelowPackage();
392
393
394
395
396
397
398 SelectableMappedJavaEntitiesList getNestedClasses();
399
400
401
402
403
404
405 SelectableMappedJavaEntitiesList getSuperClasses();
406
407
408
409
410
411
412
413
414
415 SelectableMappedJavaEntitiesList getImplementedInterfaces();
416
417
418
419
420
421
422 SelectableMappedJavaEntitiesList getDerivedClasses();
423
424
425
426
427
428
429
430
431 SelectableMappedJavaEntitiesList getAnnotatedClasses();
432 }
433
434 JavaClass javaClass;
435 String javaDocRootPath = "./apidocs/";
436 JavaDocTagsHandler javaDocTagsHandler;
437
438
439
440
441
442
443
444 public JavaSourceLoader(File baseDir, Map<String, Object> requestParams) {
445 try {
446 final String classOrPackageName = (String) requestParams.get(PARAM_JAVA_SOURCE);
447 try {
448 final JavaSource source = getSource(baseDir, classOrPackageName);
449 init(source, requestParams);
450 } catch (IllegalArgumentException e) {
451 final JavaPackage javaPackage = getPackage(baseDir, classOrPackageName);
452 if (javaPackage == null) {
453 throw new IllegalArgumentException("'" + classOrPackageName +
454 "' doesn't seem to be a valid package name nor is it a resolveable java source.", e);
455 } else
456 init(javaPackage, requestParams);
457 }
458 } catch (IOException e) {
459 throw new RuntimeException(e);
460 }
461 }
462
463
464
465
466
467
468
469 public JavaSourceLoader(File baseDir, String className) {
470 this(baseDir, Collections.singletonMap(PARAM_JAVA_SOURCE, (Object) className));
471 }
472
473
474
475
476
477
478
479 protected JavaSourceLoader(JavaClass javaClass, Map<String, Object> requestParams) {
480 init(javaClass, requestParams);
481 }
482
483
484
485
486
487
488
489 protected final void init(JavaSource source, Map<String, Object> requestParams) {
490 Globals.getLog().debug("About to load first java class of source '" + source.getURL() + "'.");
491
492 final JavaClass[] classes = source.getClasses();
493 if (classes.length == 0)
494 throw new IllegalArgumentException("The given source '" + source.getURL() + "' did not contain a single class.");
495 JavaClass javaClass = classes[0];
496
497
498 String className = requestParams == null ? null : (String) requestParams.get(PARAM_JAVA_SOURCE);
499 if (className != null && className.contains("$")) {
500 className = className.substring(className.indexOf('$') + 1).replace('$', '.');
501 javaClass = javaClass.getNestedClassByName(className);
502 if (javaClass == null)
503 throw new IllegalArgumentException("Did not find nested class: " + className + " in " + classes[0]);
504 }
505
506 init(javaClass, requestParams);
507 }
508
509
510
511
512
513
514
515 protected final void init(final JavaClass javaClass, Map<String, Object> requestParams) {
516 final Log log = Globals.getLog();
517 final boolean debug = log.isDebugEnabled();
518 this.javaClass = javaClass;
519
520 Object overwrite = null;
521
522 if (requestParams != null) {
523 overwrite = requestParams.get(PARAM_OVERWRITE);
524 putAll(requestParams);
525 String apiDocsPath = (String) requestParams.get(PARAM_API_DOCS);
526 if (apiDocsPath != null && apiDocsPath.trim().length() != 0) javaDocRootPath = apiDocsPath;
527 }
528
529 javaDocTagsHandler = new JavaDocTagsHandler(javaClass, javaDocRootPath, requestParams);
530
531 if (debug) log.debug("About to load reflection details on class '" + javaClass.getFullyQualifiedName() + "'");
532
533 scanFieldsAndConstants(javaClass);
534 scanProperties(javaClass);
535 scanMethods(javaClass);
536
537 put(OUT_PARAM_NAME, javaClass.getFullyQualifiedName());
538 put(OUT_PARAM_SIMPLE_NAME, javaClass.getName());
539 put(OUT_PARAM_JAVA_CLASS, javaClass);
540 put(OUT_PARAM_COMMENT, javaDocTagsHandler.processJavaDocComment(javaClass.getComment()));
541 put(OUT_PARAM_ANNOTATIONS, asMap(javaClass.getAnnotations()));
542 put(OUT_PARAM_TAGS, asMap(javaClass.getTags()));
543 put(OUT_PARAM_SELECTOR, new SelectorImplementation(javaClass, javaClass.getPackage()));
544
545 if (overwrite == null) putAll(requestParams);
546
547 PrintableMap<String, Object> selfIntrospection = new PrintableMap<String, Object>(
548 this, "Reflection details on class '" + javaClass.getFullyQualifiedName() + '\'');
549 put(OUT_PARAM_CLASS, selfIntrospection);
550
551 if (debug) log.debug("Loaded: $" + OUT_PARAM_CLASS + '=' + selfIntrospection.getContentAsString());
552
553 if (overwrite != null && !parseBoolean(valueOf(overwrite))) putAll(requestParams);
554 }
555
556
557
558
559
560
561
562 protected final void init(JavaPackage javaPackage, Map<String, Object> requestParams) {
563 put(OUT_PARAM_NAME, javaPackage.getName());
564 put(OUT_PARAM_SIMPLE_NAME, javaPackage.getName());
565 put(OUT_PARAM_ANNOTATIONS, asMap(javaPackage.getAnnotations()));
566 put(OUT_PARAM_SELECTOR, new SelectorImplementation(null, javaPackage));
567 }
568
569
570
571
572
573
574
575
576
577 protected final JavaSource getSource(File baseDir, String className) throws IOException {
578 className = className.replace('.', '/');
579 if (className.contains("$"))
580 className = className.substring(0, className.indexOf('$'));
581
582 if (className.endsWith("/java"))
583 className = className.substring(0, className.length() - 5) + JAVA_EXT;
584 else if (!className.endsWith(JAVA_EXT))
585 className += JAVA_EXT;
586
587 return JavaClassLoader.getInstance().addSource(baseDir, className);
588 }
589
590
591
592
593
594
595
596
597
598 protected final JavaPackage getPackage(File baseDir, String packageName) throws IOException {
599 JavaPackage aPackage = null;
600 try {
601 for (URL packageUrl : findAllSources(baseDir, packageName.replace('.', File.separatorChar))) {
602 File packagePath = "file".equalsIgnoreCase(packageUrl.getProtocol()) ? new File(packageUrl.toURI()) : null;
603
604
605
606 if (packagePath != null && packagePath.isDirectory()) {
607 @SuppressWarnings("unchecked")
608 final List<File> files = FileUtils.getFiles(packagePath, "**/*.java", "**/package-info.java", true);
609 if (files.isEmpty()) continue;
610
611 aPackage = JavaClassLoader.getInstance().addSource(files.get(0).toURI().toURL(), false).getPackage();
612 while (aPackage != null && aPackage.getName().startsWith(packageName) && !aPackage.getName().equals(packageName))
613 aPackage = aPackage.getParentPackage();
614 }
615 }
616 } catch (IllegalArgumentException ignore) {
617 } catch (URISyntaxException e) {
618 throw new RuntimeException(e);
619 }
620 return aPackage;
621 }
622
623
624
625
626
627
628 protected void scanMethods(JavaClass javaClass) {
629 final List<Map<?, ?>> interfaceMethods = new SelectableMappedJavaEntitiesList("method");
630 put(OUT_PARAM_INTERFACE_METHODS, interfaceMethods);
631 final List<Map<?, ?>> methods = new SelectableMappedJavaEntitiesList("method");
632 put(OUT_PARAM_METHODS, methods);
633
634 for (JavaMethod method : javaClass.getMethods()) {
635 boolean nonVisibleMethod = !method.isPublic() && !method.isProtected();
636 if (nonVisibleMethod || method.isConstructor() || method.isPropertyAccessor() || method.isPropertyMutator())
637 continue;
638
639 Map<String, Map> parameterAnnotations = new PrintableMap<String, Map>("Parameter-Annotations");
640 if (method.getParameters() != null) {
641 for (JavaParameter parameter : method.getParameters())
642 parameterAnnotations.put(parameter.getName(), asMap(parameter.getAnnotations()));
643 }
644
645 Map<?, ?> row = asMap(
646 "type", typeToString(method.getReturnType()),
647 "name", method.getName(),
648 "signature", method.getCallSignature(),
649 OUT_PARAM_COMMENT, javaDocTagsHandler.processJavaDocComment(method.getComment()),
650 OUT_PARAM_TAGS, asMap(method.getTags()),
651 "method", method,
652 OUT_PARAM_ANNOTATIONS, asMap(method.getAnnotations()),
653 "parameterAnnotations", parameterAnnotations);
654
655 if (method.isAbstract())
656 interfaceMethods.add(row);
657 else
658 methods.add(row);
659 }
660
661 put(OUT_PARAM_INTERFACE_METHODS_MAP, asMap(interfaceMethods, "name"));
662 put(OUT_PARAM_METHODS_MAP, asMap(methods, "name"));
663 }
664
665
666
667
668
669
670 protected void scanProperties(JavaClass javaClass) {
671 final List<Map<?, ?>> properties = new SelectableMappedJavaEntitiesList("property");
672 put(OUT_PARAM_PROPERTIES, properties);
673
674 for (BeanProperty property : javaClass.getBeanProperties()) {
675 final JavaMethod getter = property.getAccessor();
676 final JavaMethod setter = property.getMutator();
677 final JavaField field = javaClass.getFieldByName(property.getName());
678
679 final Map<String, Map> annotations = new PrintableMap<String, Map>("Annotations");
680 if (getter != null) annotations.putAll(asMap(getter.getAnnotations()));
681 if (setter != null) annotations.putAll(asMap(setter.getAnnotations()));
682 if (field != null) annotations.putAll(asMap(field.getAnnotations()));
683
684 final Map<?, ?> row = asMap(
685 "type", typeToString(property.getType()),
686 "name", property.getName(),
687 OUT_PARAM_COMMENT, javaDocTagsHandler.processJavaDocComment(getter == null ? "" : getter.getComment() == null ?
688 (field == null ? "" : field.getComment()) : getter.getComment()),
689 OUT_PARAM_TAGS, getter == null ? field == null ? emptyMap() : asMap(field.getTags()) : asMap(getter.getTags()),
690 "setterComment", javaDocTagsHandler.processJavaDocComment(setter == null ? "" : setter.getComment()),
691 "setterTags", setter == null ? emptyMap() : asMap(setter.getTags()),
692 "property", property,
693 "getter", getter,
694 "setter", setter,
695 "field", field,
696 "value", field == null ? "" : field.getInitializationExpression(),
697 OUT_PARAM_ANNOTATIONS, annotations);
698
699 properties.add(row);
700 }
701
702 put(OUT_PARAM_PROPERTIES_MAP, asMap(properties, "name"));
703 }
704
705
706
707
708
709
710 protected void scanFieldsAndConstants(JavaClass javaClass) {
711 final List<Map<?, ?>> constants = new SelectableMappedJavaEntitiesList("field"),
712 declaredConstants = new SelectableMappedJavaEntitiesList("field");
713 put(OUT_PARAM_CONSTANTS, constants);
714 put(OUT_PARAM_DECLARED_CONSTANTS, declaredConstants);
715 final List<Map<?, ?>> fields = new SelectableMappedJavaEntitiesList("field"),
716 declaredFields = new SelectableMappedJavaEntitiesList("field");
717 put(OUT_PARAM_FIELDS, fields);
718 put(OUT_PARAM_DECLARED_FIELDS, declaredFields);
719
720 boolean classIsInterface = javaClass.isInterface();
721
722 for (JavaField field : javaClass.getFields()) {
723 boolean fieldIsConstant = classIsInterface || (field.isFinal() && field.isStatic());
724
725 Map<?, ?> row = asMap(
726 "type", typeToString(field.getType()),
727 "name", field.getName(),
728 "value", field.getInitializationExpression(),
729 OUT_PARAM_COMMENT, javaDocTagsHandler.processJavaDocComment(field.getComment()),
730 OUT_PARAM_TAGS, asMap(field.getTags()),
731 "field", field,
732 OUT_PARAM_ANNOTATIONS, asMap(field.getAnnotations()));
733
734 (fieldIsConstant ? declaredConstants : declaredFields).add(row);
735
736 if (!field.isPublic() && !field.isProtected() && !classIsInterface)
737 continue;
738
739 (fieldIsConstant ? constants : fields).add(row);
740 }
741
742 put(OUT_PARAM_CONSTANTS_MAP, asMap(constants, "name"));
743 put(OUT_PARAM_DECLARED_CONSTANTS_MAP, asMap(declaredConstants, "name"));
744 put(OUT_PARAM_FIELDS_MAP, asMap(fields, "name"));
745 put(OUT_PARAM_DECLARED_FIELDS_MAP, asMap(declaredFields, "name"));
746 }
747
748
749
750
751
752
753
754 @SuppressWarnings("unchecked")
755 protected Map<String, Object> asMap(DocletTag... tags) {
756 Map<String, Object> result = new PrintableMap<String, Object>("Doclet-Tags");
757 for (DocletTag tag : tags) {
758 Map targetMap = result;
759 String name = tag.getName(), value = tag.getValue();
760
761 if ("see".equalsIgnoreCase(name)) {
762 value = "{@link " + value + '}';
763 } else if ("param".equalsIgnoreCase(name)) {
764 if (tag.getParameters().length > 0) {
765 name = tag.getParameters()[0];
766 if (result.containsKey("param")) targetMap = (Map) result.get("param");
767 else result.put("param", targetMap = new PrintableMap<String, Object>("Method-Params-Tags"));
768 } else
769 continue;
770 }
771
772 targetMap.put(name, javaDocTagsHandler.processJavaDocComment(value));
773 }
774 return result;
775 }
776
777
778
779
780
781
782
783 protected static String typeToString(Type type) {
784 return type == null ? "" : type.toGenericString();
785 }
786
787
788
789
790
791
792
793
794 @SuppressWarnings("unchecked")
795 protected static Map<String, Map> asMap(Annotation... annotations) {
796 Map<String, Map> result = new PrintableMap<String, Map>("Annotations");
797 for (Annotation annotation : annotations) {
798 String name = annotation.getType().getFullyQualifiedName();
799 name = "@".concat(name.substring(name.lastIndexOf('.') + 1));
800
801 Map<Object, Object> map = new PrintableMap<Object, Object>("Annotation-Parameters");
802 map.putAll(annotation.getNamedParameterMap());
803 for (Map.Entry<Object, Object> entry : map.entrySet())
804 if (entry.getValue() != null)
805 entry.setValue(entry.getValue().toString().trim());
806
807 result.put(name, map);
808 }
809
810 return result;
811 }
812
813
814
815
816
817
818
819 protected static Map<Object, Object> asMap(Object... keyValuePairs) {
820 if (keyValuePairs.length % 2 != 0)
821 throw new IllegalArgumentException("The key and value input array length must be a multiple of 2.");
822
823 final Map<Object, Object> map = new PrintableMap<Object, Object>("Key-Value-Pairs"),
824 assocMap = new LinkedHashMap<Object, Object>(keyValuePairs.length / 2);
825
826 for (int i = 0; i < keyValuePairs.length; i += 2) {
827 Object key = valueOf(keyValuePairs[i]), value = keyValuePairs[i + 1];
828 map.put(i / 2, value);
829 assocMap.put(key, value);
830 }
831
832 map.putAll(assocMap);
833
834 return map;
835 }
836
837
838
839
840
841
842
843
844 protected static Map<String, Map<?, ?>> asMap(Iterable<Map<?, ?>> namedRows, String nameKey) {
845 final Map<String, Map<?, ?>> map = new PrintableMap<String, Map<?, ?>>("Named-Class-Elements");
846 for (Map<?, ?> namedRow : namedRows)
847 map.put((String) namedRow.get(nameKey), namedRow);
848
849 return map;
850 }
851
852 private class SelectorImplementation implements Selector {
853
854 private final JavaClass javaClass;
855 private final JavaPackage javaPackage;
856
857 SelectorImplementation(JavaClass javaClass, JavaPackage javaPackage) {
858 this.javaClass = javaClass;
859 this.javaPackage = javaPackage;
860 }
861
862 Map<String, Object> extractRequestParams() {
863 Map<String, Object> requestParams = new HashMap<String, Object>();
864 for (Map.Entry<String, Object> entry : entrySet()) {
865 if (entry.getKey().startsWith(PARAM_API_DOCS))
866 requestParams.put(entry.getKey(), entry.getValue());
867 }
868 return requestParams;
869 }
870
871 List<Map<String, ?>> convert(Collection<JavaClass> classes) {
872 return convert(classes.toArray(new JavaClass[classes.size()]));
873 }
874
875 List<Map<String, ?>> convert(JavaClass[] classes) {
876 Map<String, Object> requestParams = extractRequestParams();
877 final List<Map<String, ?>> sourceLoaders = new ArrayList<Map<String, ?>>(classes.length);
878 for (JavaClass aClass : classes)
879 sourceLoaders.add(new PrintableMap<String, Object>(new JavaSourceLoader(aClass, requestParams), aClass.toString()));
880 return sourceLoaders;
881 }
882
883 public SelectableMappedJavaEntitiesList getPackageClasses() {
884 final JavaClass[] classes = javaPackage == null ? new JavaClass[0] : javaPackage.getClasses();
885 return new SelectableMappedJavaEntitiesList(convert(classes), OUT_PARAM_JAVA_CLASS);
886 }
887
888 public SelectableMappedJavaEntitiesList getClassesBelowPackage() {
889 final List<JavaClass> classes = new ArrayList<JavaClass>();
890 if (javaPackage == null)
891 classes.addAll(JavaClassLoader.getInstance().getClasses());
892 else {
893 String prefix = javaPackage.getName() + '.';
894 for (JavaPackage candidate : JavaClassLoader.getInstance().getPackages()) {
895 if (candidate.equals(javaPackage) || candidate.getName().startsWith(prefix))
896 classes.addAll(Arrays.asList(candidate.getClasses()));
897 }
898 }
899
900 return new SelectableMappedJavaEntitiesList(convert(classes), OUT_PARAM_JAVA_CLASS);
901 }
902
903 public SelectableMappedJavaEntitiesList getNestedClasses() {
904 final JavaClass[] nestedClasses = javaClass == null ? new JavaClass[0] : javaClass.getNestedClasses();
905 return new SelectableMappedJavaEntitiesList(convert(nestedClasses), OUT_PARAM_JAVA_CLASS);
906 }
907
908 public SelectableMappedJavaEntitiesList getSuperClasses() {
909 final List<JavaClass> knownSuperClasses = new ArrayList<JavaClass>();
910 if (javaClass != null) {
911 for (JavaClass superClass = javaClass.getSuperJavaClass(); superClass != null; superClass = superClass.getSuperJavaClass())
912 knownSuperClasses.add(superClass);
913 }
914
915 final List<Map<String, ?>> mapList = convert(knownSuperClasses.toArray(new JavaClass[knownSuperClasses.size()]));
916 return new SelectableMappedJavaEntitiesList(mapList, OUT_PARAM_JAVA_CLASS);
917 }
918
919 public SelectableMappedJavaEntitiesList getImplementedInterfaces() {
920 final JavaClass[] interfaces = javaClass == null ? new JavaClass[0] : javaClass.getImplementedInterfaces();
921 return new SelectableMappedJavaEntitiesList(convert(interfaces), OUT_PARAM_JAVA_CLASS);
922 }
923
924 public SelectableMappedJavaEntitiesList getDerivedClasses() {
925 final JavaClass[] classes = javaClass == null ? new JavaClass[0] : javaClass.getDerivedClasses();
926 return new SelectableMappedJavaEntitiesList(convert(classes), OUT_PARAM_JAVA_CLASS);
927 }
928
929 public SelectableMappedJavaEntitiesList getAnnotatedClasses() {
930 if (!SelectableMappedJavaEntitiesList.isAnnotation(javaClass)) {
931 throw new IllegalStateException("Cannot look after classes that are annotated with '" + javaClass +
932 "' as this class is no annotation.");
933 }
934
935 final SortedSet<JavaClass> allClasses = JavaClassLoader.getInstance().getClasses();
936 final SelectableJavaEntitiesList<JavaClass> entitiesList = new SelectableJavaEntitiesList<JavaClass>(allClasses);
937 final List<Map<String, ?>> converted = convert(entitiesList.selectAnnotated('@' + javaClass.getFullyQualifiedName()));
938
939 return new SelectableMappedJavaEntitiesList(converted, OUT_PARAM_JAVA_CLASS);
940 }
941 }
942 }