# frozen_string_literal: true

# This file is autogenerated by Deimos, Do NOT modify
module Schemas; module MyNamespace
  ### Primary Schema Class ###
  # Autogenerated Schema for Record at com.my-namespace.Generated
  class Generated < Deimos::SchemaClass::Record

    ### Secondary Schema Classes ###
    # Autogenerated Schema for Record at com.my-namespace.ARecord
    class ARecord < Deimos::SchemaClass::Record
  
      ### Attribute Accessors ###
      # @return [String]
      attr_accessor :a_record_field
  
      # @override
      def initialize(_from_message: false, a_record_field: nil)
        @_from_message = _from_message
        super
        self.a_record_field = a_record_field
      end
  
      # @override
      def schema
        'ARecord'
      end
  
      # @override
      def namespace
        'com.my-namespace'
      end
  
      # @override
      def as_json(_opts={})
        {
          'a_record_field' => @a_record_field
        }
      end
    end

    # Autogenerated Schema for Enum at com.my-namespace.AnEnum
    class AnEnum < Deimos::SchemaClass::Enum
      # @override
      def symbols
        %w(sym1 sym2)
      end
  
      
      def sym1?
        @value == 'sym1'
      end
      
      def sym2?
        @value == 'sym2'
      end
      
    end


    ### Attribute Readers ###
    # @return [AnEnum]
    attr_reader :an_enum
    # @return [ARecord]
    attr_reader :a_record

    ### Attribute Accessors ###
    # @return [String]
    attr_accessor :a_string
    # @return [Integer]
    attr_accessor :a_int
    # @return [Integer]
    attr_accessor :a_long
    # @return [Float]
    attr_accessor :a_float
    # @return [Float]
    attr_accessor :a_double
    # @return [nil, Integer]
    attr_accessor :an_optional_int
    # @return [Array<Integer>]
    attr_accessor :an_array
    # @return [Hash<String, String>]
    attr_accessor :a_map
    # @return [String]
    attr_accessor :timestamp
    # @return [String]
    attr_accessor :message_id

    ### Attribute Writers ###
    # @return [AnEnum]
    def an_enum=(value)
      @an_enum = AnEnum.initialize_from_value(value, from_message: self._from_message)
    end

    # @return [ARecord]
    def a_record=(value)
      @a_record = ARecord.initialize_from_value(value, from_message: self._from_message)
    end

    # @override
    def initialize(_from_message: false, a_string: nil,
                   a_int: nil,
                   a_long: nil,
                   a_float: nil,
                   a_double: nil,
                   an_optional_int: nil,
                   an_enum: nil,
                   an_array: nil,
                   a_map: nil,
                   timestamp: nil,
                   message_id: nil,
                   a_record: nil)
      @_from_message = _from_message
      super
      self.a_string = a_string
      self.a_int = a_int
      self.a_long = a_long
      self.a_float = a_float
      self.a_double = a_double
      self.an_optional_int = an_optional_int
      self.an_enum = an_enum
      self.an_array = an_array
      self.a_map = a_map
      self.timestamp = timestamp
      self.message_id = message_id
      self.a_record = a_record
    end

    # @override
    def schema
      'Generated'
    end

    # @override
    def namespace
      'com.my-namespace'
    end

    def self.tombstone(key)
      record = self.allocate
      record.tombstone_key = key
      record.a_string = key
      record
    end

    # @override
    def as_json(_opts={})
      {
        'a_string' => @a_string,
        'a_int' => @a_int,
        'a_long' => @a_long,
        'a_float' => @a_float,
        'a_double' => @a_double,
        'an_optional_int' => @an_optional_int,
        'an_enum' => @an_enum&.as_json,
        'an_array' => @an_array,
        'a_map' => @a_map,
        'timestamp' => @timestamp,
        'message_id' => @message_id,
        'a_record' => @a_record&.as_json
      }
    end
  end
end; end
