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.
Aide reflection contains utils for reflection such as fast method invocation with lambda wrapping, annotation processing and other useful methods.
Reflective method calls with Aide are simple:
// Get LambdaWrapperHolder isntance with default LambdaWrapper interface loaded
LambdaWrapperHolder lambdaWrapperHolder = LambdaWrapperHolder.DEFAULT;
// Find static method
Method staticMethod = ReflectionUtil.getMethod(TestClass.class, "staticMethod", String.class);
// Wrap static method
// LambdaWrapper - default wrapper interface from Aide
// Void - caller class. In case of static method caller is not needed, so Void
// Integer - return type
MethodHolder<LambdaWrapper, Void, Integer> staticHolder = lambdaWrapperHolder.wrapSafe(staticMethod);
// Invoke static method without caller
int staticResult = staticHolder.invokeStatic("Hello");
Aide optional contains extended optional classes for String, Boolean types, IfTrue and When conditionals, Object utils.
Extended optionals provides new methods for some types:
BooleanOptional.of(Modifier.isPublic(executable.getModifiers()))
.ifFalseThrow(() -> ReflectionException.format("Wrapping is supported for PUBLIC methods only!"));
With conditionals you can make your code more functional. Thats how Aide reflection uses them:
AbstractSignature signature = IfTrueConditional.create()
.ifTrue(exact).then(() -> ExactMethodSignature.from(method))
.ifTrue(!exact).then(() -> MethodSignature.from(method))
.orElseThrow(() -> ReflectionException.format("%s undefined!", exact));
Or WhenConditional:
WhenConditional.create()
.when(someObj, Objects::nonNull).then(MyClass::nonNull)
.when(someObj, Objects::isNull).then(MyClass::isNull)
.orDoNothing();
SwitchConditional too:
Status status = Status.BAD_REQUEST;
String message = SwitchConditional.<Status, String>on(status)
.caseOn(Status.BAD_REQUEST::equals).thenGet("Error: Bad request")
.caseOn(Status.INTERNAL_ERROR::equals).thenGet("Error: Internal error")
.orElse("");
assert message.equals("Error: Bad request");
SwitchConditional.on(status)
// false = no break;, so all branches below will be executed
.caseOn(Status.BAD_REQUEST::equals, false).thenDo(this::action)
.caseOn(Status.INTERNAL_ERROR::equals).thenDo(this::action)
.orElseDo(() -> System.out.println("No action"));
Artifact ids:
tech.hiddenproject:aide-all
- all componentstech.hiddenproject:aide-optional
- optionals and conditionalstech.hiddenproject:aide-reflection
- reflection utils
<dependency>
<groupId>tech.hiddenproject</groupId>
<artifactId>aide-all</artifactId>
<version>1.3</version>
</dependency>
implementation 'tech:hiddenproject:aide-all:1.3'
Aide has no dependencies and use only Java 8.
- The main branch contains stable release
- Development branch contains WIP code
- Aide is released under version 2.0 of the Apache License