Skip to content

Commit

Permalink
Reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
samleeflang committed Nov 18, 2024
1 parent 94cd2a4 commit 13c41c9
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ private static void handleMultipleAgents(
List<Agent> agents, String agentValue, String agentId, AgentRoleType role, Type type) {
var ids = new String[0];
var agentValues = new String[0];
if (agentValue != null && (agentValue.contains("&") || agentValue.contains("|"))) {
if (checkIfNeedsParsing(agentValue)) {
agentValues = Arrays.stream(agentValue.split("[&|]")).map(String::trim)
.toArray(String[]::new);
}
if (agentId != null && (agentId.contains("&") || agentId.contains("|"))) {
if (checkIfNeedsParsing(agentId)) {
ids = Arrays.stream(agentId.split("[&|]")).map(String::trim).toArray(String[]::new);
}
if (agentValues.length == ids.length) {
Expand All @@ -96,4 +96,8 @@ private static void handleMultipleAgents(
}
}
}

private static boolean checkIfNeedsParsing(String value) {
return value != null && (value.contains("&") || value.contains("|"));
}
}

0 comments on commit 13c41c9

Please sign in to comment.