Class List Method List File List

# Class: VertxBridgeCommon::BaseBridgeEvent

Inherits:
  Vertx::Future
  - Object
  - Vertx::Future
  - VertxBridgeCommon::BaseBridgeEvent
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb

## Overview

Represents an event that occurs on the event bus bridge.

Please consult the documentation for a full explanation.

## Direct Known Subclasses

VertxTcpEventbusBridge::BridgeEvent, VertxWeb::BridgeEvent

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (Exception) cause
  A Throwable describing failure.
- - (void) complete(result = nil)
  Set the result.
- - (true, false) complete?
  Has the future completed? It's completed if it's either succeeded or failed.
- - (Proc) completer
  An handler completing this future.
- - (::Vertx::Future) compose(param_1 = nil, param_2 = nil)
  Compose this future with a provided next future.
- - (void) fail(param_1 = nil)
  Try to set the failure.
- - (true, false) failed?
  Did it fail?.
- - (Hash{String => Object}) get_raw_message
  Get the raw JSON message for the event.
- - (::Vertx::Future) map(param_1 = nil)
  Map the result of a future to a specific value.
- - (::Vertx::Future) map_empty
  Map the result of a future to null.
- - (::Vertx::Future) otherwise(param_1 = nil)
  Map the failure of a future to a specific value.
- - (::Vertx::Future) otherwise_empty
  Map the failure of a future to null.
- - (::Vertx::Future) recover(mapper = nil) { ... }
  Handles a failure of this Future by returning the result of another Future.
- - (true, false) result?
  The result of the operation.
- - (self) set_handler { ... }
  Set a handler for the result.
- - (self) set_raw_message(message = nil)
  Get the raw JSON message for the event.
- - (true, false) succeeded?
  Did it succeed?.
- - (true, false) try_complete?(result = nil)
  Set the failure.
- - (true, false) try_fail?(param_1 = nil)
  Try to set the failure.
- - (:SOCKET_CREATED, ...) type
  The type of the event.

### Methods inherited from Vertx::Future

failed_future, future, #result, succeeded_future

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    21
    22
    23
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 21

    def @@j_api_type.accept?(obj)
      obj.class == BaseBridgeEvent
    end

### + (`Object`) j_api_type

    30
    31
    32
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 30

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    33
    34
    35
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 33

    def self.j_class
      Java::IoVertxExtBridge::BaseBridgeEvent.java_class
    end

### + (`Object`) unwrap(obj)

    27
    28
    29
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 27

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    24
    25
    26
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 24

    def @@j_api_type.wrap(obj)
      BaseBridgeEvent.new(obj)
    end

## Instance Method Details

### - (`Exception`) cause

A Throwable describing failure. This will be null if the operation succeeded.

Returns:

- (`Exception`) —
  the cause or null if the operation succeeded.

Raises:

- (`ArgumentError`)

    119
    120
    121
    122
    123
    124
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 119

    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.

Parameters:

- result (`true`, `false`) (defaults to: `nil`) —
  the result

Raises:

- (`ArgumentError`)

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

    def complete(result=nil)
      if !block_given? && result == nil
        return @j_del.java_method(:complete, []).call()
      elsif (result.class == TrueClass || result.class == FalseClass) && !block_given?
        return @j_del.java_method(:complete, [Java::JavaLang::Boolean.java_class]).call(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.

Returns:

- (`true`, `false`) —
  true if completed, false if not

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 40

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

### - (`Proc`) completer

Returns an handler completing this future

Returns:

- (`Proc`) —
  an handler completing this future

Raises:

- (`ArgumentError`)

    197
    198
    199
    200
    201
    202
    203
    204
    205
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 197

    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| val }
      end
      raise ArgumentError, "Invalid arguments when calling completer()"
    end

### - (`::Vertx::Future`) compose(mapper) { ... } - (`::Vertx::Future`) compose(handler)

Compose this future with a provided `next` future.

When this (the one on which `compose` is called) 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.

Overloads:

- - (`::Vertx::Future`) compose(mapper) { ... }

  Yields:

  - the mapper function
- - (`::Vertx::Future`) compose(handler)

  Parameters:

  - handler (`Proc`) —
    the handler
  - _next (`::Vertx::Future`) —
    the next future

Returns:

- (`::Vertx::Future`) —
  the next future, used for chaining

Raises:

- (`ArgumentError`)

    156
    157
    158
    159
    160
    161
    162
    163
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 156

    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(event).j_del })),::Vertx::Future, nil)
      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(event) }),param_2.j_del),::Vertx::Future, nil)
      end
      raise ArgumentError, "Invalid arguments when calling compose(#{param_1},#{param_2})"
    end

### - (`void`) fail(cause) - (`void`) fail(failureMessage)

This method returns an undefined value.

Try to set the failure. When it happens, any handler will be called, if there is one, and the future will be marked as completed.

Overloads:

- - (`void`) fail(cause)

  Parameters:

  - cause (`Exception`) —
    the failure cause
- - (`void`) fail(failureMessage)

  Parameters:

  - failureMessage (`String`) —
    the failure message

Raises:

- (`ArgumentError`)

    76
    77
    78
    79
    80
    81
    82
    83
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 76

    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?

Did it fail?

Returns:

- (`true`, `false`) —
  true if it failed or false otherwise

Raises:

- (`ArgumentError`)

    135
    136
    137
    138
    139
    140
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 135

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

### - (`Hash{String => Object}`) get_raw_message

Get the raw JSON message for the event. This will be null for SOCKET_CREATED or SOCKET_CLOSED events as there is no message involved. If the returned message is modified, #set_raw_message should be called with the new message.

Returns:

- (`Hash{String => Object}`) —
  the raw JSON message for the event

Raises:

- (`ArgumentError`)

    262
    263
    264
    265
    266
    267
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 262

    def get_raw_message
      if !block_given?
        return @j_del.java_method(:getRawMessage, []).call() != nil ? JSON.parse(@j_del.java_method(:getRawMessage, []).call().encode) : nil
      end
      raise ArgumentError, "Invalid arguments when calling get_raw_message()"
    end

### - (`::Vertx::Future`) map(mapper) { ... } - (`::Vertx::Future`) map(value)

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.

Overloads:

- - (`::Vertx::Future`) map(mapper) { ... }

  Yields:

  - the mapper function
- - (`::Vertx::Future`) map(value)

  Parameters:

  - value (`Object`) —
    the value that eventually completes the mapped future

Returns:

- (`::Vertx::Future`) —
  the mapped future

Raises:

- (`ArgumentError`)

    174
    175
    176
    177
    178
    179
    180
    181
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 174

    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(event)) })),::Vertx::Future, nil)
      elsif ::Vertx::Util::unknown_type.accept?(param_1) && !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, nil)
      end
      raise ArgumentError, "Invalid arguments when calling map(#{param_1})"
    end

### - (`::Vertx::Future`) map_empty

Map the result of a future to `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.

Returns:

- (`::Vertx::Future`) —
  the mapped future

Raises:

- (`ArgumentError`)

    190
    191
    192
    193
    194
    195
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 190

    def map_empty
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:mapEmpty, []).call(),::Vertx::Future, nil)
      end
      raise ArgumentError, "Invalid arguments when calling map_empty()"
    end

### - (`::Vertx::Future`) otherwise(mapper) { ... } - (`::Vertx::Future`) otherwise(value)

Map the failure of a future to a specific `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.

Overloads:

- - (`::Vertx::Future`) otherwise(mapper) { ... }

  Yields:

  - the mapper function
- - (`::Vertx::Future`) otherwise(value)

  Parameters:

  - value (`true`, `false`) —
    the value that eventually completes the mapped future

Returns:

- (`::Vertx::Future`) —
  the mapped future

Raises:

- (`ArgumentError`)

    226
    227
    228
    229
    230
    231
    232
    233
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 226

    def otherwise(param_1=nil)
      if block_given? && param_1 == nil
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:otherwise, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) })),::Vertx::Future, nil)
      elsif (param_1.class == TrueClass || param_1.class == FalseClass) && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:otherwise, [Java::JavaLang::Boolean.java_class]).call(param_1),::Vertx::Future, nil)
      end
      raise ArgumentError, "Invalid arguments when calling otherwise(#{param_1})"
    end

### - (`::Vertx::Future`) otherwise_empty

Map the failure of a future to `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.

Returns:

- (`::Vertx::Future`) —
  the mapped future

Raises:

- (`ArgumentError`)

    242
    243
    244
    245
    246
    247
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 242

    def otherwise_empty
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:otherwiseEmpty, []).call(),::Vertx::Future, nil)
      end
      raise ArgumentError, "Invalid arguments when calling otherwise_empty()"
    end

### - (`::Vertx::Future`) recover(mapper = nil) { ... }

Handles a failure of this Future by returning the result of another Future. If the mapper fails, then the returned future will be failed with this failure.

Yields:

- A function which takes the exception of a failure and returns a new future.

Returns:

- (`::Vertx::Future`) —
  A recovered future

Raises:

- (`ArgumentError`)

    210
    211
    212
    213
    214
    215
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 210

    def recover(mapper=nil)
      if block_given? && mapper == 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 })),::Vertx::Future, nil)
      end
      raise ArgumentError, "Invalid arguments when calling recover(#{mapper})"
    end

### - (`true`, `false`) result?

The result of the operation. This will be null if the operation failed.

Returns:

- (`true`, `false`) —
  the result or null if the operation failed.

Raises:

- (`ArgumentError`)

    111
    112
    113
    114
    115
    116
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 111

    def result?
      if !block_given?
        return @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.

Yields:

- the Handler that will be called with the result

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    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 ? ar.result : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_handler()"
    end

### - (`self`) set_raw_message(message = nil)

Get the raw JSON message for the event. This will be null for SOCKET_CREATED or SOCKET_CLOSED events as there is no message involved.

Parameters:

- message (`Hash{String => Object}`) (defaults to: `nil`) —
  the raw message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    272
    273
    274
    275
    276
    277
    278
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 272

    def set_raw_message(message=nil)
      if message.class == Hash && !block_given?
        @j_del.java_method(:setRawMessage, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(message))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_raw_message(#{message})"
    end

### - (`true`, `false`) succeeded?

Did it succeed?

Returns:

- (`true`, `false`) —
  true if it succeded or false otherwise

Raises:

- (`ArgumentError`)

    127
    128
    129
    130
    131
    132
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 127

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

### - (`true`, `false`) try_complete?(result = nil)

Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

Parameters:

- result (`true`, `false`) (defaults to: `nil`) —
  the result

Returns:

- (`true`, `false`) —
  false when the future is already completed

Raises:

- (`ArgumentError`)

    87
    88
    89
    90
    91
    92
    93
    94
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 87

    def try_complete?(result=nil)
      if !block_given? && result == nil
        return @j_del.java_method(:tryComplete, []).call()
      elsif (result.class == TrueClass || result.class == FalseClass) && !block_given?
        return @j_del.java_method(:tryComplete, [Java::JavaLang::Boolean.java_class]).call(result)
      end
      raise ArgumentError, "Invalid arguments when calling try_complete?(#{result})"
    end

### - (`true`, `false`) tryFail(cause) - (`true`, `false`) tryFail(failureMessage)

Try to set the failure. When it happens, any handler will be called, if there is one, and the future will be marked as completed.

Overloads:

- - (`true`, `false`) tryFail(cause)

  Parameters:

  - cause (`Exception`) —
    the failure cause
- - (`true`, `false`) tryFail(failureMessage)

  Parameters:

  - failureMessage (`String`) —
    the failure message

Returns:

- (`true`, `false`) —
  false when the future is already completed

Raises:

- (`ArgumentError`)

    101
    102
    103
    104
    105
    106
    107
    108
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 101

    def try_fail?(param_1=nil)
      if param_1.is_a?(Exception) && !block_given?
        return @j_del.java_method(:tryFail, [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(:tryFail, [Java::java.lang.String.java_class]).call(param_1)
      end
      raise ArgumentError, "Invalid arguments when calling try_fail?(#{param_1})"
    end

### - (`:SOCKET_CREATED`, ...) type

Returns the type of the event

Returns:

- (`:SOCKET_CREATED`, `:SOCKET_CLOSED`, `:SOCKET_IDLE`, `:SOCKET_PING`, `:SEND`, `:PUBLISH`, `:RECEIVE`, `:REGISTER`, `:UNREGISTER`) —
  the type of the event

Raises:

- (`ArgumentError`)

    249
    250
    251
    252
    253
    254
    255
    256
    257
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 249

    def type
      if !block_given?
        if @cached_type != nil
          return @cached_type
        end
        return @cached_type = @j_del.java_method(:type, []).call().name.intern
      end
      raise ArgumentError, "Invalid arguments when calling type()"
    end