Class: Vertx::LocalMap
- Inherits:
-
Object
- Object
- Vertx::LocalMap
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb
Overview
Local maps can be used to share data safely in a single Vert.x instance.
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.
Instance Method Summary (collapse)
-
- (void) clear
Clear all entries in the map.
-
- (void) close
Close and release the map.
-
- (true, false) empty?
@return true if there are zero entries in the map.
-
- (Object) get(key = nil)
Get a value from the map.
-
- (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
52 53 54 55 56 57 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 52 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
117 118 119 120 121 122 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 117 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (true, false) empty?
@return true if there are zero entries in the map
68 69 70 71 72 73 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 68 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
25 26 27 28 29 30 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 25 def get(key=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && !block_given? return ::Vertx::Util::Utils.from_object(@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) put(key = nil, value = nil)
Put an entry in the map
35 36 37 38 39 40 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 35 def put(key=nil,value=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && (value.class == String || value.class == Hash || value.class == Array || value.class == NilClass || value.class == TrueClass || value.class == FalseClass || value.class == Fixnum || value.class == Float) && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:put, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key),::Vertx::Util::Utils.to_object(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
78 79 80 81 82 83 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 78 def put_if_absent(key=nil,value=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && (value.class == String || value.class == Hash || value.class == Array || value.class == NilClass || value.class == TrueClass || value.class == FalseClass || value.class == Fixnum || value.class == Float) && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:putIfAbsent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key),::Vertx::Util::Utils.to_object(value))) end raise ArgumentError, "Invalid arguments when calling put_if_absent(key,value)" end |
- (Object) remove(key = nil)
Remove an entry from the map
44 45 46 47 48 49 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 44 def remove(key=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && !block_given? return ::Vertx::Util::Utils.from_object(@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
88 89 90 91 92 93 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 88 def remove_if_present?(key=nil,value=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && (value.class == String || value.class == Hash || value.class == Array || value.class == NilClass || value.class == TrueClass || value.class == FalseClass || value.class == Fixnum || value.class == Float) && !block_given? return @j_del.java_method(:removeIfPresent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key),::Vertx::Util::Utils.to_object(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
109 110 111 112 113 114 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 109 def replace(key=nil,value=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && (value.class == String || value.class == Hash || value.class == Array || value.class == NilClass || value.class == TrueClass || value.class == FalseClass || value.class == Fixnum || value.class == Float) && !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:replace, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(key),::Vertx::Util::Utils.to_object(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
99 100 101 102 103 104 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 99 def replace_if_present?(key=nil,oldValue=nil,newValue=nil) if (key.class == String || key.class == Hash || key.class == Array || key.class == NilClass || key.class == TrueClass || key.class == FalseClass || key.class == Fixnum || key.class == Float) && (oldValue.class == String || oldValue.class == Hash || oldValue.class == Array || oldValue.class == NilClass || oldValue.class == TrueClass || oldValue.class == FalseClass || oldValue.class == Fixnum || oldValue.class == Float) && (newValue.class == String || newValue.class == Hash || newValue.class == Array || newValue.class == NilClass || newValue.class == TrueClass || newValue.class == FalseClass || newValue.class == Fixnum || newValue.class == Float) && !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(::Vertx::Util::Utils.to_object(key),::Vertx::Util::Utils.to_object(oldValue),::Vertx::Util::Utils.to_object(newValue)) end raise ArgumentError, "Invalid arguments when calling replace_if_present?(key,oldValue,newValue)" end |
- (Fixnum) size
Get the size of the map
60 61 62 63 64 65 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/local_map.rb', line 60 def size if !block_given? return @j_del.java_method(:size, []).call() end raise ArgumentError, "Invalid arguments when calling size()" end |