Skip to content

Add option for generating toString() methods basing on fields #34

@alexander-yevsyukov

Description

@alexander-yevsyukov

Have a look at the Twitter thread which hinted me on this feature. The thread shows the way TypeScript defines new types basing on values of other types used in a string form.

Currently we have an ability in Java to add a mix-in interface which would allow to have a custom toString(), but it's too much work. A more simple approach would be to have a type option, which would be used by a Model Compiler for a corresponding language. Something like this:

message Length {
   option (string_form) = "${value}${units}";
   int value = 1 [(required) = true];
   LengthUnit units = 2 [(required) = true];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions