“Metaprogramming is a computer programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyze, or transform other programs, and even modify itself, while running..” 9
*/ /* UnionOfPhilosophersModule.kt */ @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers } 1. single file named “${implDeclaration.syperType()}Module” 2. single abstract class named “${implDeclaration.syperType()}Module” annotated with @Module and @InstallIn(autoBindAnnotation.components) 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Binds one parameter of type implementation returns implDeclaration.syperType() :union_of_philosophers:impl
{ return FunSpec .builder("bind${implDeclaration.superTypes.first().resolve().toClassName().simpleName}") .addModifiers(KModifier.ABSTRACT) .addAnnotation(Binds :: class) .addParameter( name = "impl", type = implDeclaration.toClassName() ) .returns(implDeclaration.superTypes.first().toTypeName()) .build() } 66 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Bind one parameter of type implementation returns implDeclaration.syperType() @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers }
{ return FunSpec .builder("bind${implDeclaration.superTypes.first().resolve().toClassName().simpleName}") .addModifiers(KModifier.ABSTRACT) .addAnnotation(Binds :: class) .addParameter( name = "impl", type = implDeclaration.toClassName() ) .returns(implDeclaration.superTypes.first().toTypeName()) .build() } 67 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Bind one parameter of type implementation returns implDeclaration.syperType() @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers }
{ return FunSpec .builder("bind${implDeclaration.superTypes.first().resolve().toClassName().simpleName}") .addModifiers(KModifier.ABSTRACT) .addAnnotation(Binds :: class) .addParameter( name = "impl", type = implDeclaration.toClassName() ) .returns(implDeclaration.superTypes.first().toTypeName()) .build() } 68 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Bind one parameter of type implementation returns implDeclaration.syperType() @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers }
{ return FunSpec .builder("bind${implDeclaration.superTypes.first().resolve().toClassName().simpleName}") .addModifiers(KModifier.ABSTRACT) .addAnnotation(Binds :: class) .addParameter( name = "impl", type = implDeclaration.toClassName() ) .returns(implDeclaration.superTypes.first().toTypeName()) .build() } 69 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Bind one parameter of type implementation returns implDeclaration.syperType() @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers }
{ return FunSpec .builder("bind${implDeclaration.superTypes.first().resolve().toClassName().simpleName}") .addModifiers(KModifier.ABSTRACT) .addAnnotation(Binds :: class) .addParameter( name = "impl", type = implDeclaration.toClassName() ) .returns(implDeclaration.superTypes.first().toTypeName()) .build() } 70 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Bind one parameter of type implementation returns implDeclaration.syperType() @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers }
{ return FunSpec .builder("bind${implDeclaration.superTypes.first().resolve().toClassName().simpleName}") .addModifiers(KModifier.ABSTRACT) .addAnnotation(Binds :: class) .addParameter( name = "impl", type = implDeclaration.toClassName() ) .returns(implDeclaration.superTypes.first().toTypeName()) .build() } 71 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Bind one parameter of type implementation returns implDeclaration.syperType() @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers }
*/ /* UnionOfPhilosophersModule.kt */ @Module @InstallIn(SingletonComponent :: class) abstract class UnionOfPhilosophersModule { @Binds abstract fun bindTheUnionOfPhilosphers(impl: TheUnionOfPhilosophersImpl): TheUnionOfPhilosophers } 1. single file named “${implDeclaration.syperType()}Module” 2. single abstract class named “${implDeclaration.syperType()}Module” annotated with @Module and @InstallIn(autoBindAnnotation.components) 3. single abstract function named “bind${implDeclaration.syperType()}Module” annotated with @Binds one parameter of type implementation returns implDeclaration.syperType() :union_of_philosophers:impl