Class: Vertx::LocalMap

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb

Overview

Local maps can be used to share data safely in a single Vert.x instance.

By default the map allows immutable keys and values. Custom keys and values should implement Nil interface. The map returns their copies.

This ensures there is no shared access to mutable state from different threads (e.g. different event loops) in the Vert.x instance, and means you don't have to protect access to that state using synchronization or locks.

Since the version 3.4, this class extends the interface. However some methods are only accessible in Java.

Instance Method Summary (collapse)

Instance Method Details

- (void) clear

This method returns an undefined value.

Clear all entries in the map


107
108
109
110
111
112
113
114
115
116
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 107

def clear
  if !block_given?
    return @j_del.java_method(:clear, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling clear()"
  end
end

- (void) close

This method returns an undefined value.

Close and release the map


191
192
193
194
195
196
197
198
199
200
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 191

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling close()"
  end
end

- (true, false) containsKey(key)

Returns true if this map contains a mapping for the specified key.

Parameters:

  • key (Object)
    key whose presence in this map is to be tested

Returns:

  • (true, false)
    true if this map contains a mapping for the specified key


67
68
69
70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 67

def contains_key?(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given?
    return @j_del.java_method(:containsKey, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling contains_key?(#{args[0]})"
  end
end

- (true, false) containsValue(value)

Returns @true if this map maps one or more keys to the specified value.

Parameters:

  • value (Object)
    value whose presence in this map is to be tested

Returns:

  • (true, false)
    @true if this map maps one or more keys to the specified value


122
123
124
125
126
127
128
129
130
131
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 122

def contains_value?(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given?
    return @j_del.java_method(:containsValue, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling contains_value?(#{args[0]})"
  end
end

- (true, false) isEmpty

Returns true if there are zero entries in the map

Returns:

  • (true, false)
    true if there are zero entries in the map


94
95
96
97
98
99
100
101
102
103
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 94

def empty?
  if !block_given?
    return @j_del.java_method(:isEmpty, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling empty?()"
  end
end

- (Object) get(key)

Get a value from the map

Parameters:

  • key (Object)
    the key

Returns:

  • (Object)
    the value, or null if none


178
179
180
181
182
183
184
185
186
187
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 178

def get(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given?
    return @j_arg_V.wrap(@j_del.java_method(:get, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get(#{args[0]})"
  end
end

- (Object) getOrDefault(key, defaultValue)

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

Parameters:

  • key (Object)
    the key whose associated value is to be returned
  • defaultValue (Object)
    the default mapping of the key

Returns:

  • (Object)
    the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key


52
53
54
55
56
57
58
59
60
61
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 52

def get_or_default(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && @j_arg_V.accept?(args[1]) && !block_given?
    return @j_arg_V.wrap(@j_del.java_method(:getOrDefault, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0]),@j_arg_V.unwrap(args[1])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_or_default(#{args[0]},#{args[1]})"
  end
end

- (Object) put(key, value)

Put an entry in the map

Parameters:

  • key (Object)
    the key
  • value (Object)
    the value

Returns:

  • (Object)
    return the old value, or null if none


151
152
153
154
155
156
157
158
159
160
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 151

def put(*args)
  if @j_arg_K.accept?(args[0]) && @j_arg_V.accept?(args[1]) && !block_given?
    return @j_arg_V.wrap(@j_del.java_method(:put, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(@j_arg_K.unwrap(args[0]),@j_arg_V.unwrap(args[1])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling put(#{args[0]},#{args[1]})"
  end
end

- (Object) putIfAbsent(key, value)

Put the entry only if there is no existing entry for that key

Parameters:

  • key (Object)
    the key
  • value (Object)
    the value

Returns:

  • (Object)
    the old value or null, if none


206
207
208
209
210
211
212
213
214
215
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 206

def put_if_absent(*args)
  if @j_arg_K.accept?(args[0]) && @j_arg_V.accept?(args[1]) && !block_given?
    return @j_arg_V.wrap(@j_del.java_method(:putIfAbsent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(@j_arg_K.unwrap(args[0]),@j_arg_V.unwrap(args[1])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling put_if_absent(#{args[0]},#{args[1]})"
  end
end

- (Object) remove(key)

Remove an entry from the map

Parameters:

  • key (Object)
    the key

Returns:

  • (Object)
    the old value


136
137
138
139
140
141
142
143
144
145
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 136

def remove(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given?
    return @j_arg_V.wrap(@j_del.java_method(:remove, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove(#{args[0]})"
  end
end

- (true, false) removeIfPresent(key, value)

Remove the entry only if there is an entry with the specified key and value.

This method is the poyglot version of #remove.

Parameters:

  • key (Object)
    the key
  • value (Object)
    the value

Returns:

  • (true, false)
    true if removed


223
224
225
226
227
228
229
230
231
232
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 223

def remove_if_present?(*args)
  if @j_arg_K.accept?(args[0]) && @j_arg_V.accept?(args[1]) && !block_given?
    return @j_del.java_method(:removeIfPresent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(@j_arg_K.unwrap(args[0]),@j_arg_V.unwrap(args[1]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove_if_present?(#{args[0]},#{args[1]})"
  end
end

- (Object) replace(key, value)

Replace the entry only if there is an existing entry with the key

Parameters:

  • key (Object)
    the key
  • value (Object)
    the new value

Returns:

  • (Object)
    the old value


82
83
84
85
86
87
88
89
90
91
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 82

def replace(*args)
  if @j_arg_K.accept?(args[0]) && @j_arg_V.accept?(args[1]) && !block_given?
    return @j_arg_V.wrap(@j_del.java_method(:replace, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(@j_arg_K.unwrap(args[0]),@j_arg_V.unwrap(args[1])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling replace(#{args[0]},#{args[1]})"
  end
end

- (true, false) replaceIfPresent(key, oldValue, newValue)

Replace the entry only if there is an existing entry with the specified key and value.

This method is the polyglot version of #replace.

Parameters:

  • key (Object)
    the key
  • oldValue (Object)
    the old value
  • newValue (Object)
    the new value

Returns:

  • (true, false)
    true if removed


36
37
38
39
40
41
42
43
44
45
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 36

def replace_if_present?(*args)
  if @j_arg_K.accept?(args[0]) && @j_arg_V.accept?(args[1]) && @j_arg_V.accept?(args[2]) && !block_given?
    return @j_del.java_method(:replaceIfPresent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(@j_arg_K.unwrap(args[0]),@j_arg_V.unwrap(args[1]),@j_arg_V.unwrap(args[2]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling replace_if_present?(#{args[0]},#{args[1]},#{args[2]})"
  end
end

- (Fixnum) size

Get the size of the map

Returns:

  • (Fixnum)
    the number of entries in the map


164
165
166
167
168
169
170
171
172
173
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 164

def size
  if !block_given?
    return @j_del.java_method(:size, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling size()"
  end
end