diff --git a/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java b/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java index b5b21e4..b89e42e 100644 --- a/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java +++ b/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java @@ -65,11 +65,11 @@ private static void handleMultipleAgents( List 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) { @@ -96,4 +96,8 @@ private static void handleMultipleAgents( } } } + + private static boolean checkIfNeedsParsing(String value) { + return value != null && (value.contains("&") || value.contains("|")); + } }