Skip to content

Commit

Permalink
replaced .toList() with .collect(Collectors.toList())
Browse files Browse the repository at this point in the history
  • Loading branch information
codejanovic committed Feb 15, 2024
1 parent 0589895 commit f6c23e0
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public abstract class LongAutocompleteOptionalOption extends AutocompleteOptionalOption<Long>{
public LongAutocompleteOptionalOption(final String name, final String description) {
Expand All @@ -16,7 +17,7 @@ public LongAutocompleteOptionalOption(final String name, final String descriptio
@Override
protected final List<SlashCommandOptionChoice> onAutocomplete(final Optional<SlashCommandInteractionOption> option) {
return onAutocompleteChoice(option.flatMap(SlashCommandInteractionOption::getLongValue))
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
}

protected abstract List<Choice<Long>> onAutocompleteChoice(final Optional<Long> option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public abstract class LongAutocompleteRequiredOption extends AutocompleteRequiredOption<Long> {
public LongAutocompleteRequiredOption(final String name, final String description) {
Expand All @@ -16,7 +17,7 @@ public LongAutocompleteRequiredOption(final String name, final String descriptio
@Override
protected final List<SlashCommandOptionChoice> onAutocomplete(final Optional<SlashCommandInteractionOption> option) {
return onAutocompleteChoice(option.flatMap(SlashCommandInteractionOption::getLongValue))
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
}

protected abstract List<Choice<Long>> onAutocompleteChoice(final Optional<Long> option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public abstract class StringAutocompleteOptionalOption extends AutocompleteOptionalOption<String> {
public StringAutocompleteOptionalOption(final String name, final String description) {
Expand All @@ -16,7 +17,7 @@ public StringAutocompleteOptionalOption(final String name, final String descript
@Override
protected final List<SlashCommandOptionChoice> onAutocomplete(final Optional<SlashCommandInteractionOption> option) {
return onAutocompleteChoice(option.flatMap(SlashCommandInteractionOption::getStringValue))
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
}

protected abstract List<Choice<String>> onAutocompleteChoice(final Optional<String> option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public abstract class StringAutocompleteRequiredOption extends AutocompleteRequiredOption<String> {
public StringAutocompleteRequiredOption(final String name, final String description) {
Expand All @@ -16,7 +17,7 @@ public StringAutocompleteRequiredOption(final String name, final String descript
@Override
protected final List<SlashCommandOptionChoice> onAutocomplete(final Optional<SlashCommandInteractionOption> option) {
return onAutocompleteChoice(option.flatMap(SlashCommandInteractionOption::getStringValue))
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
}

protected abstract List<Choice<String>> onAutocompleteChoice(final Optional<String> option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.javacord.api.interaction.SlashCommandOptionType;

import java.util.List;
import java.util.stream.Collectors;

public class ChoiceLongOptionalOption extends OptionalOption<Long> {
private final List<Choice<Long>> _choices;
Expand All @@ -17,7 +18,7 @@ public ChoiceLongOptionalOption(final String name, final String description, fin

@Override
protected final SlashCommandOptionBuilder buildSlashCommandOption(final SlashCommandOptionBuilder builder) {
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
return builder.setChoices(choices);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.javacord.api.interaction.SlashCommandOptionType;

import java.util.List;
import java.util.stream.Collectors;

public class ChoiceLongRequiredOption extends RequiredOption<Long> {
private final List<Choice<Long>> _choices;
Expand All @@ -17,7 +18,7 @@ public ChoiceLongRequiredOption(final String name, final String description, fin

@Override
protected final SlashCommandOptionBuilder buildSlashCommandOption(final SlashCommandOptionBuilder builder) {
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
return builder.setChoices(choices);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.javacord.api.interaction.SlashCommandOptionType;

import java.util.List;
import java.util.stream.Collectors;

public class ChoiceStringOptionalOption extends OptionalOption<String> {
private final List<Choice<String>> _choices;
Expand All @@ -17,7 +18,7 @@ public ChoiceStringOptionalOption(final String name, final String description, f

@Override
protected final SlashCommandOptionBuilder buildSlashCommandOption(final SlashCommandOptionBuilder builder) {
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
return builder.setChoices(choices);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.javacord.api.interaction.SlashCommandOptionType;

import java.util.List;
import java.util.stream.Collectors;

public class ChoiceStringRequiredOption extends RequiredOption<String> {
private final List<Choice<String>> _choices;
Expand All @@ -17,7 +18,7 @@ public ChoiceStringRequiredOption(final String name, final String description, f

@Override
protected final SlashCommandOptionBuilder buildSlashCommandOption(final SlashCommandOptionBuilder builder) {
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).toList();
var choices = _choices.stream().map(c -> SlashCommandOptionChoice.create(c.name(), c.value())).collect(Collectors.toList());
return builder.setChoices(choices);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public SelectMenuStringComponent(final String identifier, final List<SelectMenuC
@Override
protected final void onInteraction(final MessageComponentInteraction event) {
var interaction = event.asSelectMenuInteraction().get();
var choices = interaction.getChosenOptions().stream().map(o -> _choiceByValue.get(o.getValue())).toList();
var choices = interaction.getChosenOptions().stream().map(o -> _choiceByValue.get(o.getValue())).collect(Collectors.toList());
onChoicesSelected(interaction, choices);
}

protected abstract void onChoicesSelected(final SelectMenuInteraction interaction, final List<SelectMenuChoice<T>> choices);

@Override
public final LowLevelComponent component() {
var options = _choices.stream().map(SelectMenuChoice::toSelectMenuOption).toList();
var options = _choices.stream().map(SelectMenuChoice::toSelectMenuOption).collect(Collectors.toList());
return new SelectMenuBuilder(ComponentType.SELECT_MENU_STRING, _identifier)
.addOptions(options)
.setDisabled(_disabled)
Expand Down

0 comments on commit f6c23e0

Please sign in to comment.