From eea4c3adc11dfcc6903b5d25caeace004aed4c1d Mon Sep 17 00:00:00 2001 From: Valentin Afanasiev Date: Tue, 26 Jan 2021 13:33:01 +0300 Subject: [PATCH] revert indentation changes --- .../abilitybots/api/bot/BaseAbilityBot.java | 48 +++++++++---------- .../abilitybots/api/bot/AbilityBotTest.java | 24 +++++----- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java index 95dae8ec..726e0789 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java @@ -248,9 +248,9 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability public Privacy getPrivacy(Update update, int id) { return isCreator(id) ? - CREATOR : isAdmin(id) ? - ADMIN : (isGroupUpdate(update) || isSuperGroupUpdate(update)) && isGroupAdmin(update, id) ? - GROUP_ADMIN : PUBLIC; + CREATOR : isAdmin(id) ? + ADMIN : (isGroupUpdate(update) || isSuperGroupUpdate(update)) && isGroupAdmin(update, id) ? + GROUP_ADMIN : PUBLIC; } public boolean isGroupAdmin(Update update, int id) { @@ -260,8 +260,8 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability public boolean isGroupAdmin(long chatId, int id) { GetChatAdministrators admins = GetChatAdministrators.builder().chatId(Long.toString(chatId)).build(); return silent.execute(admins) - .orElse(new ArrayList<>()).stream() - .anyMatch(member -> member.getUser().getId() == id); + .orElse(new ArrayList<>()).stream() + .anyMatch(member -> member.getUser().getId() == id); } public boolean isCreator(int id) { @@ -326,17 +326,17 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability DefaultAbilities defaultAbs = new DefaultAbilities(this); Stream defaultAbsStream = stream(DefaultAbilities.class.getMethods()) - .filter(checkReturnType(Ability.class)) - .map(returnAbility(defaultAbs)) - .filter(ab -> !toggle.isOff(ab)) - .map(toggle::processAbility); + .filter(checkReturnType(Ability.class)) + .map(returnAbility(defaultAbs)) + .filter(ab -> !toggle.isOff(ab)) + .map(toggle::processAbility); // Extract all abilities from every single extension instance abilities = Stream.concat(defaultAbsStream, - extensions.stream() - .flatMap(ext -> stream(ext.getClass().getMethods()) - .filter(checkReturnType(Ability.class)) - .map(returnAbility(ext)))) + extensions.stream() + .flatMap(ext -> stream(ext.getClass().getMethods()) + .filter(checkReturnType(Ability.class)) + .map(returnAbility(ext)))) // Abilities are immutable, build it respectively .collect(ImmutableMap::builder, (b, a) -> b.put(a.name(), a), @@ -378,15 +378,15 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability private void initStats() { Set enabledStats = Stream.concat( - replies.stream().filter(Reply::statsEnabled).map(Reply::name), - abilities.entrySet().stream() - .filter(entry -> entry.getValue().statsEnabled()) - .map(Map.Entry::getKey)).collect(toSet()); + replies.stream().filter(Reply::statsEnabled).map(Reply::name), + abilities.entrySet().stream() + .filter(entry -> entry.getValue().statsEnabled()) + .map(Map.Entry::getKey)).collect(toSet()); stats = db.getMap(STATS); Set toBeRemoved = difference(stats.keySet(), enabledStats); toBeRemoved.forEach(stats::remove); enabledStats.forEach(abName -> stats.computeIfAbsent(abName, - name -> createStats(abName, 0))); + name -> createStats(abName, 0))); } /** @@ -579,12 +579,12 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability String[] tokens; if (allowContinuousText()) { String abName = abilities.keySet().stream() - .filter(name -> msg.getText().startsWith(format("%s%s", getCommandPrefix(), name))) - .max(comparingInt(String::length)) - .orElse(DEFAULT); + .filter(name -> msg.getText().startsWith(format("%s%s", getCommandPrefix(), name))) + .max(comparingInt(String::length)) + .orElse(DEFAULT); tokens = msg.getText() - .replaceFirst(getCommandPrefix() + abName, "") - .split(getCommandRegexSplit()); + .replaceFirst(getCommandPrefix() + abName, "") + .split(getCommandRegexSplit()); ability = abilities.get(abName); } else { tokens = msg.getText().split(getCommandRegexSplit()); @@ -663,7 +663,7 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability return callable.call(); } catch(Exception ex) { log.error(format("Reply [%s] failed to check for conditions. " + - "Make sure you're safeguarding against all possible updates.", name)); + "Make sure you're safeguarding against all possible updates.", name)); } return false; } diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java index 58f513cf..42e87d56 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java @@ -687,25 +687,25 @@ public class AbilityBotTest { private void handlesAllUpdates(Consumer utilMethod) { Arrays.stream(Update.class.getMethods()) - // filter to all these methods of hasXXX (hasPoll, hasMessage, etc...) - .filter(method -> method.getName().startsWith("has")) - // Gotta filter out hashCode - .filter(method -> method.getReturnType().getName().equals("boolean")) - .forEach(method -> { - Update update = mock(Update.class); - try { + // filter to all these methods of hasXXX (hasPoll, hasMessage, etc...) + .filter(method -> method.getName().startsWith("has")) + // Gotta filter out hashCode + .filter(method -> method.getReturnType().getName().equals("boolean")) + .forEach(method -> { + Update update = mock(Update.class); + try { // Mock the method and make sure it returns true so that it gets processed by the following method when(method.invoke(update)).thenReturn(true); // Call the function, throws an IllegalStateException if there's an update that can't be processed utilMethod.accept(update); - } catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new RuntimeException( - format("Found an update variation that is not handled by the getChatId util method [%s]", method.getName()), e); - } catch (NullPointerException | ReflectiveOperationException e) { + format("Found an update variation that is not handled by the getChatId util method [%s]", method.getName()), e); + } catch (NullPointerException | ReflectiveOperationException e) { // This is fine, the mock isn't complete and we're only // looking for IllegalStateExceptions thrown by the method - } - }); + } + }); } private void mockUser(Update update, Message message, User user) {