Class Descriptors.EnumDescriptor

    • Method Detail

      • isClosed

        public boolean isClosed()
        Determines if the given enum is closed.

        Closed enum means that it:

        • Has a fixed set of values, rather than being equivalent to an int32.
        • Encountering values not in this set causes them to be treated as unknown fields.
        • The first value (i.e., the default) may be nonzero.

        WARNING: Some runtimes currently have a quirk where non-closed enums are treated as closed when used as the type of fields defined in a `syntax = proto2;` file. This quirk is not present in all runtimes; as of writing, we know that:

        • C++, Java, and C++-based Python share this quirk.
        • UPB and UPB-based Python do not.
        • PHP and Ruby treat all enums as open regardless of declaration.

        Care should be taken when using this function to respect the target runtime's enum handling quirks.

      • getContainingType

        public Descriptors.Descriptor getContainingType()
        If this is a nested type, get the outer descriptor, otherwise null.
      • isReservedNumber

        public boolean isReservedNumber​(int number)
        Determines if the given field number is reserved.
      • isReservedName

        public boolean isReservedName​(java.lang.String name)
        Determines if the given field name is reserved.
      • findValueByName

        public Descriptors.EnumValueDescriptor findValueByName​(java.lang.String name)
        Find an enum value by name.
        Parameters:
        name - the unqualified name of the value such as "FOO"
        Returns:
        the value's descriptor, or null if not found
      • findValueByNumberCreatingIfUnknown

        public Descriptors.EnumValueDescriptor findValueByNumberCreatingIfUnknown​(int number)
        Get the enum value for a number. If no enum value has this number, construct an EnumValueDescriptor for it.