Skip to content

HyphenStyle ignores @Element(name) #45

@gdm-tts

Description

@gdm-tts

Using HyphenStyle overrides any name specified in the @Element annotation.

Example

@Root(name = "test")
public class Test {
    @Element
    public String backgroundColor;
    @Element(name = "color1")
    public String color1;

    public static void main(String[] arg) throws Exception {
        Test t = new Test();
        t.backgroundColor = "#001122";

        t.color1 = "#334455";
        Style style = new HyphenStyle();
        Format format = new Format(style);
        Persister serializer = new Persister(format);
        serializer.write(t, System.out);
    }
}

Produces:

<test>
   <background-color>#001122</background-color>
   <color-1>#334455</color-1>
</test>

Desired output:

<test>
   <background-color>#001122</background-color>
   <color1>#334455</color1>
</test>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions