Class: Types::Type_definition::TypeDefinition

Inherits:
Thrift::Union show all
Includes:
Thrift::Struct_Union
Defined in:
lib/types/type_definition/type_definition_types.rb,
lib/types/type_definition/type_definition_types.rb

Constant Summary collapse

NAME =
'TypeDefinition'.freeze
NAMESPACE =
'types.type_definition'.freeze
LEGACY_ANNOTATIONS =
{
}.freeze
STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_INDEX_SCALAR_TYPE =
1
THRIFT_FIELD_INDEX_LIST_TYPE =
2
THRIFT_FIELD_INDEX_MAP_TYPE =
3
THRIFT_FIELD_INDEX_SET_TYPE =
4
THRIFT_FIELD_INDEX_REFERENCE_TYPE =
8
THRIFT_FIELD_SCALAR_TYPE_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_SCALAR_TYPE_STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_LIST_TYPE_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_LIST_TYPE_STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_MAP_TYPE_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_MAP_TYPE_STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_SET_TYPE_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_SET_TYPE_STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_REFERENCE_TYPE_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_REFERENCE_TYPE_STRUCTURED_ANNOTATIONS =
[
].freeze
FIELDS =
{
  THRIFT_FIELD_INDEX_SCALAR_TYPE => {type: ::Thrift::Types::I32, name: 'scalar_type', optional: true, enum_class: ::Types::Type_definition::ScalarType, legacy_annotations: THRIFT_FIELD_SCALAR_TYPE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_SCALAR_TYPE_STRUCTURED_ANNOTATIONS},
  THRIFT_FIELD_INDEX_LIST_TYPE => {type: ::Thrift::Types::STRUCT, name: 'list_type', class: ::Types::Type_definition::ListTypeDefinition, optional: true, legacy_annotations: THRIFT_FIELD_LIST_TYPE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_LIST_TYPE_STRUCTURED_ANNOTATIONS},
  THRIFT_FIELD_INDEX_MAP_TYPE => {type: ::Thrift::Types::STRUCT, name: 'map_type', class: ::Types::Type_definition::MapTypeDefinition, optional: true, legacy_annotations: THRIFT_FIELD_MAP_TYPE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_MAP_TYPE_STRUCTURED_ANNOTATIONS},
  THRIFT_FIELD_INDEX_SET_TYPE => {type: ::Thrift::Types::STRUCT, name: 'set_type', class: ::Types::Type_definition::SetTypeDefinition, optional: true, legacy_annotations: THRIFT_FIELD_SET_TYPE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_SET_TYPE_STRUCTURED_ANNOTATIONS},
  THRIFT_FIELD_INDEX_REFERENCE_TYPE => {type: ::Thrift::Types::STRUCT, name: 'reference_type', class: ::Thrift::Types::Core::Reference, optional: true, legacy_annotations: THRIFT_FIELD_REFERENCE_TYPE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_REFERENCE_TYPE_STRUCTURED_ANNOTATIONS}
}.freeze

Constants included from Thrift::Struct_Union

Thrift::Struct_Union::CONTAINER_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Thrift::Struct_Union

#each_field, #field_info, #inspect_collection, #inspect_field, #is_container?, #name_to_id, #read_field, #sorted_field_ids, #write_container, #write_data

Methods inherited from Thrift::Union

#<=>, #==, field_accessor, generate_accessors, #get_set_field, #get_value, #hash, #initialize, #inspect, qmark_isset_method, #read, #write

Constructor Details

This class inherits a constructor from Thrift::Union

Class Method Details

.list_type(val) ⇒ Object



165
166
167
# File 'lib/types/type_definition/type_definition_types.rb', line 165

def list_type(val)
  TypeDefinition.new(:list_type, val)
end

.map_type(val) ⇒ Object



169
170
171
# File 'lib/types/type_definition/type_definition_types.rb', line 169

def map_type(val)
  TypeDefinition.new(:map_type, val)
end

.reference_type(val) ⇒ Object



177
178
179
# File 'lib/types/type_definition/type_definition_types.rb', line 177

def reference_type(val)
  TypeDefinition.new(:reference_type, val)
end

.scalar_type(val) ⇒ Object



161
162
163
# File 'lib/types/type_definition/type_definition_types.rb', line 161

def scalar_type(val)
  TypeDefinition.new(:scalar_type, val)
end

.set_type(val) ⇒ Object



173
174
175
# File 'lib/types/type_definition/type_definition_types.rb', line 173

def set_type(val)
  TypeDefinition.new(:set_type, val)
end

Instance Method Details

#struct_fieldsObject



226
# File 'lib/types/type_definition/type_definition_types.rb', line 226

def struct_fields; FIELDS; end

#validateObject

Raises:

  • (StandardError)


228
229
230
231
232
233
# File 'lib/types/type_definition/type_definition_types.rb', line 228

def validate
  raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
  if get_set_field == :scalar_type
    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field scalar_type!') unless ::Types::Type_definition::ScalarType::VALID_VALUES.include?(get_value)
  end
end