You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*Note that there are some breaking changes with Reflections 0.10+, along with performance improvements and more functional API. Migration is encouraged and should be easy though.*
Creating Reflections instance requires [ConfigurationBuilder](https://ronmamo.github.io/reflections/org/reflections/util/ConfigurationBuilder.html), typically configured with packages and [Scanners](https://ronmamo.github.io/reflections/org/reflections/scanners/Scanners.html) to use:
50
60
51
61
```java
52
-
// scan for:
53
-
// urls in classpath that contain 'com.my.project' package
54
-
// filter types starting with 'com.my.project'
55
-
// use the default scanners SubTypes and TypesAnnotated
62
+
// typical usage: scan package with the default scanners SubTypes, TypesAnnotated
***Scanners must be configured in order to be queried, otherwise an empty result is returned.**
78
-
If not specified, default scanners are `SubTypes` and `TypesAnnotated`. For all standard [Scanners](https://ronmamo.github.io/reflections/org/reflections/scanners/Scanners.html) use `Scanners.values()`[(src)](src/main/java/org/reflections/scanners/Scanners.java).
79
-
***All relevant URLs should be configured.**
88
+
***Scanner must be configured in order to be queried, otherwise an empty result is returned**
89
+
If not specified, default scanners will be used SubTypes, TypesAnnotated.
90
+
For all standard scanners use `Scanners.values()`. See more scanners in the source [package](https://ronmamo.github.io/reflections/org/reflections/scanners).
91
+
***All relevant URLs should be configured**
92
+
Consider `.filterInputsBy()` in case too many classes are scanned.
80
93
If required, Reflections will [expand super types](https://ronmamo.github.io/reflections/org/reflections/Reflections.html#expandSuperTypes(java.util.Map)) in order to get the transitive closure metadata without scanning large 3rd party urls.
81
-
Consider adding inputs filter in case too many classes are scanned.
82
94
* Classloader can optionally be used for resolving runtime classes from names.
83
95
84
96
### Query
85
97
Once Reflections was instantiated and scanning was successful, it can be used for querying the indexed metadata.
86
-
Standard [Scanners](https://ronmamo.github.io/reflections/org/reflections/scanners/Scanners.html) are provided for query using `reflections.get()`, for example:
*Previous ReflectionUtils 0.9.x API is still supported though marked for removal, more info in the javadocs.*
195
205
196
-
## QueryBuilder and QueryFunction
206
+
## Query API
197
207
Each Scanner and ReflectionUtils function implements [QueryBuilder](https://ronmamo.github.io/reflections/org/reflections/util/QueryBuilder.html), and supports:
198
208
*`get()` - function returns direct values
199
209
*`with()` or `of()` - function returns all transitive values
@@ -206,21 +216,19 @@ Next, each function implements [QueryFunction](https://ronmamo.github.io/reflect
206
216
and provides fluent functional interface for composing `filter()`, `map()`, `flatMap()`, `as()` and more, such that:
@@ -256,11 +264,11 @@ Check the [tests](src/test/java/org/reflections) folder for more examples and AP
256
264
257
265
### What else?
258
266
-**Integrating with build lifecycle**
259
-
It is sometime useful to save the scanned metadata into xml/json as part of the build lifecycle for generating resources,
267
+
It is sometime useful to `Reflections.save()` the scanned metadata into xml/json as part of the build lifecycle for generating resources,
260
268
and then collect it on bootstrap with `Reflections.collect()` and avoid scanning. *See [reflections-maven](https://github.com/ronmamo/reflections-maven/) for example*.
261
269
-[JavaCodeSerializer](https://ronmamo.github.io/reflections/org/reflections/serializers/JavaCodeSerializer.html) - scanned metadata can be persisted into a generated Java source code.
262
270
Although less common, it can be useful for accessing types and members in a strongly typed manner. *(see [example](src/test/java/org/reflections/MyTestModelStore.java))*
263
-
-[AnnotationMergeCollector](https://ronmamo.github.io/reflections/org/reflections/util/AnnotationMergeCollector.html) - can be used to merge similar annotations, for example for finding effective REST controller endpoints. *(see [test](src/test/java/org/reflections/ReflectionUtilsQueryTest.java#L216))*
271
+
-[AnnotationMergeCollector](https://ronmamo.github.io/reflections/org/reflections/util/AnnotationMergeCollector.html) - can be used to merge similar annotations. *(see [test](src/test/java/org/reflections/ReflectionUtilsQueryTest.java#L216))*
264
272
-`MemberUsageScanner` - experimental scanner allow querying for member usages `getMemberUsages()` of packages/types/elements in the classpath.
265
273
Can be used for finding usages between packages, layers, modules, types etc.
0 commit comments