Class: Vertx::LocalMap
- Inherits:
-
Object
- Object
- Vertx::LocalMap
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb
Overview
The map only allows immutable keys and values in the map, OR certain mutable objects such as Buffer instances which will be copied when they are added to the map.
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.
Your own objects can be marked as immutable by implementing the Nil interface. 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
58 59 60 61 62 63 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 58 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
126 127 128 129 130 131 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 126 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)
true
if this map contains a mapping for the specified
key.
136 137 138 139 140 141 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 136 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)
146 147 148 149 150 151 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 146 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?
73 74 75 76 77 78 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 73 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)
31 32 33 34 35 36 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 31 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)
defaultValue
if this map contains no mapping for the key.
157 158 159 160 161 162 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 157 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)
41 42 43 44 45 46 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 41 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)
83 84 85 86 87 88 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 83 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)
50 51 52 53 54 55 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 50 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)
This method is the poyglot version of #remove.
95 96 97 98 99 100 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 95 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)
118 119 120 121 122 123 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 118 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)
This method is the polyglot version of #replace.
108 109 110 111 112 113 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 108 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
66 67 68 69 70 71 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 66 def size if !block_given? return @j_del.java_method(:size, []).call() end raise ArgumentError, "Invalid arguments when calling size()" end |