Skip to content
/ Rumy Public

A simple library that simplifies java reflection.

License

Notifications You must be signed in to change notification settings

Hippo/Rumy

Repository files navigation

Rumy

A simple library that simplifies java reflection.

Add Rumy to your project

repositories {
    maven {
      url 'https://jitpack.io'
    }
}
dependencies {
    implementation group: 'com.github.Hippo', name: 'Rumy', version: '1.1.1'
}

How to use

Getting static access to a class:

ClassContext classContext = ClassLookup.lookup("MyClass");

Allocating Objects:

import static rip.hippo.rumy.allocate.ObjectAllocator.*;
ClassContext classContext = allocate("MyClass");

Parameter Pattern Matching:

By default, there is 3 possible options to match parameter types (for constructors and methods), empty, strong, and weak.

If no parameter pattern matcher is set it will default to empty.

Empty Pattern Matching:

As the name suggest, this will match methods and constructors with no parameters.

Strong Pattern Matching:

Strong pattern matching makes you specify the class types and the parameter values, this is to avoid mismatching with primitive and primitive wrappers.

import static rip.hippo.rumy.allocate.ObjectAllocator.*;
import static rip.hippo.rumy.pattern.ParameterTypePatternMatcher.*;
ClassContext classContext = ...;
classContext.invoke("myMethod", ofStrong(int.class).then(420));

Weak pattern matching:

Weak pattern matching only makes you specify the parameter values.

import static rip.hippo.rumy.allocate.ObjectAllocator.*;
import static rip.hippo.rumy.pattern.ParameterTypePatternMatcher.*;
ClassContext classContext = ...;
classContext.invoke("betterMethod", ofWeak("Cool value"));

The examples above shows you how to invoke methods with the parameter pattern matching, the same concept applies to allocating objects.

import static rip.hippo.rumy.allocate.ObjectAllocator.*;
import static rip.hippo.rumy.pattern.ParameterTypePatternMatcher.*;
ClassContext classContext = allocate("MyClass", ofWeak("Another cool value"));

About

A simple library that simplifies java reflection.

Resources

License

Stars

Watchers

Forks

Packages

No packages published