-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow global registration of custom XStream converters. #1010
Conversation
This lets us provide converters for classes that we cannot annotate with @XStreamConverter directly.
Nice one @rankinc! This will enable using classes such as As an alternative, did you consider using
|
I did consider using However, if the principle of registering global converters in this way is acceptable then I don't see why we shouldn't register global transformers too. TBH, I'm not a fan of using the
However, I figured this pull would be more likely to be merged if it reused existing annotations ;-). |
ConverterMatcher matcher = converter.value().newInstance(); | ||
if (matcher instanceof Converter) { | ||
xStream.registerConverter((Converter) matcher, converter.priority()); | ||
} |
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 just came across this in attempting to use this feature (which is excellent!) It looks like SingleValueConverter
s are treated separately from other Converters
and are not type-compatible, so in order to properly use SingleValueConverter
s with the global registration, there would need to be a second if statement here to handle them.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This lets us provide converters for any classes that we cannot annotate directly with
@XStreamConverter
. For example,The existing
@XStreamConverter
annotations are being reused for consistency. TheRuntimeOptionsFactory
will check for these annotations on the same class that has the@CucumberOptions
annotation, which keeps this change nicely internal tocucumber-core
.