Skip to content

Translate enums with values #19

Description

@paulirwin

I think we can translate enums with values to be sealed classes with public static readonly members.

Example:

public enum LineSeparator {
    CR("\r", "CR (\\r)"),
    LF("\n", "LF (\\n)"),
    CRLF("\r\n", "CRLF (\\r\\n)");

    private final String text;
    private final String description;

    LineSeparator(String text, String description) {
        this.text = text;
        this.description = description;
    }

    // ... other methods here
}

Output:

public sealed class LineSeparator 
{
    public static readonly LineSeparator CR = new LineSeparator("\r", "CR (\\r)");

    public static readonly LineSeparator LF = new LineSeparator("\n", "LF (\\n)");

    public static readonly LineSeparator CRLF = new LineSeparator("\r\n", "CRLF (\\r\\n)");

    private readonly string text;
    private readonly string description;
    
    private LineSeparator(string text, string description)
    {
        this.text = text;
        this.description = description;
    }

    // ... other methods here
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions