###################################################################################
#                                                                                 #
#                   Copyright 2010-2013 Ning, Inc.                                #
#                                                                                 #
#      Ning licenses this file to you under the Apache License, version 2.0       #
#      (the "License"); you may not use this file except in compliance with the   #
#      License.  You may obtain a copy of the License at:                         #
#                                                                                 #
#          http://www.apache.org/licenses/LICENSE-2.0                             #
#                                                                                 #
#      Unless required by applicable law or agreed to in writing, software        #
#      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
#      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the  #
#      License for the specific language governing permissions and limitations    #
#      under the License.                                                         #
#                                                                                 #
###################################################################################


#
#                       DO NOT EDIT!!!
#    File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
#


module Killbill
  module Plugin
    module Model

      java_package 'com.ning.billing.payment.api'
      class PaymentMethodPlugin

        include com.ning.billing.payment.api.PaymentMethodPlugin

        attr_accessor :external_payment_method_id, :is_default_payment_method, :properties, :type, :cc_name, :cc_type, :cc_expiration_month, :cc_expiration_year, :cc_last4, :address1, :address2, :city, :state, :zip, :country

        def initialize()
        end

        def to_java()
          # conversion for external_payment_method_id [type = java.lang.String]
          @external_payment_method_id = @external_payment_method_id.to_s unless @external_payment_method_id.nil?

          # conversion for is_default_payment_method [type = boolean]
          @is_default_payment_method = @is_default_payment_method.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(@is_default_payment_method)

          # conversion for properties [type = java.util.List]
          tmp = java.util.ArrayList.new
          (@properties || []).each do |m|
            # conversion for m [type = com.ning.billing.payment.api.PaymentMethodKVInfo]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          @properties = tmp

          # conversion for type [type = java.lang.String]
          @type = @type.to_s unless @type.nil?

          # conversion for cc_name [type = java.lang.String]
          @cc_name = @cc_name.to_s unless @cc_name.nil?

          # conversion for cc_type [type = java.lang.String]
          @cc_type = @cc_type.to_s unless @cc_type.nil?

          # conversion for cc_expiration_month [type = java.lang.String]
          @cc_expiration_month = @cc_expiration_month.to_s unless @cc_expiration_month.nil?

          # conversion for cc_expiration_year [type = java.lang.String]
          @cc_expiration_year = @cc_expiration_year.to_s unless @cc_expiration_year.nil?

          # conversion for cc_last4 [type = java.lang.String]
          @cc_last4 = @cc_last4.to_s unless @cc_last4.nil?

          # conversion for address1 [type = java.lang.String]
          @address1 = @address1.to_s unless @address1.nil?

          # conversion for address2 [type = java.lang.String]
          @address2 = @address2.to_s unless @address2.nil?

          # conversion for city [type = java.lang.String]
          @city = @city.to_s unless @city.nil?

          # conversion for state [type = java.lang.String]
          @state = @state.to_s unless @state.nil?

          # conversion for zip [type = java.lang.String]
          @zip = @zip.to_s unless @zip.nil?

          # conversion for country [type = java.lang.String]
          @country = @country.to_s unless @country.nil?
          self
        end

        def to_ruby(j_obj)
          # conversion for external_payment_method_id [type = java.lang.String]
          @external_payment_method_id = j_obj.external_payment_method_id

          # conversion for is_default_payment_method [type = boolean]
          @is_default_payment_method = j_obj.is_default_payment_method
          if @is_default_payment_method.nil?
            @is_default_payment_method = false
          else
            tmp_bool = (@is_default_payment_method.java_kind_of? java.lang.Boolean) ? @is_default_payment_method.boolean_value : @is_default_payment_method
            @is_default_payment_method = tmp_bool ? true : false
          end

          # conversion for properties [type = java.util.List]
          @properties = j_obj.properties
          tmp = []
          (@properties || []).each do |m|
            # conversion for m [type = com.ning.billing.payment.api.PaymentMethodKVInfo]
            m = Killbill::Plugin::Model::PaymentMethodKVInfo.new.to_ruby(m) unless m.nil?
            tmp << m
          end
          @properties = tmp

          # conversion for type [type = java.lang.String]
          @type = j_obj.type

          # conversion for cc_name [type = java.lang.String]
          @cc_name = j_obj.cc_name

          # conversion for cc_type [type = java.lang.String]
          @cc_type = j_obj.cc_type

          # conversion for cc_expiration_month [type = java.lang.String]
          @cc_expiration_month = j_obj.cc_expiration_month

          # conversion for cc_expiration_year [type = java.lang.String]
          @cc_expiration_year = j_obj.cc_expiration_year

          # conversion for cc_last4 [type = java.lang.String]
          @cc_last4 = j_obj.cc_last4

          # conversion for address1 [type = java.lang.String]
          @address1 = j_obj.address1

          # conversion for address2 [type = java.lang.String]
          @address2 = j_obj.address2

          # conversion for city [type = java.lang.String]
          @city = j_obj.city

          # conversion for state [type = java.lang.String]
          @state = j_obj.state

          # conversion for zip [type = java.lang.String]
          @zip = j_obj.zip

          # conversion for country [type = java.lang.String]
          @country = j_obj.country
          self
        end

      end
    end
  end
end