Skip to content
/ R Public

The Jolliest Java Reflection Library on the 7 Seas

License

Notifications You must be signed in to change notification settings

MrNavaStar/R

Repository files navigation

Maintenance PRs Welcome

ko-fi

The Jolliest Java Reflection Library on the 7 Seas.

Java reflection is often a treacherous journey filled with sharks and scallywags. Let R help you navigate your way through Davy Jones Locker.

Sail, Ho!

Before leaving on your adventure, be sure to pack R aboard your ship:

// We are on Maven Central

dependencies {
    implementation "me.mrnavastar:r:1.0.8"
}

O Captain! My Captain!

Now that were off, you need to wrap the object you want to plunder (reflect):

import me.mrnavastar.r.R;

R reflector = R.of(myPoorObject);
// You can also chain .of() calls on fields inside the object you just wrapped:
R reflector = R.of(myPoorObject).of("somePoorField");

Plunder The Booty!

With our treasure secured, it's time to show those landlubbers a real buccaneer:

// To get the value from a field (can be a private or a parent class field)
reflector.get("someField", Type.class);
// To set the value of a field (can be a private, final, or parent class field)
reflector.set("someField", myValue);
// To call a function (can be a private or a parent class function)
reflector.call("myFunction", ReturnType.class, param1, param2 ...);

// Get type params
reflector.generics();

Avast Ye!

Now that you've got your sea legs and are rolling in doubloons, be sure to loot with caution. Remember... dead men tell no tales.

About

The Jolliest Java Reflection Library on the 7 Seas

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages