License GPLv2.
This is a duck typing implementation based on reflection and dynamic proxies with force methods access. Perhaps it can be used as a wrapper for reflect.
Call with parameter contravariant.
class Foo {
void run() {
println("I'm running")
}
void print(String msg) {
println(msg)
}
}
Foo foo = new Foo()
Runnable runnable = Types.asType(foo, Runnable.class)
runnable.run()// I'm running
Call with method name map.
class Foo {
void run() {
println("I'm running")
}
}
Foo foo = new Foo()
Types.desc(Foo.class).map("run", Closeable.class, "close")
Types.asType(foo, Closeable.class).close()// I'm running
10x faster than PlaceholderAPI.setPlaceholder(Player, String)
import com.mengcraft.util.CompiledStr
import org.bukkit.Bukkit
def compiled = new CompiledStr("My name is %player_name%")
println compiled.apply(Bukkit.getPlayerExact("HIM")) // My name is HIM