Skip to content

Commit

Permalink
Reformat the source
Browse files Browse the repository at this point in the history
  • Loading branch information
markozajc committed Apr 2, 2021
1 parent b505d9a commit 0312952
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public static void main(String[] args) throws Exception {
Akiwrapper aw;
try {
aw = new AkiwrapperBuilder().setFilterProfanity(filterProfanity)
.setLanguage(language)
.setGuessType(guessType)
.build();
.setLanguage(language)
.setGuessType(guessType)
.build();
} catch (ServerNotFoundException e) {
System.err.println("Invalid combination of language and guess type. Try a different guess type.");
return;
Expand All @@ -107,8 +107,8 @@ public static void main(String[] args) throws Exception {
// Displays the question.

if (question.getStep() == 0)
System.out.println(
"\nAnswer with Y (yes), N (no), DK (don't know), P (probably) or PN (probably not) or go back in time with B (back).");
System.out
.println("\nAnswer with Y (yes), N (no), DK (don't know), P (probably) or PN (probably not) or go back in time with B (back).");
// Displays the tip (only for the first time).

answerQuestion(sc, aw);
Expand Down Expand Up @@ -141,7 +141,7 @@ private static void reviewGuesses(@Nonnull Scanner sc, @Nonnull Akiwrapper aw, @
System.exit(0);
}

declined.add(Long.valueOf(guess.getIdLong()));
declined.add(guess.getIdLong());
// Registers this guess as rejected.
}

Expand Down Expand Up @@ -177,16 +177,15 @@ private static void answerQuestion(@Nonnull Scanner sc, @Nonnull Akiwrapper aw)
ApiKey.accquireApiKey();

} else if (answer.equals("debug")) {
System.out.println("Debug information:\n\tCurrent API server: "
+ aw.getServer().getUrl()
+ "\n\tCurrent guess count: "
+ aw.getGuesses().size());
System.out.println("Debug information:\n\tCurrent API server: " + aw.getServer().getUrl() +
"\n\tCurrent guess count: " +
aw.getGuesses().size());
continue;
// Displays some debug information.

} else {
System.out.println(
"Please answer with either [Y]ES, [N]O, [D|ONT |K]NOW, [P]ROBABLY or [P|ROBABLY |N]OT or go back one step with [B]ACK.");
System.out
.println("Please answer with either [Y]ES, [N]O, [D|ONT |K]NOW, [P]ROBABLY or [P|ROBABLY |N]OT or go back one step with [B]ACK.");
continue;
}

Expand Down Expand Up @@ -224,8 +223,8 @@ private static Language getLanguage(@Nonnull Scanner sc) {
EnumSet<Language> languages = EnumSet.allOf(Language.class);
// Fetches all available languages.

String unsupportedLanguageMessage = "Sorry, that language isn't supported. Rather try with:"
+ languages.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", ""));
String unsupportedLanguageMessage = "Sorry, that language isn't supported. Rather try with:" +
languages.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", ""));
// Does some Java 8 magic to pre-prepare the error message.

System.out.println("What's your language? (English)");
Expand All @@ -238,9 +237,9 @@ private static Language getLanguage(@Nonnull Scanner sc) {
}

Language matching = languages.stream()
.filter(l -> l.toString().toLowerCase().equals(selectedLanguage))
.findAny()
.orElse(null);
.filter(l -> l.toString().toLowerCase().equals(selectedLanguage))
.findAny()
.orElse(null);

if (matching == null) {
System.out.println(unsupportedLanguageMessage);
Expand All @@ -258,8 +257,8 @@ private static GuessType getGuessType(@Nonnull Scanner sc) {
EnumSet<GuessType> guessTypes = EnumSet.allOf(GuessType.class);
// Fetches all available guess types.

String unsupportedGuessTypeMessage = "Sorry, that guess type isn't supported. Rather try with:"
+ guessTypes.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", ""));
String unsupportedGuessTypeMessage = "Sorry, that guess type isn't supported. Rather try with:" +
guessTypes.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", ""));
// Does some Java 8 magic to pre-prepare the error message.

System.out.println("What will you be guessing? (character)");
Expand All @@ -272,9 +271,9 @@ private static GuessType getGuessType(@Nonnull Scanner sc) {
}

GuessType matching = guessTypes.stream()
.filter(l -> l.toString().toLowerCase().equals(selectedGuessType))
.findAny()
.orElse(null);
.filter(l -> l.toString().toLowerCase().equals(selectedGuessType))
.findAny()
.orElse(null);

if (matching == null) {
System.out.println(unsupportedGuessTypeMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
protected GuessType guessType;

protected MutableAkiwrapperMetadata(@Nullable Server server, boolean filterProfanity, @Nonnull Language language,
@Nonnull GuessType guessType) {
@Nonnull GuessType guessType) {
this.server = server;
this.filterProfanity = filterProfanity;
this.language = language;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class MissingQuestionException extends RuntimeException {
/**
* Constructs a new {@link MissingQuestionException} instance.
*/
public MissingQuestionException() {
}
public MissingQuestionException() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class ServerNotFoundException extends Exception {
/**
* Constructs a new {@link ServerNotFoundException}.
*/
public ServerNotFoundException() {
}
public ServerNotFoundException() {}

}
9 changes: 6 additions & 3 deletions src/test/java/com/markozajc/akiwrapper/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

class IntegrationTest {

private static final String SERVER_GUESSTYPE_NO_MATCH = "The wanted and actual guess type of the server don't match.";
private static final String SERVER_GUESSTYPE_NO_MATCH =
"The wanted and actual guess type of the server don't match.";
private static final String SERVER_LANGUAGE_NO_MATCH = "The wanted and actual language of the server don't match.";
private static final String QUESTION_CURRENT_NO_MATCH = "Current question does not match the one just returned by the API.";
private static final String QUESTION_CURRENT_NO_MATCH =
"Current question does not match the one just returned by the API.";
private static final String QUESTION_WRONG_STEP = "Question was on an unexpected step.";
private static final String QUESTION_EMPTY = "Question mustn't be empty.";
private static final String QUESTION_NULL = "Question was null";
private static final String QUESTION_INITIAL_NO_MATCH = "Initial question does not match the one after an equal amount of answers and undoes.";
private static final String QUESTION_INITIAL_NO_MATCH =
"Initial question does not match the one after an equal amount of answers and undoes.";

@ParameterizedTest
@MethodSource("generateTestAkiwrapper")
Expand Down

0 comments on commit 0312952

Please sign in to comment.