Class: Vertx::Future
- Inherits:
-
Object
- Object
- Vertx::Future
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb
Overview
Direct Known Subclasses
Class Method Summary (collapse)
-
+ (::Vertx::Future) failed_future(*args)
Create a failed future with the specified failure message.
-
+ (::Vertx::Future) future(handler) { ... }
Create a future that hasn't completed yet and that is passed to the handler before it is returned.
-
+ (::Vertx::Future) succeeded_future(*args)
Created a succeeded future with the specified result.
Instance Method Summary (collapse)
-
- (Exception) cause
A Throwable describing failure.
-
- (true, false) isComplete
Has the future completed? It's completed if it's either succeeded or failed.
-
- (::Vertx::Future) compose(mapper) { ... }
Compose this future with a mapper function.
-
- (true, false) failed
Did it fail?.
-
- (Proc) getHandler
The handler for the result.
-
- (::Vertx::Future) map(*args)
Map the result of a future to a specific value.
-
- (::Vertx::Future) mapEmpty
Map the result of a future to null.
-
- (::Vertx::Future) otherwise(*args)
Map the failure of a future to a specific value.
-
- (::Vertx::Future) otherwiseEmpty
Map the failure of a future to null.
-
- (::Vertx::Future) recover(mapper) { ... }
Handles a failure of this Future by returning the result of another Future.
-
- (Object) result
The result of the operation.
-
- (self) setHandler(handler) { ... }
Set a handler for the result.
-
- (true, false) succeeded
Did it succeed?.
Class Method Details
+ (::Vertx::Future) failedFuture(t) + (::Vertx::Future) failedFuture(failureMessage)
163 164 165 166 167 168 169 170 171 172 173 174 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 163 def self.failed_future(*args) if args[0].is_a?(Exception) && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:failedFuture, [Java::JavaLang::Throwable.java_class]).call(::Vertx::Util::Utils.to_throwable(args[0])),::Vertx::Future, nil) elsif args[0].class == String && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:failedFuture, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling failed_future(#{args[0]})" end end |
+ (::Vertx::Future) future(handler) { ... }
handler
before it is returned.
215 216 217 218 219 220 221 222 223 224 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 215 def self.future if true return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:future, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Promise, nil)) unless !block_given? })),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling future()" end end |
+ (::Vertx::Future) succeededFuture + (::Vertx::Future) succeededFuture(result)
230 231 232 233 234 235 236 237 238 239 240 241 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 230 def self.succeeded_future(*args) if !block_given? && args[0] == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:succeededFuture, []).call(),::Vertx::Future, nil) elsif ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:succeededFuture, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0])),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling succeeded_future(#{args[0]})" end end |
Instance Method Details
- (Exception) cause
84 85 86 87 88 89 90 91 92 93 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 84 def cause if !block_given? return ::Vertx::Util::Utils.from_throwable(@j_del.java_method(:cause, []).call()) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling cause()" end end |
- (true, false) isComplete
It's completed if it's either succeeded or failed.
282 283 284 285 286 287 288 289 290 291 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 282 def complete? if !block_given? return @j_del.java_method(:isComplete, []).call() end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling complete?()" end end |
- (::Vertx::Future) compose(mapper) { ... }
mapper
function.
When this future (the one on which compose
is called) succeeds, the mapper
will be called with
the completed value and this mapper returns another future object. This returned future completion will complete
the future returned by this method call.
If the mapper
throws an exception, the returned future will be failed with this exception.
When this future fails, the failure will be propagated to the returned future and the mapper
will not be called.
201 202 203 204 205 206 207 208 209 210 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 201 def compose(*args) if block_given? && args[0] == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:compose, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| yield(@j_arg_T.wrap(event)).j_del unless !block_given? })),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling compose(#{args[0]})" end end |
- (true, false) failed
116 117 118 119 120 121 122 123 124 125 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 116 def failed? if !block_given? return @j_del.java_method(:failed, []).call() end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling failed?()" end end |
- (Proc) getHandler
128 129 130 131 132 133 134 135 136 137 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 128 def get_handler if !block_given? return ::Vertx::Util::Utils.to_async_result_handler_proc(@j_del.java_method(:getHandler, []).call()) { |val| @j_arg_T.unwrap(val) } end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling get_handler()" end end |
- (::Vertx::Future) map(mapper) { ... } - (::Vertx::Future) map(value)
value
.
When this future succeeds, this value
will complete the future returned by this method call.
When this future fails, the failure will be propagated to the returned future.
252 253 254 255 256 257 258 259 260 261 262 263 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 252 def map(*args) if block_given? && args[0] == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:map, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| ::Vertx::Util::Utils.to_object(yield(@j_arg_T.wrap(event))) unless !block_given? })),::Vertx::Future, nil) elsif ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:map, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0])),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling map(#{args[0]})" end end |
- (::Vertx::Future) mapEmpty
null
.
This is a conveniency for future.map((T) null)
or future.map((Void) null)
.
When this future succeeds, null
will complete the future returned by this method call.
When this future fails, the failure will be propagated to the returned future.
103 104 105 106 107 108 109 110 111 112 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 103 def map_empty if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:mapEmpty, []).call(),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling map_empty()" end end |
- (::Vertx::Future) otherwise(mapper) { ... } - (::Vertx::Future) otherwise(value)
value
.
When this future fails, this value
will complete the future returned by this method call.
When this future succeeds, the result will be propagated to the returned future.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 30 def otherwise(*args) if block_given? && args[0] == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:otherwise, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| @j_arg_T.unwrap(yield(::Vertx::Util::Utils.from_throwable(event))) unless !block_given? })),::Vertx::Future, nil) elsif @j_arg_T.accept?(args[0]) && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:otherwise, [Java::java.lang.Object.java_class]).call(@j_arg_T.unwrap(args[0])),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling otherwise(#{args[0]})" end end |
- (::Vertx::Future) otherwiseEmpty
null
.
This is a convenience for future.otherwise((T) null)
.
When this future fails, the null
value will complete the future returned by this method call.
When this future succeeds, the result will be propagated to the returned future.
147 148 149 150 151 152 153 154 155 156 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 147 def otherwise_empty if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:otherwiseEmpty, []).call(),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling otherwise_empty()" end end |
- (::Vertx::Future) recover(mapper) { ... }
71 72 73 74 75 76 77 78 79 80 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 71 def recover(*args) if block_given? && args[0] == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:recover, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)).j_del unless !block_given? })),::Vertx::Future, nil) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling recover(#{args[0]})" end end |
- (Object) result
178 179 180 181 182 183 184 185 186 187 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 178 def result if !block_given? return @j_arg_T.wrap(@j_del.java_method(:result, []).call()) end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling result()" end end |
- (self) setHandler(handler) { ... }
If the future has already been completed it will be called immediately. Otherwise it will be called when the future is completed.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 49 def set_handler if true if (block_given?) @j_del.java_method(:setHandler, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_T.wrap(ar.result) : nil) } : promise) return self else promise = ::Vertx::Util::Utils.promise @j_del.java_method(:setHandler, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_T.wrap(ar.result) : nil) } : promise) return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil) end end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling set_handler()" end end |
- (true, false) succeeded
267 268 269 270 271 272 273 274 275 276 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/future.rb', line 267 def succeeded? if !block_given? return @j_del.java_method(:succeeded, []).call() end if defined?(super) super else raise ArgumentError, "Invalid arguments when calling succeeded?()" end end |