Skip to content

Commit

Permalink
Reformat the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
markozajc committed Feb 10, 2021
1 parent 1f31127 commit d15884f
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package com.markozajc.akiwrapper.example;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Scanner;
import java.util.*;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;

import com.markozajc.akiwrapper.Akiwrapper;
import com.markozajc.akiwrapper.*;
import com.markozajc.akiwrapper.Akiwrapper.Answer;
import com.markozajc.akiwrapper.AkiwrapperBuilder;
import com.markozajc.akiwrapper.core.entities.Guess;
import com.markozajc.akiwrapper.core.entities.Question;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Server.*;
import com.markozajc.akiwrapper.core.entities.impl.immutable.ApiKey;
import com.markozajc.akiwrapper.core.exceptions.ServerNotFoundException;

Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/markozajc/akiwrapper/Akiwrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import java.util.List;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import com.markozajc.akiwrapper.core.entities.Guess;
import com.markozajc.akiwrapper.core.entities.Question;
import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.*;

/**
* The "core" of interaction with the Akinator's API. Contains all methods required
Expand Down
21 changes: 7 additions & 14 deletions src/main/java/com/markozajc/akiwrapper/core/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.*;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.*;
import org.slf4j.*;

import com.markozajc.akiwrapper.core.entities.Status;
import com.markozajc.akiwrapper.core.entities.Status.Level;
import com.markozajc.akiwrapper.core.entities.impl.immutable.ApiKey;
import com.markozajc.akiwrapper.core.entities.impl.immutable.StatusImpl;
import com.markozajc.akiwrapper.core.exceptions.ServerUnavailableException;
import com.markozajc.akiwrapper.core.exceptions.StatusException;
import com.markozajc.akiwrapper.core.entities.impl.immutable.*;
import com.markozajc.akiwrapper.core.exceptions.*;
import com.markozajc.akiwrapper.core.impl.AkiwrapperImpl.Token;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import kong.unirest.Unirest;
import kong.unirest.UnirestInstance;
import kong.unirest.*;

/**
* A class defining various API endpoints. It is capable of building such
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.markozajc.akiwrapper.core.entities;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import com.markozajc.akiwrapper.Akiwrapper;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.Server.*;

/**
* A class holding configuration for an {@link Akiwrapper} instance. Note that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import java.net.URL;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import com.markozajc.akiwrapper.AkiwrapperBuilder;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.markozajc.akiwrapper.core.entities;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.*;

/**
* A representation of an object with a numeric identifier. Some objects in the API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.markozajc.akiwrapper.core.entities;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.*;

import com.markozajc.akiwrapper.Akiwrapper.Answer;
import com.markozajc.akiwrapper.AkiwrapperBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.markozajc.akiwrapper.core.entities;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import com.markozajc.akiwrapper.core.Route;
import com.markozajc.akiwrapper.core.exceptions.ServerNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.*;

import javax.annotation.Nonnull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.markozajc.akiwrapper.core.entities.impl.immutable;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.*;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import org.json.JSONArray;
import org.json.JSONObject;
import org.json.*;

import com.markozajc.akiwrapper.core.Route;
import com.markozajc.akiwrapper.core.entities.Guess;
Expand Down Expand Up @@ -61,7 +57,7 @@ public GuessImpl(@Nonnull String id, @Nonnull String name, @Nullable String desc
@SuppressWarnings("null")
public GuessImpl(@Nonnull JSONObject json) {
this(json.getString("id"), json.getString("name"), getDescription(json), getImage(json),
JSONUtils.getDouble(json, "proba").get().doubleValue());
JSONUtils.getDouble(json, "proba").get());
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package com.markozajc.akiwrapper.core.entities.impl.immutable;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import com.markozajc.akiwrapper.core.entities.AkiwrapperMetadata;
import com.markozajc.akiwrapper.core.entities.Guess;
import com.markozajc.akiwrapper.core.entities.Question;
import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Server.*;

/**
* An immutable implementation of {@link AkiwrapperMetadata}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.markozajc.akiwrapper.core.entities.impl.immutable;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.*;

import org.json.JSONObject;

import com.markozajc.akiwrapper.core.entities.Question;
import com.markozajc.akiwrapper.core.entities.Status;
import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Status.Level;
import com.markozajc.akiwrapper.core.exceptions.MissingQuestionException;
import com.markozajc.akiwrapper.core.utils.JSONUtils;
Expand Down Expand Up @@ -67,9 +65,9 @@ public QuestionImpl(@Nonnull JSONObject json, @Nonnull Status status) {
checkMissingQuestion(status);
this.id = json.getString("questionid");
this.question = json.getString("question");
this.step = JSONUtils.getInteger(json, "step").get().intValue();
this.gain = JSONUtils.getDouble(json, "infogain").get().doubleValue();
this.progression = JSONUtils.getDouble(json, "progression").get().doubleValue();
this.step = JSONUtils.getInteger(json, "step").get();
this.gain = JSONUtils.getDouble(json, "infogain").get();
this.progression = JSONUtils.getDouble(json, "progression").get();
}

private static void checkMissingQuestion(@Nonnull Status status) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package com.markozajc.akiwrapper.core.entities.impl.immutable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Queue;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.*;

import javax.annotation.Nonnull;

import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.ServerList;
import com.markozajc.akiwrapper.core.entities.*;

public class ServerListImpl implements ServerList {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.markozajc.akiwrapper.core.entities.impl.immutable;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import org.json.JSONObject;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package com.markozajc.akiwrapper.core.entities.impl.mutable;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.markozajc.akiwrapper.core.entities.AkiwrapperMetadata;
import com.markozajc.akiwrapper.core.entities.Guess;
import com.markozajc.akiwrapper.core.entities.Question;
import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.ServerList;
import javax.annotation.*;

import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Server.*;
import com.markozajc.akiwrapper.core.entities.impl.immutable.ImmutableAkiwrapperMetadata;
import com.markozajc.akiwrapper.core.utils.Servers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class MissingQuestionException extends RuntimeException {
* Constructs a new {@link MissingQuestionException} instance.
*/
public MissingQuestionException() {
super();
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.markozajc.akiwrapper.core.exceptions;

import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.Server.*;

/**
* An exception indicating that no {@link Server} could be found for the given
Expand All @@ -16,7 +15,6 @@ public class ServerNotFoundException extends Exception {
* Constructs a new {@link ServerNotFoundException}.
*/
public ServerNotFoundException() {
super();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import javax.annotation.Nonnull;

import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.Status;
import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.impl.immutable.StatusImpl;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import javax.annotation.Nonnull;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.*;

/**
* A set of utilities for JSON that prevent type errors.
Expand All @@ -31,7 +30,7 @@ public static Optional<Integer> getInteger(@Nonnull JSONObject json, @Nonnull St
Object object = json.get(key);
Integer value;
if (object instanceof Number)
value = Integer.valueOf(((Number) object).intValue());
value = ((Number) object).intValue();
else if (object instanceof String)
value = Integer.valueOf((String) object);
else
Expand Down Expand Up @@ -62,7 +61,7 @@ public static Optional<Double> getDouble(@Nonnull JSONObject json, @Nonnull Stri
Object object = json.get(key);
Double value;
if (object instanceof Number)
value = Double.valueOf(((Number) object).doubleValue());
value = ((Number) object).doubleValue();
else if (object instanceof String)
value = Double.valueOf((String) object);
else
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/com/markozajc/akiwrapper/core/utils/Servers.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package com.markozajc.akiwrapper.core.utils;

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

import javax.annotation.Nonnull;

import com.jcabi.xml.XMLDocument;
import com.markozajc.akiwrapper.core.Route;
import com.markozajc.akiwrapper.core.entities.Server;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.ServerList;
import com.markozajc.akiwrapper.core.entities.impl.immutable.ServerImpl;
import com.markozajc.akiwrapper.core.entities.impl.immutable.ServerListImpl;
import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Server.*;
import com.markozajc.akiwrapper.core.entities.impl.immutable.*;
import com.markozajc.akiwrapper.core.exceptions.ServerNotFoundException;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down
20 changes: 6 additions & 14 deletions src/test/java/com/markozajc/akiwrapper/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@
import java.util.List;
import java.util.stream.Stream;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.*;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.junit.jupiter.params.provider.*;
import org.slf4j.*;

import com.markozajc.akiwrapper.Akiwrapper.Answer;
import com.markozajc.akiwrapper.core.entities.Guess;
import com.markozajc.akiwrapper.core.entities.Question;
import com.markozajc.akiwrapper.core.entities.Server.GuessType;
import com.markozajc.akiwrapper.core.entities.Server.Language;
import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Server.*;
import com.markozajc.akiwrapper.core.exceptions.ServerNotFoundException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.*;

class IntegrationTest {

Expand Down
6 changes: 2 additions & 4 deletions src/test/java/com/markozajc/akiwrapper/core/RouteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import org.json.JSONObject;
import org.junit.jupiter.api.Test;

import com.markozajc.akiwrapper.core.exceptions.ServerUnavailableException;
import com.markozajc.akiwrapper.core.exceptions.StatusException;
import com.markozajc.akiwrapper.core.exceptions.*;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

class RouteTest {

Expand Down
Loading

0 comments on commit d15884f

Please sign in to comment.