Module: Java::JavaUtil::Map

Defined in:
lib/jinx/import/java.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object

Returns whether this Set has the same content as the other Java Map or Ruby Hash.



62
63
64
# File 'lib/jinx/import/java.rb', line 62

def ==(other)
  ::Hash === other ? (size == other.size and other.all? { |key, value| get(key) == value }) : equals(other)
end

#merge(other) ⇒ Object Also known as: merge!

Merges the other Java Map or Ruby Hash into this Map. Returns this modified Map.

If a block is given to this method, then the block determines the mapped value as specified in the Ruby Hash merge method documentation.



70
71
72
73
74
75
76
# File 'lib/jinx/import/java.rb', line 70

def merge(other)
  other.each do |key, value|
    value = yield(key, get(key), value) if block_given? and containsKey(key)
    put(key, value)
  end
  self
end