163
GitHub - TheWizardAndTheWyrd/kotlin-reified-factory: Let's use reified g...
source link: https://github.com/TheWizardAndTheWyrd/kotlin-reified-factory
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
TheWizardAndTheWyrd/kotlin-reified-factory
master
Code
kotlin-reified-factory
Let's use reified generics in Kotlin
to implement a simple Factory Method
pattern.
Class Hierarchy
BaseClient
Abstract base class.
FooClient
Implements BaseClient
.
BarClient
Implements BaseClient
.
ClientFactory
Singleton object with a ::create()
method to create implementations of BaseClient
.
Testing
There is a JUnit
test in ClientFactoryTest
.
License
Released under the MIT License
.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK