|
1 | 1 | ## About |
2 | 2 |
|
3 | 3 | [](https://github.com/CrissNamon/aide/actions/workflows/maven.yml) |
| 4 | +[](https://github.com/CrissNamon/aide/releases) |
| 5 | +[](https://central.sonatype.com/artifact/tech.hiddenproject/aide/1.2) |
4 | 6 |
|
5 | | -Aide is a set of useful utils to simplify your code |
| 7 | +Aide is a set of useful utils for fast reflection, extended optionals and conditionals. It can help you with development of some service or your own framework. |
6 | 8 |
|
7 | 9 | ## Content |
8 | 10 |
|
9 | | -* Reflection |
10 | | - - contains utils for reflection such as fast method invocation, annotation processing and other useful methods |
11 | | -* Optional |
12 | | - - contains extended optional classes for String, Boolean types, IfTrue and When conditionals, Object utils |
| 11 | +#### Reflection |
| 12 | + |
| 13 | +Aide reflection contains utils for reflection such as fast method invocation with lambda wrapping, annotation processing and other useful methods. |
| 14 | + |
| 15 | +Reflective method calls with Aide are simple: |
| 16 | + |
| 17 | +```java |
| 18 | +// Get LambdaWrapperHolder isntance with default LambdaWrapper interface loaded |
| 19 | +LambdaWrapperHolder lambdaWrapperHolder = LambdaWrapperHolder.DEFAULT; |
| 20 | +// Find static method |
| 21 | +Method staticMethod = ReflectionUtil.getMethod(TestClass.class, "staticMethod", String.class); |
| 22 | +// Wrap static method |
| 23 | +// LambdaWrapper - default wrapper interface from Aide |
| 24 | +// Test class - caller class |
| 25 | +// Integer - return type |
| 26 | +MethodHolder<LambdaWrapper, TestClass, Integer> staticHolder = lambdaWrapperHolder.wrapSafe(staticMethod); |
| 27 | +// Invoke static method without caller |
| 28 | +int staticResult = staticHolder.invokeStatic("Hello"); |
| 29 | +``` |
| 30 | + |
| 31 | +#### Optional |
| 32 | + |
| 33 | +Aide optional contains extended optional classes for String, Boolean types, IfTrue and When conditionals, Object utils. |
| 34 | + |
| 35 | +Extended optionals provides new methods for some types: |
| 36 | + |
| 37 | +```java |
| 38 | +BooleanOptional.of(Modifier.isPublic(executable.getModifiers())) |
| 39 | + .ifFalseThrow(() -> ReflectionException.format("Wrapping is supported for PUBLIC methods only!")); |
| 40 | +``` |
| 41 | + |
| 42 | +With conditionals you can make your code more functional. Thats how Aide reflection uses them: |
| 43 | + |
| 44 | +```java |
| 45 | +AbstractSignature signature = IfTrueConditional.create() |
| 46 | + .ifTrue(exact).then(() -> ExactMethodSignature.from(method)) |
| 47 | + .ifTrue(someObj, Objects::isNull).then(() -> new MethodSignature()) |
| 48 | + .orElseGet(() -> MethodSignature.from(method)); |
| 49 | +``` |
| 50 | + |
| 51 | +Or WhenConditional: |
| 52 | + |
| 53 | +```java |
| 54 | +WhenConditional.create() |
| 55 | + .when(someObj, Objects::nonNull).then(MyClass::nonNull) |
| 56 | + .when(someObj, Objects::isNull).then(MyClass::isNull) |
| 57 | + .orDoNothing(); |
| 58 | +``` |
13 | 59 |
|
14 | 60 | ## Use |
15 | 61 |
|
16 | 62 | Artifact ids: |
17 | 63 |
|
18 | | -- all -> aide-all |
19 | | -- reflection -> aide-reflection |
20 | | -- optional -> aide-optional |
| 64 | +- `tech.hiddenproject:aide-all` - all components |
| 65 | +- `tech.hiddenproject:aide-optional` - optionals and conditionals |
| 66 | +- `tech.hiddenproject:aide-reflection` - reflection utils |
21 | 67 |
|
22 | 68 | ### Maven |
23 | 69 |
|
24 | 70 | ```xml |
25 | 71 | <dependency> |
26 | 72 | <groupId>tech.hiddenproject</groupId> |
27 | 73 | <artifactId>aide-all</artifactId> |
28 | | - <version>1.1</version> |
| 74 | + <version>1.2</version> |
29 | 75 | </dependency> |
30 | 76 | ``` |
31 | 77 |
|
32 | 78 | ### Gradle |
33 | 79 |
|
34 | 80 | ```groovy |
35 | | -implementation 'tech:hiddenproject:aide-all:1.1' |
| 81 | +implementation 'tech:hiddenproject:aide-all:1.2' |
36 | 82 | ``` |
37 | 83 |
|
38 | 84 | ## Resources |
|
48 | 94 |
|
49 | 95 | ___ |
50 | 96 |
|
51 | | -Aide has no dependencies and use only Java 8.</p> |
| 97 | +Aide has no dependencies and use only Java 8. |
52 | 98 |
|
53 | 99 | ## Repository info |
54 | 100 |
|
|
0 commit comments