Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 1.45 KB

20240222-3-kinds-boolean-issue.md

File metadata and controls

61 lines (41 loc) · 1.45 KB
title description
3 kinds Boolean support in ApiHug framework
bool should has 2 flag, but 3 design ways really freak out.

3 kinds Boolean

proto primitive:

//Define
bool flag =1;

//Assign
flag: true;

proto wrapper:

//Define
google.protobuf.BoolValue flag = 1;

//Assign
flag: {
    value: true;
}

ApiHug Enum:

//Define
hope.common.BoolType flag = 1;

//Assign
flag: TRUE;

Why

ApiHug pros cons Comment
Proto Primitive straightforward default always false as no default or optional present since proto3
Proto Wrapper support not set syntax a bit complex when assign you need a message wrapper
ApiHug Enum straightforward introduce depend on ApiHug Lib only used in meta generation no affect on application layer

Rule

Since ApiHug Lib 0.6.0-RELEASE and IDE Plugin version 0.2.0,avoid the usage of of Proto's primitive & wrapper ways, use ApiHug Enum as mandatory.

Otherwise the IDE plugin can not parse the AST tree, any bool dependent flag can not be picked up.

Refer

  1. Avoid Null Booleans in Java
  2. Wikipedia: Boolean algebra
  3. wikipedia: Three-valued logic