# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
#     ***     AUTO GENERATED CODE    ***    AUTO GENERATED CODE     ***
#
# ----------------------------------------------------------------------------
#
#     This file is automatically generated by Magic Modules and manual
#     changes will be clobbered when the file is regenerated.
#
#     Please read more about how to change this file in README.md and
#     CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/bigquery/property/table_external_data_configuration_bigtable_options_column_families'
module GoogleInSpec
  module BigQuery
    module Property
      class TableExternalDataConfigurationBigtableOptions
        attr_reader :arguments

        attr_reader :ignore_unspecified_column_families

        attr_reader :read_rowkey_as_string

        attr_reader :column_families

        def initialize(arguments = nil, parent_identifier = nil)
          @arguments = arguments
          return if arguments.nil?
          @parent_identifier = parent_identifier
          @ignore_unspecified_column_families = arguments['ignoreUnspecifiedColumnFamilies']
          @read_rowkey_as_string = arguments['readRowkeyAsString']
          @column_families = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptionsColumnFamiliesArray.parse(arguments['columnFamilies'], to_s)
        end

        def to_s
          "#{@parent_identifier} TableExternalDataConfigurationBigtableOptions"
        end

        def self.un_parse(item, current_path)
          return if item.nil?
          way_to_parse = {
            'ignore_unspecified_column_families' => ->(x, path) { x.nil? ? [] : ["its('#{path}.ignore_unspecified_column_families') { should cmp #{x.inspect} }"] },
            'read_rowkey_as_string' => ->(x, path) { x.nil? ? [] : ["its('#{path}.read_rowkey_as_string') { should cmp #{x.inspect} }"] },
            'column_families' => ->(x, path) { x.nil? ? [] : x.map { |single| "its('#{path}.column_families') { should include '#{single.to_json}' }" } },
          }
          way_to_parse.map do |k, v|
            v.call(item.method(k).call, current_path)
          end
        end

        def to_json(*_args)
          @arguments.to_json
        end

        # other is a string representation of this object
        def ==(other)
          @arguments == JSON.parse(other)
        end
      end
    end
  end
end
