Skip to content

Commit

Permalink
Clean up unused validateFieldName() and use existing methods for Text…
Browse files Browse the repository at this point in the history
…EmbeddingProcessorIT (#1074)

Signed-off-by: Yizhe Liu <[email protected]>
  • Loading branch information
yizheliu-amazon authored and martin-gaievski committed Jan 13, 2025
1 parent 597d2b4 commit 6be95ce
Showing 1 changed file with 0 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,30 +296,6 @@ private static void unflattenSingleItem(String key, Object value, Map<String, Ob
}
}

/**
* Validate if field name is in correct format, which is either "a", or "a.b.c".
* If field name is like "..a..b", "a..b", "a.b..", it should be invalid.
* This is done via checking if a string contains empty segments when split by dots.
*
* @param input the string to check
* @throws IllegalArgumentException if the input is null or has invalid dot usage
*/
private static void validateFieldName(String input) {
if (StringUtils.isBlank(input)) {
throw new IllegalArgumentException("Field name cannot be null or empty");
}

// Use split with -1 limit to preserve trailing empty strings
String[] segments = input.split("\\.", -1);

// Check if any segment is empty
for (String segment : segments) {
if (StringUtils.isBlank(segment)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "Field name '%s' contains invalid dot usage", input));
}
}
}

// Helper classes to maintain state during iteration
private static class ProcessJsonObjectItem {
String key;
Expand Down

0 comments on commit 6be95ce

Please sign in to comment.