Class: Vertx::LocalMap
- Inherits:
-
Object
- Object
- Vertx::LocalMap
- 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)
-
- (void) clear
Clear all entries in the map.
-
- (void) close
Close and release the map.
-
- (true, false) contains_key?(key = nil)
Returns true if this map contains a mapping for the specified key.
-
- (true, false) contains_value?(value = nil)
Returns @true if this map maps one or more keys to the specified value.
-
- (true, false) empty?
True if there are zero entries in the map.
-
- (Object) get(key = nil)
Get a value from the map.
-
- (Object) get_or_default(key = nil, defaultValue = nil)
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
-
- (Object) put(key = nil, value = nil)
Put an entry in the map.
-
- (Object) put_if_absent(key = nil, value = nil)
Put the entry only if there is no existing entry for that key.
-
- (Object) remove(key = nil)
Remove an entry from the map.
-
- (true, false) remove_if_present?(key = nil, value = nil)
Remove the entry only if there is an entry with the specified key and value.
-
- (Object) replace(key = nil, value = nil)
Replace the entry only if there is an existing entry with the key.
-
- (true, false) replace_if_present?(key = nil, oldValue = nil, newValue = nil)
Replace the entry only if there is an existing entry with the specified key and value.
-
- (Fixnum) size
Get the size of the map.
Instance Method Details
- (void) clear
This method returns an undefined value.
Clear all entries in the map
57 58 59 60 61 62 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 57 def clear if !block_given? return @j_del.java_method(:clear, []).call() end raise ArgumentError, "Invalid arguments when calling clear()" end |
- (void) close
This method returns an undefined value.
Close and release the map
125 126 127 128 129 130 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 125 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (true, false) contains_key?(key = nil)
Returns
true
if this map contains a mapping for the specified
key.
135 136 137 138 139 140 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 135 def contains_key?(key=nil) if ::Vertx::Util::unknown_type.accept?(key) && !block_given? return @j_del.java_method(:containsKey, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key)) end raise ArgumentError, "Invalid arguments when calling contains_key?(#{key})" end |
- (true, false) contains_value?(value = nil)
Returns @true if this map maps one or more keys to the
specified value.
145 146 147 148 149 150 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 145 def contains_value?(value=nil) if ::Vertx::Util::unknown_type.accept?(value) && !block_given? return @j_del.java_method(:containsValue, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(value)) end raise ArgumentError, "Invalid arguments when calling contains_value?(#{value})" end |
- (true, false) empty?
Returns true if there are zero entries in the map
72 73 74 75 76 77 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 72 def empty? if !block_given? return @j_del.java_method(:isEmpty, []).call() end raise ArgumentError, "Invalid arguments when calling empty?()" end |
- (Object) get(key = nil)
Get a value from the map
30 31 32 33 34 35 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 30 def get(key=nil) if ::Vertx::Util::unknown_type.accept?(key) && !block_given? return @j_arg_V.wrap(@j_del.java_method(:get, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key))) end raise ArgumentError, "Invalid arguments when calling get(#{key})" end |
- (Object) get_or_default(key = nil, defaultValue = nil)
Returns the value to which the specified key is mapped, or
defaultValue
if this map contains no mapping for the key.
156 157 158 159 160 161 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 156 def get_or_default(key=nil,defaultValue=nil) if ::Vertx::Util::unknown_type.accept?(key) && @j_arg_V.accept?(defaultValue) && !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(key),@j_arg_V.unwrap(defaultValue))) end raise ArgumentError, "Invalid arguments when calling get_or_default(#{key},#{defaultValue})" end |
- (Object) put(key = nil, value = nil)
Put an entry in the map
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 40 def put(key=nil,value=nil) if @j_arg_K.accept?(key) && @j_arg_V.accept?(value) && !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(key),@j_arg_V.unwrap(value))) end raise ArgumentError, "Invalid arguments when calling put(#{key},#{value})" end |
- (Object) put_if_absent(key = nil, value = nil)
Put the entry only if there is no existing entry for that key
82 83 84 85 86 87 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 82 def put_if_absent(key=nil,value=nil) if @j_arg_K.accept?(key) && @j_arg_V.accept?(value) && !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(key),@j_arg_V.unwrap(value))) end raise ArgumentError, "Invalid arguments when calling put_if_absent(#{key},#{value})" end |
- (Object) remove(key = nil)
Remove an entry from the map
49 50 51 52 53 54 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 49 def remove(key=nil) if ::Vertx::Util::unknown_type.accept?(key) && !block_given? return @j_arg_V.wrap(@j_del.java_method(:remove, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key))) end raise ArgumentError, "Invalid arguments when calling remove(#{key})" end |
- (true, false) remove_if_present?(key = nil, value = nil)
Remove the entry only if there is an entry with the specified key and value.
This method is the poyglot version of #remove.
94 95 96 97 98 99 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 94 def remove_if_present?(key=nil,value=nil) if @j_arg_K.accept?(key) && @j_arg_V.accept?(value) && !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(key),@j_arg_V.unwrap(value)) end raise ArgumentError, "Invalid arguments when calling remove_if_present?(#{key},#{value})" end |
- (Object) replace(key = nil, value = nil)
Replace the entry only if there is an existing entry with the key
117 118 119 120 121 122 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 117 def replace(key=nil,value=nil) if @j_arg_K.accept?(key) && @j_arg_V.accept?(value) && !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(key),@j_arg_V.unwrap(value))) end raise ArgumentError, "Invalid arguments when calling replace(#{key},#{value})" end |
- (true, false) replace_if_present?(key = nil, oldValue = nil, newValue = nil)
Replace the entry only if there is an existing entry with the specified key and value.
This method is the polyglot version of #replace.
107 108 109 110 111 112 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 107 def replace_if_present?(key=nil,oldValue=nil,newValue=nil) if @j_arg_K.accept?(key) && @j_arg_V.accept?(oldValue) && @j_arg_V.accept?(newValue) && !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(key),@j_arg_V.unwrap(oldValue),@j_arg_V.unwrap(newValue)) end raise ArgumentError, "Invalid arguments when calling replace_if_present?(#{key},#{oldValue},#{newValue})" end |
- (Fixnum) size
Get the size of the map
65 66 67 68 69 70 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/local_map.rb', line 65 def size if !block_given? return @j_del.java_method(:size, []).call() end raise ArgumentError, "Invalid arguments when calling size()" end |