Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
markozajc committed Feb 10, 2021
2 parents 9cd0345 + d15884f commit 7902fd8
Show file tree
Hide file tree
Showing 28 changed files with 77 additions and 162 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
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.markozajc</groupId>
<artifactId>akiwrapper</artifactId>
<version>1.5</version>
<version>1.5.1</version>

<name>Akiwrapper</name>
<description>A Java API wrapper for Akinator</description>
Expand Down Expand Up @@ -41,7 +41,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<junit.version>5.6.2</junit.version>
<junit.version>5.7.1</junit.version>
<slf4j.version>1.7.30</slf4j.version>
</properties>

Expand All @@ -57,7 +57,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
<version>20201115</version>
</dependency>

<!-- Unit tests -->
Expand All @@ -84,14 +84,14 @@
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.7.04</version>
<version>3.11.11</version>
</dependency>

<!-- Cache -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
<version>30.1-jre</version>
</dependency>

<!-- Logging -->
Expand All @@ -111,7 +111,7 @@
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.0.0</version>
<version>4.2.1</version>
</dependency>

<dependency>
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
17 changes: 6 additions & 11 deletions src/main/java/com/markozajc/akiwrapper/AkiwrapperBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

import javax.annotation.Nonnull;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.markozajc.akiwrapper.core.entities.AkiwrapperMetadata;
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 org.slf4j.*;

import com.markozajc.akiwrapper.core.entities.*;
import com.markozajc.akiwrapper.core.entities.Server.*;
import com.markozajc.akiwrapper.core.entities.impl.mutable.MutableAkiwrapperMetadata;
import com.markozajc.akiwrapper.core.exceptions.ServerNotFoundException;
import com.markozajc.akiwrapper.core.exceptions.ServerUnavailableException;
import com.markozajc.akiwrapper.core.exceptions.*;
import com.markozajc.akiwrapper.core.impl.AkiwrapperImpl;
import com.markozajc.akiwrapper.core.utils.Servers;

Expand Down Expand Up @@ -88,7 +83,7 @@ public Akiwrapper build() throws ServerNotFoundException {
LOG.warn("Failed to construct an instance, trying the next available server", e);
}
} while (serverList.next());
throw new ServerUnavailableException("AW-KO MULTIPLE FAILS");
throw new ServerUnavailableException("KO - NO SERVER AVAILABLE");
} else {
LOG.debug("Given Server is not a ServerList, only attempting to build once.");
return new AkiwrapperImpl(server, this.filterProfanity);
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
Loading

0 comments on commit 7902fd8

Please sign in to comment.