Skip to content
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

Using more than one @XStreamAlias annotation for same element #104

Open
wertklop opened this issue Jan 15, 2018 · 5 comments
Open

Using more than one @XStreamAlias annotation for same element #104

wertklop opened this issue Jan 15, 2018 · 5 comments
Assignees
Milestone

Comments

@wertklop
Copy link

wertklop commented Jan 15, 2018

Improvement. I would like to have an implementation that support:

@XStreamAlias("alias1")
@XStreamAlias("alias2")
class ABC{

    @XStreamAlias("field1")
    @XStreamAlias("field2")
    String field;
}

Where xml node has been named any present aliases.
Thank's

@joehni joehni self-assigned this Jan 15, 2018
@joehni
Copy link
Member

joehni commented Jan 15, 2018

You can do this without annotations using the XStream.alias() and XStream.aliasField() methods. However, this is no usual setup and you have to know, that a second alias definition will clobber the first one at serialization time, but will remain active for deserialization.

@joehni joehni closed this as completed Jun 7, 2018
@sewe
Copy link

sewe commented Feb 14, 2019

@joehni FWIW, I would also like to see @XStreamAlias be made @Repeatable. Of course, during serialization one of the alias definitions has to be picked, but as long as the choice is deterministic, I think there is not much risk of confusion. And it would really simplify working with types which (unfortunately) have suffered multiple rounds of renaming in the past (you know, naming is a hard problem).

@tetianakh
Copy link

@joehni I would like @XStreamAlias to be repeatable too. Clients send us XMLs with different names for the same fields, and we (sadly) have to support this. For example, the following snippets have to be treated identically:
<item-ids><item>123</item></item-ids> // lower case field name
<item-ids><Item>123</Item></item-ids> // capitalized field name

@bzurmaar
Copy link

Quite honestly I don't understand why this got closed so fast. It would be easy to make the annotation repeatable. The currenty state forces you to stray your meta data in annotations and extra-code when you want to have more than one alias. I support the original request. @tetianakh also delivered a scenario which developers find themselves in quite frequently.

@joehni
Copy link
Member

joehni commented Feb 13, 2024

So I keep it open for now...

@joehni joehni reopened this Feb 13, 2024
@joehni joehni added this to the 1.5.x milestone Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants