Skip to content

Commit e907c27

Browse files
committed
Explanatory comment for regex
1 parent 72fb697 commit e907c27

File tree

1 file changed

+4
-1
lines changed
  • libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy

1 file changed

+4
-1
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ static String getEntitlementTypeName(Class<? extends Entitlement> entitlementCla
8080
}
8181

8282
var strippedClassName = entitlementClassName.substring(0, entitlementClassName.indexOf("Entitlement"));
83-
return Arrays.stream(strippedClassName.split("(?=\\p{Lu})"))
83+
// Identify word boundaries by uppercase letters with \p{Lu}, but retain those
84+
// characters, rather than discarding them as separators, with (?=).
85+
String[] words = strippedClassName.split("(?=\\p{Lu})");
86+
return Arrays.stream(words)
8487
.filter(Predicate.not(String::isEmpty))
8588
.map(s -> s.toLowerCase(Locale.ROOT))
8689
.collect(Collectors.joining("_"));

0 commit comments

Comments
 (0)