Class: Vertx::Future
- Inherits:
-
Object
show all
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb
Overview
Represents the result of an action that may, or may not, have occurred yet.
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Class Method Details
+ (::Vertx::Future) failed_future(failureMessage = nil)
Create a failed future with the specified failure message.
39
40
41
42
43
44
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 39
def self.failed_future(failureMessage=nil)
if failureMessage.class == String && !block_given?
return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:failedFuture, [Java::java.lang.String.java_class]).call(failureMessage),::Vertx::Future)
end
raise ArgumentError, "Invalid arguments when calling failed_future(failureMessage)"
end
|
Create a future that hasn't completed yet
19
20
21
22
23
24
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 19
def self.future
if !block_given?
return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:future, []).call(),::Vertx::Future)
end
raise ArgumentError, "Invalid arguments when calling future()"
end
|
+ (::Vertx::Future) succeeded_future(result = nil)
Created a succeeded future with the specified result.
28
29
30
31
32
33
34
35
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 28
def self.succeeded_future(result=nil)
if !block_given? && result == nil
return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::Future.java_method(:succeededFuture, []).call(),::Vertx::Future)
elsif (result.class == String || result.class == Hash || result.class == Array || result.class == NilClass || result.class == TrueClass || result.class == FalseClass || result.class == Fixnum || result.class == Float) && !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(result)),::Vertx::Future)
end
raise ArgumentError, "Invalid arguments when calling succeeded_future(result)"
end
|
Instance Method Details
- (Exception) cause
A Throwable describing failure. This will be null if the operation succeeded.
103
104
105
106
107
108
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 103
def cause
if !block_given?
return ::Vertx::Util::Utils.from_throwable(@j_del.java_method(:cause, []).call())
end
raise ArgumentError, "Invalid arguments when calling cause()"
end
|
- (void) complete(result = nil)
This method returns an undefined value.
Set the result. Any handler will be called, if there is one, and the future will be marked as completed.
71
72
73
74
75
76
77
78
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 71
def complete(result=nil)
if !block_given? && result == nil
return @j_del.java_method(:complete, []).call()
elsif (result.class == String || result.class == Hash || result.class == Array || result.class == NilClass || result.class == TrueClass || result.class == FalseClass || result.class == Fixnum || result.class == Float) && !block_given?
return @j_del.java_method(:complete, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(result))
end
raise ArgumentError, "Invalid arguments when calling complete(result)"
end
|
- (true, false) complete?
Has the future completed?
It's completed if it's either succeeded or failed.
49
50
51
52
53
54
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 49
def complete?
if !block_given?
return @j_del.java_method(:isComplete, []).call()
end
raise ArgumentError, "Invalid arguments when calling complete?()"
end
|
- (Proc) completer
@return an handler completing this future
168
169
170
171
172
173
174
175
176
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 168
def completer
if !block_given?
if @cached_completer != nil
return @cached_completer
end
return @cached_completer = ::Vertx::Util::Utils.to_async_result_handler_proc(@j_del.java_method(:completer, []).call()) { |val| ::Vertx::Util::Utils.to_object(val) }
end
raise ArgumentError, "Invalid arguments when calling completer()"
end
|
Compose this future with a provided
next
future.
When this future succeeds, the handler
will be called with the completed value, this handler
should complete the next future.
If the handler
throws an exception, the returned future will be failed with this exception.
When this future fails, the failure will be propagated to the next
future and the handler
will not be called.
140
141
142
143
144
145
146
147
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 140
def compose(param_1=nil,param_2=nil)
if block_given? && param_1 == nil && param_2 == nil
return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:compose, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_object(event)).j_del })),::Vertx::Future)
elsif param_1.class == Proc && param_2.class.method_defined?(:j_del) && !block_given?
return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:compose, [Java::IoVertxCore::Handler.java_class,Java::IoVertxCore::Future.java_class]).call((Proc.new { |event| param_1.call(::Vertx::Util::Utils.from_object(event)) }),param_2.j_del),::Vertx::Future)
end
raise ArgumentError, "Invalid arguments when calling compose(param_1,param_2)"
end
|
- (void) fail(throwable)
- (void) fail(failureMessage)
This method returns an undefined value.
Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.
85
86
87
88
89
90
91
92
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 85
def fail(param_1=nil)
if param_1.is_a?(Exception) && !block_given?
return @j_del.java_method(:fail, [Java::JavaLang::Throwable.java_class]).call(::Vertx::Util::Utils.to_throwable(param_1))
elsif param_1.class == String && !block_given?
return @j_del.java_method(:fail, [Java::java.lang.String.java_class]).call(param_1)
end
raise ArgumentError, "Invalid arguments when calling fail(param_1)"
end
|
- (true, false) failed?
119
120
121
122
123
124
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 119
def failed?
if !block_given?
return @j_del.java_method(:failed, []).call()
end
raise ArgumentError, "Invalid arguments when calling failed?()"
end
|
Map the result of a future to a specific
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.
158
159
160
161
162
163
164
165
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 158
def map(param_1=nil)
if block_given? && param_1 == 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(::Vertx::Util::Utils.from_object(event))) })),::Vertx::Future)
elsif (param_1.class == String || param_1.class == Hash || param_1.class == Array || param_1.class == NilClass || param_1.class == TrueClass || param_1.class == FalseClass || param_1.class == Fixnum || param_1.class == Float) && !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(param_1)),::Vertx::Future)
end
raise ArgumentError, "Invalid arguments when calling map(param_1)"
end
|
- (Object) result
The result of the operation. This will be null if the operation failed.
95
96
97
98
99
100
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 95
def result
if !block_given?
return ::Vertx::Util::Utils.from_object(@j_del.java_method(:result, []).call())
end
raise ArgumentError, "Invalid arguments when calling result()"
end
|
- (self) set_handler { ... }
Set a handler for the result.
If the future has already been completed it will be called immediately. Otherwise it will be called when the
future is completed.
61
62
63
64
65
66
67
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 61
def set_handler
if block_given?
@j_del.java_method(:setHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.from_object(ar.result) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling set_handler()"
end
|
- (true, false) succeeded?
111
112
113
114
115
116
|
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/future.rb', line 111
def succeeded?
if !block_given?
return @j_del.java_method(:succeeded, []).call()
end
raise ArgumentError, "Invalid arguments when calling succeeded?()"
end
|