diff --git a/build.gradle b/build.gradle index 2180a82..f112f27 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'uk.ac.hutton.ics' -version '1.0.1' +version '1.0.2' sourceCompatibility = 11 diff --git a/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BaseResult.java b/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BaseResult.java index d27d007..80fd5a8 100644 --- a/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BaseResult.java +++ b/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BaseResult.java @@ -9,6 +9,10 @@ public class BaseResult private Metadata metadata = new Metadata(); private T result; + public BaseResult() + { + } + public BaseResult(T result, int currentPage, int pageSize, long totalCount) { this.result = result; diff --git a/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BrapiCall.java b/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BrapiCall.java index 3c02ca7..555231c 100644 --- a/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BrapiCall.java +++ b/src/main/java/uk/ac/hutton/ics/brapi/resource/base/BrapiCall.java @@ -39,7 +39,7 @@ public BrapiCall addVersion(Version version) public boolean hasDataType(DataType datatype) { - return dataTypes.contains(datatype.name()); + return dataTypes.contains(datatype.getType()); } public boolean hasMethod(Method method) @@ -49,7 +49,7 @@ public boolean hasMethod(Method method) public boolean hasVersion(Version version) { - return versions.contains(version.name()); + return versions.contains(version.getNumber()); } public String getService() @@ -65,7 +65,7 @@ public BrapiCall setService(String service) public List getDataTypes() { - return dataTypes.stream().map(DataType::valueOf).collect(Collectors.toList()); + return dataTypes.stream().map(DataType::getFromString).collect(Collectors.toList()); } public List getMethods() @@ -75,7 +75,7 @@ public List getMethods() public List getVersions() { - return versions.stream().map(Version::valueOf).collect(Collectors.toList()); + return versions.stream().map(Version::getFromString).collect(Collectors.toList()); } public enum DataType @@ -90,6 +90,21 @@ public enum DataType { this.type = type; } + + public String getType() { + return type; + } + + public static DataType getFromString(String type) + { + for (DataType dt : DataType.values()) + { + if (Objects.equals(dt.type, type)) + return dt; + } + + return null; + } } public enum Method @@ -114,5 +129,20 @@ public enum Version { this.number = number; } + + public String getNumber() { + return number; + } + + public static Version getFromString(String version) + { + for (Version v : Version.values()) + { + if (Objects.equals(v.number, version)) + return v; + } + + return null; + } } } \ No newline at end of file diff --git a/src/main/java/uk/ac/hutton/ics/brapi/resource/base/TokenPagination.java b/src/main/java/uk/ac/hutton/ics/brapi/resource/base/TokenPagination.java index 0b184ae..4d0f95f 100644 --- a/src/main/java/uk/ac/hutton/ics/brapi/resource/base/TokenPagination.java +++ b/src/main/java/uk/ac/hutton/ics/brapi/resource/base/TokenPagination.java @@ -21,7 +21,7 @@ public TokenPagination(int pageSize, String currentPageToken, long totalCount, i this.totalCount = totalCount; this.totalPages = (int) Math.ceil(totalCount / (float) desiredPageSize); - // If we can, generate valeus for prevPageToken and nextPageToken + // If we can, generate values for prevPageToken and nextPageToken int currentPage = Integer.parseInt(currentPageToken); if (currentPage >= 1) prevPageToken = String.valueOf(currentPage - 1); diff --git a/src/main/java/uk/ac/hutton/ics/brapi/resource/core/serverinfo/ServerInfo.java b/src/main/java/uk/ac/hutton/ics/brapi/resource/core/serverinfo/ServerInfo.java index 9be3642..da8d159 100644 --- a/src/main/java/uk/ac/hutton/ics/brapi/resource/core/serverinfo/ServerInfo.java +++ b/src/main/java/uk/ac/hutton/ics/brapi/resource/core/serverinfo/ServerInfo.java @@ -15,6 +15,10 @@ public class ServerInfo private String serverDescription; private String serverName; + public ServerInfo() + { + } + public List getCalls() { return calls;