Helper class to coerce values from Java to lua within the luajava library.
This class is primarily used by the {@link LuajavaLib}, but can also be used directly when working with Java/lua bindings.
To coerce scalar types, the various, generally the {@code valueOf(type)} methods on {@link LuaValue} may be used:
- {@link LuaValue#valueOf(boolean)}
- {@link LuaValue#valueOf(byte[])}
- {@link LuaValue#valueOf(double)}
- {@link LuaValue#valueOf(int)}
- {@link LuaValue#valueOf(String)}
To coerce arrays of objects and lists, the {@code listOf(..)} and {@code tableOf(...)} methods on {@link LuaValue} may be used:
- {@link LuaValue#listOf(LuaValue[])}
- {@link LuaValue#listOf(LuaValue[],org.luaj.vm2.Varargs)}
- {@link LuaValue#tableOf(LuaValue[])}
- {@link LuaValue#tableOf(LuaValue[],LuaValue[],org.luaj.vm2.Varargs)}
The method {@link CoerceJavaToLua#coerce(Object)} looks as the type and dimesioning of the argument and tries to guess the best fit for corrsponding lua scalar, table, or table of tables.
@see CoerceJavaToLua#coerce(Object)
@see LuajavaLib