Class: Vertx::AsyncMap

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

Overview

An asynchronous map.

AsyncMap does not allow null to be used as a key or value.

Instance Method Summary (collapse)

Instance Method Details

- (void) clear { ... }

This method returns an undefined value.

Clear all entries in the map

Yields:

  • called on completion

Raises:

  • (ArgumentError)


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

def clear
  if block_given?
    return @j_del.java_method(:clear, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling clear()"
end

- (void) get(k = nil) { ... }

This method returns an undefined value.

Get a value from the map, asynchronously.

Parameters:

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

Yields:

  • - this will be called some time later with the async result.

Raises:

  • (ArgumentError)


24
25
26
27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_map.rb', line 24

def get(k=nil)
  if @j_arg_K.accept?(k) && block_given?
    return @j_del.java_method(:get, [Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_V.wrap(ar.result) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling get(#{k})"
end

- (void) put(k = nil, v = nil, ttl = nil) { ... }

This method returns an undefined value.

Like #put but specifying a time to live for the entry. Entry will expire and get evicted after the ttl.

Parameters:

  • k (Object) (defaults to: nil)
    the key
  • v (Object) (defaults to: nil)
    the value
  • ttl (Fixnum) (defaults to: nil)
    The time to live (in ms) for the entry

Yields:

  • the handler

Raises:

  • (ArgumentError)


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

def put(k=nil,v=nil,ttl=nil)
  if @j_arg_K.accept?(k) && @j_arg_V.accept?(v) && block_given? && ttl == nil
    return @j_del.java_method(:put, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(v),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  elsif @j_arg_K.accept?(k) && @j_arg_V.accept?(v) && ttl.class == Fixnum && block_given?
    return @j_del.java_method(:put, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(v),ttl,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling put(#{k},#{v},#{ttl})"
end

- (void) put_if_absent(k = nil, v = nil, ttl = nil) { ... }

This method returns an undefined value.

Link #put_if_absent but specifying a time to live for the entry. Entry will expire and get evicted after the ttl.

Parameters:

  • k (Object) (defaults to: nil)
    the key
  • v (Object) (defaults to: nil)
    the value
  • ttl (Fixnum) (defaults to: nil)
    The time to live (in ms) for the entry

Yields:

  • the handler

Raises:

  • (ArgumentError)


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

def put_if_absent(k=nil,v=nil,ttl=nil)
  if @j_arg_K.accept?(k) && @j_arg_V.accept?(v) && block_given? && ttl == nil
    return @j_del.java_method(:putIfAbsent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(v),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_V.wrap(ar.result) : nil) }))
  elsif @j_arg_K.accept?(k) && @j_arg_V.accept?(v) && ttl.class == Fixnum && block_given?
    return @j_del.java_method(:putIfAbsent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(v),ttl,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_V.wrap(ar.result) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling put_if_absent(#{k},#{v},#{ttl})"
end

- (void) remove(k = nil) { ... }

This method returns an undefined value.

Remove a value from the map, asynchronously.

Parameters:

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

Yields:

  • - this will be called some time later to signify the value has been removed

Raises:

  • (ArgumentError)


64
65
66
67
68
69
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_map.rb', line 64

def remove(k=nil)
  if @j_arg_K.accept?(k) && block_given?
    return @j_del.java_method(:remove, [Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_V.wrap(ar.result) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling remove(#{k})"
end

- (void) remove_if_present(k = nil, v = nil) { ... }

This method returns an undefined value.

Remove a value from the map, only if entry already exists with same value.

Parameters:

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

Yields:

  • - this will be called some time later to signify the value has been removed

Raises:

  • (ArgumentError)


75
76
77
78
79
80
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_map.rb', line 75

def remove_if_present(k=nil,v=nil)
  if @j_arg_K.accept?(k) && @j_arg_V.accept?(v) && block_given?
    return @j_del.java_method(:removeIfPresent, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(v),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling remove_if_present(#{k},#{v})"
end

- (void) replace(k = nil, v = nil) { ... }

This method returns an undefined value.

Replace the entry only if it is currently mapped to some value

Parameters:

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

Yields:

  • the result handler will be passed the previous value

Raises:

  • (ArgumentError)


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

def replace(k=nil,v=nil)
  if @j_arg_K.accept?(k) && @j_arg_V.accept?(v) && block_given?
    return @j_del.java_method(:replace, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(v),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_V.wrap(ar.result) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling replace(#{k},#{v})"
end

- (void) replace_if_present(k = nil, oldValue = nil, newValue = nil) { ... }

This method returns an undefined value.

Replace the entry only if it is currently mapped to a specific value

Parameters:

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

Yields:

  • the result handler

Raises:

  • (ArgumentError)


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

def replace_if_present(k=nil,oldValue=nil,newValue=nil)
  if @j_arg_K.accept?(k) && @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,Java::IoVertxCore::Handler.java_class]).call(@j_arg_K.unwrap(k),@j_arg_V.unwrap(oldValue),@j_arg_V.unwrap(newValue),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling replace_if_present(#{k},#{oldValue},#{newValue})"
end

- (void) size { ... }

This method returns an undefined value.

Provide the number of entries in the map

Yields:

  • handler which will receive the number of entries

Raises:

  • (ArgumentError)


116
117
118
119
120
121
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_map.rb', line 116

def size
  if block_given?
    return @j_del.java_method(:size, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling size()"
end