From 6fbe25edadceafb6e0f46bd6a0380e89aad0dafc Mon Sep 17 00:00:00 2001 From: iiAhmedYT <61851106+iiAhmedYT@users.noreply.github.com> Date: Wed, 17 Jul 2024 02:40:08 +0300 Subject: [PATCH] Optimize requirements and some utils --- .../itsme/itsmyconfig/requirement/RequirementManager.java | 7 ++++++- src/main/java/to/itsme/itsmyconfig/util/Strings.java | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/to/itsme/itsmyconfig/requirement/RequirementManager.java b/src/main/java/to/itsme/itsmyconfig/requirement/RequirementManager.java index 8da805f..26853ed 100644 --- a/src/main/java/to/itsme/itsmyconfig/requirement/RequirementManager.java +++ b/src/main/java/to/itsme/itsmyconfig/requirement/RequirementManager.java @@ -30,7 +30,12 @@ public final class RequirementManager { * @return the Requirement object that matches the given type, or null if no match is found */ public Requirement getRequirementByType(final String type) { - return this.requirements.stream().filter(requirement -> requirement.matchIdentifier(type)).findAny().orElse(null); + for (final Requirement requirement : this.requirements) { + if (requirement.matchIdentifier(type)) { + return requirement; + } + } + return null; } /** diff --git a/src/main/java/to/itsme/itsmyconfig/util/Strings.java b/src/main/java/to/itsme/itsmyconfig/util/Strings.java index 5845e79..5c8a0e1 100644 --- a/src/main/java/to/itsme/itsmyconfig/util/Strings.java +++ b/src/main/java/to/itsme/itsmyconfig/util/Strings.java @@ -217,12 +217,12 @@ public static String integerToRoman(int num) { } /** - * Converts a list of objects to a string, where each object is represented on a new line. + * Converts a list of strings to a string, where each string is represented on a new line. * - * @param list The list of objects to be converted to a string. + * @param list The list of strings to be converted to a string. * @return The string representation of the list. */ - public static String toString(final @NotNull List list) { + public static String toString(final @NotNull List list) { return String.join(System.lineSeparator(), list.stream().map(Object::toString).toArray(String[]::new)); }