class Embulk::Column

def self.from_java(java_column)

def self.from_java(java_column)
  type = Type.from_java(java_column.getType)
  if type == :timestamp
    format = java_column.getType.getFormat
  else
    format = nil
  end
  Column.new(java_column.getIndex, java_column.getName, type, format)
end

def initialize(*args)

def initialize(*args)
  if args.length == 1 && args[0].is_a?(Hash)
    # initialize(hash)
    hash = args.first
    super(hash[:index], hash[:name], hash[:type], hash[:format])
  else
    # initialize(index, name, type, format)
    super(*args)
  end
end

def to_java

def to_java
  if type == :timestamp && format
    Java::Column.new(index, name, Type.new_java_type(type).withFormat(format))
  else
    Java::Column.new(index, name, Type.new_java_type(type))
  end
end

def to_json(*args)

def to_json(*args)
  if type == :timestamp && format
    {"index"=>index, "name"=>name, "type"=>type, "format"=>format}.to_json(*args)
  else
    {"index"=>index, "name"=>name, "type"=>type}.to_json(*args)
  end
end