# 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 Compute
    module Property
      class RegionDeprecated
        attr_reader :arguments

        attr_reader :deleted

        attr_reader :deprecated

        attr_reader :obsolete

        attr_reader :replacement

        attr_reader :state

        def initialize(arguments = nil, parent_identifier = nil)
          @arguments = arguments
          return if arguments.nil?
          @parent_identifier = parent_identifier
          @deleted = parse_time_string(arguments['deleted'])
          @deprecated = parse_time_string(arguments['deprecated'])
          @obsolete = parse_time_string(arguments['obsolete'])
          @replacement = arguments['replacement']
          @state = arguments['state']
        end

        def to_s
          "#{@parent_identifier} RegionDeprecated"
        end

        def self.un_parse(item, current_path)
          return if item.nil?
          way_to_parse = {
            'deleted' => ->(x, path) { x.nil? ? [] : ["its('#{path}.deleted.to_s') { should cmp '#{x.inspect}' }"] },
            'deprecated' => ->(x, path) { x.nil? ? [] : ["its('#{path}.deprecated.to_s') { should cmp '#{x.inspect}' }"] },
            'obsolete' => ->(x, path) { x.nil? ? [] : ["its('#{path}.obsolete.to_s') { should cmp '#{x.inspect}' }"] },
            'replacement' => ->(x, path) { x.nil? ? [] : ["its('#{path}.replacement') { should cmp #{x.inspect} }"] },
            'state' => ->(x, path) { x.nil? ? [] : ["its('#{path}.state') { 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
