Class ProtoEnumNameUtils


  • public class ProtoEnumNameUtils
    extends java.lang.Object
    Because in Go enums are in a shared namespace, one of protobuf common practices is to prefix the enums with enum name prefix to create unique names. The final result is verbose and when we use a string representation of some enum in different parts of the system (history json or search attribute types), we use a short version without prefix in camel case. So, protobuf enum EventType.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED gets converted to "WorkflowExecutionStarted"

    AIP 126
    - The other values should not be prefixed by the name of the enum itself. This generally requires users to write MyState.MYSTATE_ACTIVE in their code, which is unnecessarily verbose. - To avoid sharing values, APIs may prefix enum values with the name of the enum. In this case, they must do so consistently within the enum.

    See Also:
    AIP 126, Related commit to Go Proto module
    • Field Detail

      • WORKFLOW_TASK_FAILED_CAUSE_PREFIX

        public static final java.lang.String WORKFLOW_TASK_FAILED_CAUSE_PREFIX
        See Also:
        Constant Field Values
      • INDEXED_VALUE_TYPE_PREFIX

        public static final java.lang.String INDEXED_VALUE_TYPE_PREFIX
        See Also:
        Constant Field Values
      • ENUM_CLASS_TO_PREFIX

        public static final java.util.Map<java.lang.Class<?>,​java.lang.String> ENUM_CLASS_TO_PREFIX
    • Constructor Detail

      • ProtoEnumNameUtils

        public ProtoEnumNameUtils()
    • Method Detail

      • uniqueToSimplifiedName

        @Nonnull
        public static java.lang.String uniqueToSimplifiedName​(@Nonnull
                                                              java.lang.Enum<?> enumm)
      • uniqueToSimplifiedName

        public static java.lang.String uniqueToSimplifiedName​(java.lang.String protoEnumName,
                                                              java.lang.String prefix)
      • simplifiedToUniqueName

        public static java.lang.String simplifiedToUniqueName​(java.lang.String enumName,
                                                              java.lang.String prefix)