Fixed JDK compilation error (due to bug #JDK-8044546)

This commit is contained in:
Abbas Abou Daya 2017-07-11 13:07:09 +03:00
parent 6df6627821
commit 8c9d3c3ad7
2 changed files with 10 additions and 3 deletions

View File

@ -27,6 +27,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static com.google.common.base.Strings.isNullOrEmpty;
@ -728,9 +730,11 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
boolean checkMessageFlags(Trio<Update, Ability, String[]> trio) {
Ability ability = trio.b();
Update update = trio.a();
// The following variable is required to avoid bug #JDK-8044546
BiFunction<Boolean, Predicate<Update>, Boolean> flagAnd = (flag, nextFlag) -> flag && nextFlag.test(update);
return ability.flags().stream()
.reduce(true, (flag, nextFlag) -> flag && nextFlag.test(update), Boolean::logicalAnd);
.reduce(true, flagAnd, Boolean::logicalAnd);
}
private File downloadFileWithId(String fileId) throws TelegramApiException {

View File

@ -5,6 +5,7 @@ import org.telegram.telegrambots.api.objects.Update;
import java.util.List;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Predicate;
@ -31,7 +32,9 @@ public final class Reply {
}
public boolean isOkFor(Update update) {
return conditions.stream().reduce(true, (state, cond) -> state && cond.test(update), Boolean::logicalAnd);
// The following variable is required to avoid bug #JDK-8044546
BiFunction<Boolean, Predicate<Update>, Boolean> stateAnd = (state, cond) -> state && cond.test(update);
return conditions.stream().reduce(true, stateAnd, Boolean::logicalAnd);
}
public void actOn(Update update) {