getEnumeratedTypes function

Iterable<EnumeratedType> getEnumeratedTypes(
  1. Root root, {
  2. bool excludeSealedClasses = false,
})

Return the enumerated types that must exist in the codec where the enumeration should be the key used in the buffer.

Implementation

Iterable<EnumeratedType> getEnumeratedTypes(
  Root root, {
  bool excludeSealedClasses = false,
}) sync* {
  int index = 0;

  for (final Enum customEnum in root.enums) {
    yield EnumeratedType(
      customEnum.name,
      index + minimumCodecFieldKey,
      CustomTypes.customEnum,
      associatedEnum: customEnum,
    );
    index += 1;
  }

  for (final Class customClass in root.classes) {
    if (!excludeSealedClasses || !customClass.isSealed) {
      yield EnumeratedType(
        customClass.name,
        index + minimumCodecFieldKey,
        CustomTypes.customClass,
        associatedClass: customClass,
      );
      index += 1;
    }
  }
}