This class acts as a tagged union. Only one of the ``is_*`` methods will return true. To get the associated value of a tag (if one exists), use the corresponding ``get_*`` method. :ivar str file_properties.PropertiesSearchMode.field_name: Search for a value associated with
| 936 | PropertiesSearchMatch_validator = bv.Struct(PropertiesSearchMatch) |
| 937 | |
| 938 | class PropertiesSearchMode(bb.Union): |
| 939 | """ |
| 940 | This class acts as a tagged union. Only one of the ``is_*`` methods will |
| 941 | return true. To get the associated value of a tag (if one exists), use the |
| 942 | corresponding ``get_*`` method. |
| 943 | |
| 944 | :ivar str file_properties.PropertiesSearchMode.field_name: Search for a |
| 945 | value associated with this field name. |
| 946 | """ |
| 947 | |
| 948 | _catch_all = 'other' |
| 949 | # Attribute is overwritten below the class definition |
| 950 | other = None |
| 951 | |
| 952 | @classmethod |
| 953 | def field_name(cls, val): |
| 954 | """ |
| 955 | Create an instance of this class set to the ``field_name`` tag with |
| 956 | value ``val``. |
| 957 | |
| 958 | :param str val: |
| 959 | :rtype: PropertiesSearchMode |
| 960 | """ |
| 961 | return cls('field_name', val) |
| 962 | |
| 963 | def is_field_name(self): |
| 964 | """ |
| 965 | Check if the union tag is ``field_name``. |
| 966 | |
| 967 | :rtype: bool |
| 968 | """ |
| 969 | return self._tag == 'field_name' |
| 970 | |
| 971 | def is_other(self): |
| 972 | """ |
| 973 | Check if the union tag is ``other``. |
| 974 | |
| 975 | :rtype: bool |
| 976 | """ |
| 977 | return self._tag == 'other' |
| 978 | |
| 979 | def get_field_name(self): |
| 980 | """ |
| 981 | Search for a value associated with this field name. |
| 982 | |
| 983 | Only call this if :meth:`is_field_name` is true. |
| 984 | |
| 985 | :rtype: str |
| 986 | """ |
| 987 | if not self.is_field_name(): |
| 988 | raise AttributeError("tag 'field_name' not set") |
| 989 | return self._value |
| 990 | |
| 991 | def _process_custom_annotations(self, annotation_type, field_path, processor): |
| 992 | super(PropertiesSearchMode, self)._process_custom_annotations(annotation_type, field_path, processor) |
| 993 | |
| 994 | PropertiesSearchMode_validator = bv.Union(PropertiesSearchMode) |
| 995 |