Skip to content

Commit

Permalink
Allow for JSON array objects in name generation data and improve erro…
Browse files Browse the repository at this point in the history
…r messaging (#4785)
  • Loading branch information
labkey-susanh authored Sep 29, 2023
1 parent 0078ff1 commit bc7edda
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/src/org/labkey/api/data/NameGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -668,9 +669,13 @@ else if (value instanceof Collection)
Collection<?> coll = (Collection)value;
values = coll.stream().map(String::valueOf);
}
else if (value instanceof JSONArray jsonArray)
{
values = jsonArray.toList().stream().map(String::valueOf);
}
else
{
throw new IllegalStateException("Expected string or collection for '" + parentColName + "': " + value);
throw new IllegalStateException("For parent values in naming pattern, expected string or collection for '" + parentColName + "': " + value);
}

return values
Expand Down

0 comments on commit bc7edda

Please sign in to comment.