-
Notifications
You must be signed in to change notification settings - Fork 241
maybe() method now accepts a builder as parameter #34
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Can one of the admins verify this patch? |
ok to test |
* @return this builder | ||
*/ | ||
public Builder maybe(final Builder regex) { | ||
return this.group().add(regex.build().toString()).endGr().add("?"); |
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.
add()
can be used with builder. No need toString()
method
Can I make new version after it? |
think no need other methods - any of regex can be inserted with help of |
Changes Unknown when pulling 89cfa80 on Tavio:maybe_with_builder into * on VerbalExpressions:master*. |
1 similar comment
Changes Unknown when pulling 89cfa80 on Tavio:maybe_with_builder into * on VerbalExpressions:master*. |
I think it would be nice to have the same functionality for other methods, such as oneOf() or anythingBut(), for instance. Should a user want to use a complex regex inside anythingBut(), for instance, they would have to do something like:
Since it is the purpose of this library to facilitate the building and comprehension of expressions, it would be much nicer if the user could simply do:
Unless, of course, there is a simpler way of doing this solely with the add() method which I'm not seeing. |
ok, you convinced me |
maybe() method now accepts a builder as parameter
Will do! |
Actually, I'm not seeing the following form of usage suggested (given the green light?) above, implemented in the code
What am I missing? |
This is simply not implemented yet. |
Ah, okay, just making sure. Thanks.
…On Sun, Dec 3, 2017 at 10:10 PM, Kirill Merkushev ***@***.***> wrote:
This is simply not implemented yet.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#34 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEw747-ypYv8EBas3h-wZpQNvsrI2Ngaks5s8wAbgaJpZM4Datpp>
.
|
I propose that all Builder methods which accept a string as parameter should have another version that accepts another Builder as parameter. This would allow users to break their expressions into smaller expressions, thus making their code more readable and maintainable. I built a test showing an example of an expression built with the oneOf() method being passed as the parameter for the maybe() method (with the current code this would not be possible, as the contents of the oneOf() expression would all be escaped with ).
If you guys think this is a good idea, I will open another PR implementing the same idea for all other methods of the Builder class.