KODI v1.4.2 Release Notes

Release Date: 2020-04-29 // 2 months ago
  • ➕ Added code generation for abstract and static classes and functions for BindSingle and BindProvider annotations

    Example:

    1. Create an instance with the provider for class reference

      interface IAnotherClass interface IMyClass : IAnotherClass

      @BindProvider(toClass = IAnotherClass::class) class MyClass() : IMyClass

    It is generate Providing method for binding like:
    bind<IAnotherClass>(tag = [toTag]) at [atScope] with provider { MyClass() }

    1. Binding for singleton object functions also for hight-order functions

      object CustomObject { @BindProvider(toClass = IAnotherClass::class) fun providingMethod(input: IMyClass): IAnotherClass { return input } }

    It is generate Providing method for binding like:

    bind<IAnotherClass>(tag = [toTag]) at [atScope] with provider { CustomObject.providingMethod(input = instance<IMyClass>()) }
    
    1. for interfaces and abstract classes it always will generate instance<T>():

      @BindProvider(toClass = IMyClass::class) interface IAbstractInterface : IMyClass

    bind<IMyClass>(tag = [toTag]) at [atScope] with provider { instance<IAbstractInterface>() }

    1. for abstract functions processor always generate instance().funName() like:

      interface IAbstractInterface { @BindProvider(toClass = IAnotherClass::class) fun getMyAbstractInstance(input: IAbstractInterface): IMyClass }

    bind<IAnotherClass>(tag = [toTag]) at [atScope] with provider { instance<IAbstractInterface>().getMyAbstractInstance( input = instance<IAbstractInterface>() ) }

    1. Added new annotation called WithInstance
      Tell the annotation processor to bind field or property with corresponding kodi instance

      @BindSingle(toClass = IMyClass::class)" class MyClass( @WithInstance( tag = "myAwesomeTag", scope = "MyAwesomeScope", with = "IDefaultClass::class" ) myDefaultValue: IDefaultClass ) : IMyClass

    0️⃣ It's generate single binding function with default instance paramater

    bind<IMyClass>() with single {
              MyClass(
                    myDefaultValue = instance<IDefaultClass>(
                                                            tag = "myAwesomeTag", 
                                                            scope = "MyAwesomeScope"
                                                   )
               )
    }