You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Throws java.lang.IllegalStateException: cannot modify binding: already bound to a property.
However setting the converter and binding in one line like this: builder.withConverter(new StringToIntegerConverter("error")).bind() or saving it like this: builder = builder.withConverter(new StringToIntegerConverter("error")). works as expected.
I think needing to "save" the builder is inconsistent, as for what I've tested this is not needed in the case of a Validator (and not quite what one would expect of a builder).
The main idea is to use the binding builder as a fluid API, chaining the commands. The typing of the builder actually changes when you apply a converter to it (String -> Integer), which can't be made type-safe to use with method references (.bind(IntItem::getValue, IntItem::setValue)) without this type of approach.
Yes I understand, what I attached is just a sample to show the error, and of course could be changed to used a fluid API.
In practice, to avoid repeating myself, I have generic methods to build and bind fields, otherwise, I would have waaay too much repeated code. In these cases I have to check things before setting converters, or iterate over a list of validators, etc., and cannot use the fluid API.
if you have your own piece of code that figures out what converter you need, you can actually always apply a converter (see: Converter.identity()) and chain a converter same way every time.
I have found that when binding a field, and setting a converter, the builder does not work as expected.
The following:
Throws
java.lang.IllegalStateException: cannot modify binding: already bound to a property.However setting the converter and binding in one line like this:
builder.withConverter(new StringToIntegerConverter("error")).bind()or saving it like this:builder = builder.withConverter(new StringToIntegerConverter("error")). works as expected.I think needing to "save" the builder is inconsistent, as for what I've tested this is not needed in the case of a Validator (and not quite what one would expect of a builder).
Here's a simple example: https://gist.github.com/jrfinc/c8414af2eaaec0c081ccead78df26907
I'm using
8.1.beta3but I've tested it with8.1-SNAPSHOTtoo.The text was updated successfully, but these errors were encountered: