KTX 1.10.0-b3
Pre-release
Pre-release
The first release to include the ktx-reflect
module with new reflection utilities. Includes notable new features in ktx-collections
, ktx-inject
, and ktx-assets-async
.
- [UPDATE] Updated to Kotlin 1.5.31.
- [UPDATE] Updated to Kotlin Coroutines 1.5.2.
- [FEATURE] (
ktx-assets-async
)AssetStorage
now supports loadingPolygonRegion
assets out of the box if the default loaders are registered. - [FEATURE] (
ktx-assets-async
)AsyncAssetManager
is a newAssetManager
extension with basic support for Kotlin coroutines.AsyncAssetManager.loadAsync
allows to schedule an asset for loading, returning aDeferred
asset reference.AsyncAssetManager.getDefaultParameters
allows to create a default instance ofAssetLoaderParameters
for a selected asset.AsyncAssetManager.setLoaderParameterSupplier
has to be called for each custom asset loader in order to enable asynchronous loading without explicitly passing loader parameters.
- [FEATURE] (
ktx-collections
) Factory methods for LibGDX arrays of primitives:gdxBooleanArrayOf
gdxByteArrayOf
gdxCharArrayOf
gdxShortArrayOf
gdxIntArrayOf
gdxLongArrayOf
gdxFloatArrayOf
- [FEATURE] (
ktx-inject
) New reflection-basedContext
methods with automatic dependency injection:newInstanceOf
: constructs an instance of the selected class. Injects constructor dependencies from theContext
.bind<Type>
: registers a provider that creates a new instance of selected class via reflection each time it is requested.bindSingleton<Type>
: creates, registers, and returns a singleton of selected class using reflection.
- [FEATURE] (
ktx-reflect
) Added a new module with reflection utilities.Reflection
annotation, which requires opt-in, allows marking functionalities that rely on reflection.ReflectedClass
is an inlined wrapper forClass
that allows to easily use LibGDX reflection API.ClassReflection
methods exposed asReflectedClass
read-only properties:simpleName
isMemberClass
isStatic
isArray
isPrimitive
isEnum
isAnnotation
isInterface
isAbstract
componentType
constructors
methods
declaredMethods
fields
declaredFields
annotations
declaredAnnotations
interfaces
enumConstants
ClassReflection
methods exposed asReflectedClass
methods with improved Kotlin class handling:isInstance
isAssignableFrom
newInstance
getConstructor
getDeclaredConstructor
getMethod
getDeclaredMethod
getField
getDeclaredField
isAnnotationPresent
getAnnotation
getDeclaredAnnotation
- Additional
ReflectedClass
utilities:constructor
property allows to extract the only class constructor if it is available.newArrayInstance
method allows to create a type array of the given size usingArrayReflection
.KClass
constructor allows creatingReflectedClass
from aKClass
.
reflect<Type>()
function allows to wrap a selected class withReflectedClass
.reflect(KClass<Type>)
function allows to wrap a selectedKClass
withReflectedClass
.reflect(Class<Type>)
function allows to wrap a selectedClass
withReflectedClass
.reflect(String)
function allows to find a selected class by qualified name and wrap it withReflectedClass
.Annotation.get
extension method with a reified type allowing to get an instance of the annotation.