# 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.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
  module BigQuery
    module Property
      class TableExternalDataConfigurationCsvOptions
        attr_reader :arguments

        attr_reader :allow_jagged_rows

        attr_reader :allow_quoted_newlines

        attr_reader :encoding

        attr_reader :field_delimiter

        attr_reader :quote

        attr_reader :skip_leading_rows

        def initialize(arguments = nil, parent_identifier = nil)
          @arguments = arguments
          return if arguments.nil?
          @parent_identifier = parent_identifier
          @allow_jagged_rows = arguments['allowJaggedRows']
          @allow_quoted_newlines = arguments['allowQuotedNewlines']
          @encoding = arguments['encoding']
          @field_delimiter = arguments['fieldDelimiter']
          @quote = arguments['quote']
          @skip_leading_rows = arguments['skipLeadingRows']
        end

        def to_s
          "#{@parent_identifier} TableExternalDataConfigurationCsvOptions"
        end

        def self.un_parse(item, current_path)
          return if item.nil?
          way_to_parse = {
            'allow_jagged_rows' => ->(x, path) { x.nil? ? [] : ["its('#{path}.allow_jagged_rows') { should cmp #{x.inspect} }"] },
            'allow_quoted_newlines' => ->(x, path) { x.nil? ? [] : ["its('#{path}.allow_quoted_newlines') { should cmp #{x.inspect} }"] },
            'encoding' => ->(x, path) { x.nil? ? [] : ["its('#{path}.encoding') { should cmp #{x.inspect} }"] },
            'field_delimiter' => ->(x, path) { x.nil? ? [] : ["its('#{path}.field_delimiter') { should cmp #{x.inspect} }"] },
            'quote' => ->(x, path) { x.nil? ? [] : ["its('#{path}.quote') { should cmp #{x.inspect} }"] },
            'skip_leading_rows' => ->(x, path) { x.nil? ? [] : ["its('#{path}.skip_leading_rows') { should cmp #{x.inspect} }"] },
          }
          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
