diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/ListFormatter.java b/base/src/main/java/de/staropensource/sosengine/base/utility/ListFormatter.java index d212683b..51e66254 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/ListFormatter.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/ListFormatter.java @@ -19,10 +19,8 @@ package de.staropensource.sosengine.base.utility; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; @@ -46,9 +44,20 @@ public final class ListFormatter { * @param array array to convert * @return formatted string */ - @ApiStatus.Experimental() // TODO public static @NotNull String formatArray(@NotNull Object[] array) { - return Arrays.toString(array); + StringBuilder output = new StringBuilder(); + + for (int index = 0; index < array.length; index++) { + if (!output.isEmpty()) + if (index == array.length - 1) + output.append(" & "); + else + output.append(", "); + + output.append(array[index]); + } + + return output.toString(); } /** @@ -57,9 +66,8 @@ public final class ListFormatter { * @param set set to convert * @return formatted string */ - @ApiStatus.Experimental() // TODO public static @NotNull String formatSet(@NotNull Set set) { - return set.toString(); + return formatArray(set.toArray()); } /** @@ -68,9 +76,8 @@ public final class ListFormatter { * @param list list to convert * @return formatted string */ - @ApiStatus.Experimental() // TODO public static @NotNull String formatList(@NotNull List list) { - return list.toString(); + return formatArray(list.toArray()); } /** @@ -79,8 +86,23 @@ public final class ListFormatter { * @param map map to convert * @return formatted string */ - @ApiStatus.Experimental() // TODO public static @NotNull String formatMap(@NotNull Map map) { - return map.toString(); + StringBuilder output = new StringBuilder(); + + int index = 0; + for (Object key : map.keySet()) { + if (!output.isEmpty()) + if (index == map.size() - 1) + output.append(" & "); + else + output.append(", "); + + output + .append(key) + .append("=") + .append(map.get(key)); + } + + return output.toString(); } } diff --git a/testapp/build.gradle b/testapp/build.gradle index 7ea04985..8b955206 100644 --- a/testapp/build.gradle +++ b/testapp/build.gradle @@ -22,7 +22,7 @@ import org.mikeneck.graalvm.BuildTypeSelector // Plugins plugins { id("java") - id "application" + id("application") id("io.freefair.lombok") version("${pluginLombok}") id("io.github.goooler.shadow") version("${pluginShadow}") id('org.mikeneck.graalvm-native-image') version("${pluginNativeImage}")