[groovy] add Consumer.plusAssign

This commit is contained in:
Daniil Ovchinnikov
2018-01-23 17:32:57 +03:00
parent 5a3817a5ce
commit f7f4594948
@@ -1,8 +1,17 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.util
import com.intellij.util.Consumer
import java.util.function.Consumer
import com.intellij.util.Consumer as JBConsumer
fun <T> Consumer<T>.consumeAll(items: Iterable<T>) {
fun <T> JBConsumer<T>.consumeAll(items: Iterable<T>) {
items.forEach(this::consume)
}
operator fun <T> Consumer<in T>.plusAssign(elements: Iterable<T>) {
elements.forEach(this::plusAssign)
}
operator fun <T> Consumer<in T>.plusAssign(element: T) {
accept(element)
}