Provide stream() method in enhanced container
This commit is contained in:
parent
16d492073b
commit
6c42af9f30
@ -15,6 +15,8 @@ import ru.dbotthepony.mc.otm.core.collect.filter
|
|||||||
import ru.dbotthepony.mc.otm.core.collect.map
|
import ru.dbotthepony.mc.otm.core.collect.map
|
||||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||||
import java.util.function.Predicate
|
import java.util.function.Predicate
|
||||||
|
import java.util.stream.Stream
|
||||||
|
import java.util.stream.StreamSupport
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Backward-compatible" enhanced container interface, where all methods can be derived/emulated from existing [IContainer] ([Container]) code
|
* "Backward-compatible" enhanced container interface, where all methods can be derived/emulated from existing [IContainer] ([Container]) code
|
||||||
@ -291,6 +293,10 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack>, Sta
|
|||||||
return addItem(stack, false, slots, onlyIntoExisting, popTime).isEmpty
|
return addItem(stack, false, slots, onlyIntoExisting, popTime).isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun stream(): Stream<ItemStack> {
|
||||||
|
return StreamSupport.stream(spliterator(), false)
|
||||||
|
}
|
||||||
|
|
||||||
private class Wrapper(private val parent: Container) : IEnhancedContainer {
|
private class Wrapper(private val parent: Container) : IEnhancedContainer {
|
||||||
override fun clearContent() {
|
override fun clearContent() {
|
||||||
return parent.clearContent()
|
return parent.clearContent()
|
||||||
|
Loading…
Reference in New Issue
Block a user