NestedNameToEnum maps the Enums in the ContainerDescriptor to a map from nested name to Enum. Returns error if Enums do not have unique nested names within the ContainerDescriptor, which should generally never happen for properly-formed ContainerDescriptors.
(containerDescriptor ContainerDescriptor)
| 673 | // Returns error if Enums do not have unique nested names within the ContainerDescriptor, |
| 674 | // which should generally never happen for properly-formed ContainerDescriptors. |
| 675 | func NestedNameToEnum(containerDescriptor ContainerDescriptor) (map[string]Enum, error) { |
| 676 | nestedNameToEnum := make(map[string]Enum) |
| 677 | if err := ForEachEnum( |
| 678 | func(enum Enum) error { |
| 679 | nestedName := enum.NestedName() |
| 680 | if _, ok := nestedNameToEnum[nestedName]; ok { |
| 681 | return fmt.Errorf("duplicate enum: %q", nestedName) |
| 682 | } |
| 683 | nestedNameToEnum[nestedName] = enum |
| 684 | return nil |
| 685 | }, |
| 686 | containerDescriptor, |
| 687 | ); err != nil { |
| 688 | return nil, err |
| 689 | } |
| 690 | return nestedNameToEnum, nil |
| 691 | } |
| 692 | |
| 693 | // NestedNameToExtension maps the Enums in the ContainerDescriptor to a map from |
| 694 | // nested name to extension Field. |
no test coverage detected
searching dependent graphs…