This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConcreteFactory1 : AbstractFactory { | |
override fun createProductA(): ProductA { | |
return ConcreteProductA1() | |
} | |
override fun createProductB(): ProductB { | |
return ConcreteProductB1() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConcreteProductA1 : ProductA { | |
override fun use() { | |
// implementation | |
} | |
} | |
class ConcreteProductA2 : ProductA { | |
override fun use() { | |
// implementation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ProductA { | |
fun use() | |
} | |
interface ProductB { | |
fun use() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface AbstractFactory { | |
fun createProductA(): ProductA | |
fun createProductB(): ProductB | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface RetrofitApi { | |
fun create(): Retrofit | |
} | |
class ProductionRetrofitApi : RetrofitApi { | |
override fun create(): Retrofit { | |
val retrofit = Retrofit.Builder() | |
.baseUrl("https://production-api.com") | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConcreteCreatorA : Creator() { | |
override fun factoryMethod(): Product { | |
return ConcreteProductA() | |
} | |
} | |
class ConcreteCreatorB : Creator() { | |
override fun factoryMethod(): Product { | |
return ConcreteProductB() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Creator { | |
abstract fun factoryMethod(): Product | |
fun someOperation() { | |
val product = factoryMethod() | |
product.use() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConcreteProductA : Product { | |
override fun use() { | |
// implementation | |
} | |
} | |
class ConcreteProductB : Product { | |
override fun use() { | |
// implementation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Product { | |
fun use() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Koin.getDependency(objCClass: ObjCClass): T? = getOriginalKotlinClass(objCClass)?.let { | |
getDependency(it) | |
} |