Class: Vertx::LocalMap

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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. 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

Raises:

  • (ArgumentError)


56
57
58
59
60
61
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 56

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

Raises:

  • (ArgumentError)


124
125
126
127
128
129
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 124

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.

Parameters:

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

Returns:

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

Raises:

  • (ArgumentError)


134
135
136
137
138
139
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 134

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.

Parameters:

  • value (Object) (defaults to: nil)
    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

Raises:

  • (ArgumentError)


144
145
146
147
148
149
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 144

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

Returns:

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

Raises:

  • (ArgumentError)


71
72
73
74
75
76
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 71

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

Parameters:

  • key (Object) (defaults to: nil)
    the key

Returns:

  • (Object)
    the value, or null if none

Raises:

  • (ArgumentError)


29
30
31
32
33
34
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 29

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.

Parameters:

  • key (Object) (defaults to: nil)
    the key whose associated value is to be returned
  • defaultValue (Object) (defaults to: nil)
    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

Raises:

  • (ArgumentError)


155
156
157
158
159
160
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 155

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

Parameters:

  • key (Object) (defaults to: nil)
    the key
  • value (Object) (defaults to: nil)
    the value

Returns:

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

Raises:

  • (ArgumentError)


39
40
41
42
43
44
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 39

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

Parameters:

  • key (Object) (defaults to: nil)
    the key
  • value (Object) (defaults to: nil)
    the value

Returns:

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

Raises:

  • (ArgumentError)


81
82
83
84
85
86
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 81

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

Parameters:

  • key (Object) (defaults to: nil)
    the key

Returns:

  • (Object)
    the old value

Raises:

  • (ArgumentError)


48
49
50
51
52
53
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 48

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.

Parameters:

  • key (Object) (defaults to: nil)
    the key
  • value (Object) (defaults to: nil)
    the value

Returns:

  • (true, false)
    true if removed

Raises:

  • (ArgumentError)


93
94
95
96
97
98
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 93

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

Parameters:

  • key (Object) (defaults to: nil)
    the key
  • value (Object) (defaults to: nil)
    the new value

Returns:

  • (Object)
    the old value

Raises:

  • (ArgumentError)


116
117
118
119
120
121
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 116

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.

Parameters:

  • key (Object) (defaults to: nil)
    the key
  • oldValue (Object) (defaults to: nil)
    the old value
  • newValue (Object) (defaults to: nil)
    the new value

Returns:

  • (true, false)
    true if removed

Raises:

  • (ArgumentError)


106
107
108
109
110
111
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 106

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

Returns:

  • (Fixnum)
    the number of entries in the map

Raises:

  • (ArgumentError)


64
65
66
67
68
69
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/local_map.rb', line 64

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