reflection

Reflection utils

License

License

GroupId

GroupId

com.mercateo
ArtifactId

ArtifactId

reflection
Last Version

Last Version

1.2.14
Release Date

Release Date

Type

Type

jar
Description

Description

reflection
Reflection utils
Project URL

Project URL

https://github.com/Mercateo/reflection
Project Organization

Project Organization

Mercateo AG
Source Code Management

Source Code Management

https://github.com/Mercateo/reflection.git

Download reflection

How to add to project

<!-- https://jarcasting.com/artifacts/com.mercateo/reflection/ -->
<dependency>
    <groupId>com.mercateo</groupId>
    <artifactId>reflection</artifactId>
    <version>1.2.14</version>
</dependency>
// https://jarcasting.com/artifacts/com.mercateo/reflection/
implementation 'com.mercateo:reflection:1.2.14'
// https://jarcasting.com/artifacts/com.mercateo/reflection/
implementation ("com.mercateo:reflection:1.2.14")
'com.mercateo:reflection:jar:1.2.14'
<dependency org="com.mercateo" name="reflection" rev="1.2.14">
  <artifact name="reflection" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.mercateo', module='reflection', version='1.2.14')
)
libraryDependencies += "com.mercateo" % "reflection" % "1.2.14"
[com.mercateo/reflection "1.2.14"]

Dependencies

compile (3)

Group / Artifact Type Version
net.bytebuddy : byte-buddy jar 1.7.11
org.objenesis : objenesis jar 2.6
org.cache2k : cache2k-core jar 1.0.2.Final

provided (1)

Group / Artifact Type Version
com.mercateo : default-immutables jar 1.2.1

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.9.1
org.mockito : mockito-core jar 2.13.0
org.openjdk.jmh : jmh-core jar 1.20
org.openjdk.jmh : jmh-generator-annprocess jar 1.20

Project Modules

There are no modules declared in this project.

Build Status Coverage Status MavenCentral

com.mercateo:reflection

ProxyFactory — create an intercepting proxy

    InvocationHandler interceptor = ...
    TestClass proxy = ProxyFactory.createProxy(TestClass.class, interceptor);

Call — A type safe variant for examination of method calls

Given an arbitrary class

class TestClass {
    public Integer testMethod(String name, Long counter) {
        return 42;
    }
}

Call can record a given method call

Method method = Call.of(TestClass.class, c -> c.testMethod("foo", 1234l)).method();

and returns all relevant parameters like

  • Method
  • Call Arguments
  • Object of Method

There is an additional shortcut to get the called method with Call.methodOf(...):

Method method = Call.methodOf(TestClass.class, c -> c.testMethod(null, 0));

Which replaces using reflection to get the method:

Method method = TestClass.class.getDeclaredMethod("testMethod", String.class, Long.class);

The latter can throw a NoSuchMethodException. Using Call.of(...)/Call.methodOf(...) with an unknown method just leads to a compile error.

com.mercateo
the procurement platform for your business

Versions

Version
1.2.14
1.2.13
1.2.12
1.2.11
1.2.10
1.2.9
1.2.8
1.2.7
1.2.6
1.2.5
1.2.3