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

protobuf枚举类需要支持自定义value #414

Closed
KING754 opened this issue Dec 16, 2024 · 1 comment
Closed

protobuf枚举类需要支持自定义value #414

KING754 opened this issue Dec 16, 2024 · 1 comment
Assignees
Labels
enhancement;功能增强 Function enhancement;功能增强 trick;使用技巧 trick;使用技巧

Comments

@KING754
Copy link

KING754 commented Dec 16, 2024

新增功能的使用场景

增加protobuf枚举类支持自定义value.
比如Channel:XIAOMI,OPPO,....
这种可能,其它地方已经定义好了。需要保持统一。

enum Channel {
  PC= 0;
  XIAOMI = 1001;
  OPPO = 1002;
  HW = 1003;
}
@iohao
Copy link
Owner

iohao commented Dec 16, 2024

java code

@ProtobufClass
@ProtoFileMerge(fileName = TempProtoFile.fileName, filePackage = TempProtoFile.filePackage)
public enum AnimalTypeEnum implements EnumReadable {
    /** the cat */
    cat(0),
    /** the tiger */
    tiger(10),
    ;

    final int value;

    AnimalTypeEnum(int value) {
        this.value = value;
    }

    @Override
    public int value() {
        return this.value;
    }
}

generate .proto

// TestAnimalTypeEnum
enum AnimalTypeEnum {
  // the cat
  cat = 0;
  // the tiger
  tiger = 10;
}

@iohao iohao self-assigned this Dec 16, 2024
@iohao iohao added trick;使用技巧 trick;使用技巧 enhancement;功能增强 Function enhancement;功能增强 future;将要提供 Features to be provided in the upcoming versions;近期版本将要提供的功能 labels Dec 16, 2024
@KING754 KING754 closed this as completed Dec 17, 2024
@iohao iohao reopened this Dec 17, 2024
@iohao iohao removed the future;将要提供 Features to be provided in the upcoming versions;近期版本将要提供的功能 label Jan 8, 2025
@iohao iohao closed this as completed Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement;功能增强 Function enhancement;功能增强 trick;使用技巧 trick;使用技巧
Projects
None yet
Development

No branches or pull requests

3 participants
@iohao @KING754 and others