From 02527761951327bbabdcbf0119f6208973e4bf48 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 1 Sep 2024 21:50:25 +0200 Subject: [PATCH] Fix warnings and duplicate check --- .../base/utility/DependencyResolver.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java b/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java index 62f8e5946..cfb68a0a2 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java @@ -177,14 +177,30 @@ public final class DependencyResolver { for (char character : dependency.toCharArray()) { switch (character) { case '=' -> { + // Check for duplicate + if (duplicateCheck[0]) + throw new IllegalStateException("The dependency listing \"" + dependency + "\" cannot include multiple '=' characters"); + + // Update mode mode = 1; + continue; } case '<' -> { + // Check for duplicate + if (duplicateCheck[1]) + throw new IllegalStateException("The dependency listing \"" + dependency + "\" cannot include multiple '<' characters"); + + // Update mode mode = 2; continue; } case '>' -> { + // Check for duplicate + if (duplicateCheck[2]) + throw new IllegalStateException("The dependency listing \"" + dependency + "\" cannot include multiple '>' characters"); + + // Update mode mode = 3; continue; } @@ -195,9 +211,6 @@ public final class DependencyResolver { case 0 -> identifier.append(character); // Version equal case 1 -> { - // Check for duplicate - if (character == '=' && duplicateCheck[0]) - throw new IllegalStateException("The dependency listing \"" + dependency + "\" cannot include multiple '=' characters"); duplicateCheck[0] = true; // Check for smaller and bigger than @@ -208,9 +221,6 @@ public final class DependencyResolver { } // Version smaller case 2 -> { - // Check for duplicate - if (character == '<' && duplicateCheck[1]) - throw new IllegalStateException("The dependency listing \"" + dependency + "\" cannot include multiple '<' characters"); duplicateCheck[1] = true; // Check for equal @@ -221,9 +231,6 @@ public final class DependencyResolver { } // Version bigger case 3 -> { - // Check for duplicate - if (character == '>' && duplicateCheck[2]) - throw new IllegalStateException("The dependency listing \"" + dependency + "\" cannot include multiple '>' characters"); duplicateCheck[2] = true; // Check for equal