From 17200c9e2d7796c12189607dbf09fefcaf222ffd Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 6 Dec 2023 21:28:08 +0100 Subject: [PATCH] Update dependencies and make code improvements Updated various dependency versions in the pom.xml file for better compatibility and performance. Utilized more efficient methods in the ExpressionUtils.java and StringUtils.java classes such as using isEmpty() instead of checking if the length is 0 and methods like getFirst() which is more intuitive. Also, handled version details better in application.yml and adjusted the version fetching mechanism in version_pom. --- pom.xml | 20 +++++++++---------- .../martials/api/utils/ExpressionUtils.java | 6 +++--- .../no/martials/api/utils/StringUtils.java | 2 +- src/main/resources/application.yml | 2 +- version_pom | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index f9be4e2..843bda2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,18 +5,18 @@ org.springframework.boot spring-boot-starter-parent - 3.0.0 + 3.1.5 com.github martials - 2.1.1 + 2.1.2 war simplify_truths_api simplify_truths_api - 17 + 21 @@ -32,36 +32,36 @@ org.springframework.boot spring-boot-starter-web - 3.0.4 + 3.1.5 org.springframework.boot spring-boot-devtools - 3.0.4 + 3.1.5 runtime true org.springframework.boot spring-boot-starter-tomcat - 3.0.4 + 3.1.5 provided org.springframework.boot spring-boot-starter-test - 3.0.4 + 3.1.5 test org.springdoc springdoc-openapi-starter-webmvc-ui - 2.0.4 + 2.2.0 com.fasterxml.jackson.module jackson-module-kotlin - 2.14.2 + 2.15.3 javax.servlet @@ -82,7 +82,7 @@ org.springframework.boot spring-boot-starter-actuator - 3.0.4 + 3.1.5 diff --git a/src/main/java/no/martials/api/utils/ExpressionUtils.java b/src/main/java/no/martials/api/utils/ExpressionUtils.java index 727d960..525d14d 100644 --- a/src/main/java/no/martials/api/utils/ExpressionUtils.java +++ b/src/main/java/no/martials/api/utils/ExpressionUtils.java @@ -201,7 +201,7 @@ else if (c == ')') { } } - CenterOperator op = operators.get(0); + CenterOperator op = operators.getFirst(); boolean allEqual = true; // Finds the rightmost operator with the lowest weight, if all the operators are equal, pick the center most @@ -253,7 +253,7 @@ public void isValid() throws ExpressionInvalidException, MissingCharacterExcepti if (matcher.find()) { throw new ExpressionInvalidException(language, matcher.group(), matcher.start()); } - else if (expression.length() == 0) { + else if (expression.isEmpty()) { throw new MissingCharacterException(language, 'A', 0); } @@ -284,7 +284,7 @@ else if (charAtI == ')') { } } } - if (brackets.size() > 0) { + if (!brackets.isEmpty()) { throw new MissingCharacterException(language, ')', expression.length()); } } diff --git a/src/main/java/no/martials/api/utils/StringUtils.java b/src/main/java/no/martials/api/utils/StringUtils.java index c296efc..54a3779 100644 --- a/src/main/java/no/martials/api/utils/StringUtils.java +++ b/src/main/java/no/martials/api/utils/StringUtils.java @@ -53,7 +53,7 @@ public static String replaceOperators(@NotNull String exp) { @NotNull public static String capitalizeFirstLetter(@NotNull String string) { - if (string.length() == 0) { + if (string.isEmpty()) { return ""; } return string.substring(0, 1).toUpperCase() + (string.length() > 1 ? string.substring(1) : ""); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 62fb34f..8a85f25 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -16,7 +16,7 @@ server: port: 8080 martials: - version: 2.1.1 + version: 2.1.2 api: dev-url: http://localhost:8080 prod-url: https://api.martials.no/simplify-truths/do diff --git a/version_pom b/version_pom index d31c2b4..4dad487 100644 --- a/version_pom +++ b/version_pom @@ -1,5 +1,5 @@ #!/bin/sh -version=$(cat src/main/resources/application.yml | grep version: | awk -F ': ' '{print $2}') +version=$(< src/main/resources/application.yml grep version: | awk -F ': ' '{print $2}') echo "Current version: $version, writing to pom.xml." xmlstarlet ed --inplace -N N="http://maven.apache.org/POM/4.0.0" -u '//N:project/N:version' -v "$version" pom.xml