Module: Java::JavaUtil::Map

Defined in:
lib/caruby/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.



103
104
105
# File 'lib/caruby/import/java.rb', line 103

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.



111
112
113
114
115
116
117
# File 'lib/caruby/import/java.rb', line 111

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