Skip to content

EnumValues do not have the same order in TypeScript as in Java #103

Description

@mkowalzik
public enum Status {
   DEVELOPMENT,
   SUSPENDED,
   ACTIVE,
   DEACTIVATED,
   EXPIRED;

   public static Status fromValue(String v) {
       if (StringUtils.isBlank(v))
           return null;
       int index = NumberUtils.toInt(v);
       return Status.values()[index];
   }
}

is gernated as

export enum Status {
   "SUSPENDED",
   "EXPIRED",
   "DEVELOPMENT",
   "ACTIVE",
   "DEACTIVATED"
}

This seems to be the problem:

return enumElement.getEnclosedElements().stream()
               .filter(e -> ElementKind.ENUM_CONSTANT.equals(e.getKind()))
               .map(e -> new EnumValue(e.getSimpleName().toString()))
               .collect(Collectors.toSet()); //<-- Collectors.toSet() does not make any guarantees on anything, in fact it is also an unordered Collector

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions