-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle the {index} parameter like a native MessageFormat argument. #969
base: main
Are you sure you want to change the base?
Conversation
For example that allows to specified leading zero by using {index,number,0000}
String finalPattern = pattern.replaceAll("\\{index\\}", | ||
Integer.toString(index)); | ||
String finalPattern = pattern; | ||
Pattern indexMatcherPattern = Pattern.compile("(\\{)index([^\\}]*\\})"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract a constant for this Pattern?
Please add some tests for this. |
Pattern indexMatcherPattern = Pattern.compile("(\\{)index([^\\}]*\\})"); | ||
Matcher matcher = indexMatcherPattern.matcher(pattern); | ||
if (matcher.find()) { | ||
String idxPattern = matcher.group(1) + 0 + matcher.group(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use "0"
instead of 0
, because it is clearer.
* extract a constant for this Pattern * use while loop (replace and not replaceall) * use "0" instead of 0
@@ -163,6 +165,8 @@ | |||
* @since 4.0 | |||
*/ | |||
public class Parameterized extends Suite { | |||
private static final String INDEX_MATCHER_PATTERN = "(\\{)index([^\\}]*\\})"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant create a constant for the Pattern. Compiling a pattern isn't cheap
Looks like an interesting addition. This also requires adjusting the documentation. I would suggest adding an extra paragraph (after line 75 in the changed file) giving a number of insightful and compelling examples on how to make good use of this new feature. |
Should the conflicts be fixed, or maybe it's too late and we should just close this pull request? |
For example that allows to specified leading zero by using
{index,number,0000}