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 main() { | |
getFruits() | |
.filter { it.name != null && !it.isRotten && it.color == Color.BLACK } | |
.forEach { println("Yay! It's an orange ${it.name}") } | |
} |
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 main() { | |
getFruits() | |
.asSequence() | |
.filter { it.name != null } | |
.filter { !it.isRotten } | |
.filter { it.color == Color.ORANGE } | |
.forEach { println("Yay! It's an orange ${it.name}") } | |
} |
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 main() { | |
getFruits() | |
.filter { it.name != null } | |
.filter { !it.isRotten } | |
.filter { it.color == Color.ORANGE } | |
.forEach { println("Yay! It's an orange ${it.name}") } | |
} |
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
data class Fruit( | |
val name: String?, | |
val isRotten: Boolean, | |
val color: Color | |
) | |
fun getFruits(): List<Fruit> { TODO() } | |
fun main() { | |
val fruits = getFruits() |
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 SampleApplication : Application() { | |
private lateinit var componentDispatcher: ComponentDispatcher | |
override fun onCreate() { | |
super.onCreate() | |
componentDispatcher = ComponentDispatcher(this) | |
} | |
fun getComponentDispatcher() = componentDispatcher |
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
<application> | |
<meta-data | |
android:name="@string/component_generator_features" | |
android:resource="@array/component_generators" /> | |
<meta-data | |
android:name="@string/component_generator_core" | |
android:value="com.yayandroid.componentdispatcher.sample.base.SampleCoreComponentGenerator" /> | |
</application |
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 SampleCoreComponentGenerator : CoreComponentGenerator<YourCoreComponent>() { | |
override fun generate(application: Application): YourCoreComponent { | |
// Create your component here... | |
} | |
} | |
class Feature1ComponentGenerator : FeatureComponentGenerator<YourFeatureComponent>() { | |
override fun generate(application: Application, coreComponent: YourCoreComponent?): YourFeatureComponent { | |
// Create your component here... Please notice, if you don't create | |
// an implementation of `CoreComponentGenerator` here coreComponent will be null. |
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 SampleBuilderTest { | |
val mockSampleObject = mock<SampleObject>() | |
val mockSampleBuilder = mockBuilder<SampleObject.Builder>(mockSampleObject) | |
@Test fun `when super business logic runs should do important stuff with correct configuration`() { | |
SampleLogic(mockSampleBuilder).superBusinessLogic() | |
verifyInOrder(mockSampleBuilder) { | |
configA(true) |
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 : Any> verifyInOrder(mock: T, body: T.() -> Unit) | |
= with(inOrder(mock)) { verify(mock).body() } |
NewerOlder