Class List Method List File List

# Class: VertxBridgeCommon::BaseBridgeEvent

Inherits:
  Vertx::Promise
  - Object
  - Vertx::Promise
  - 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)

- - (void) complete(result = nil)
  Set the result.
- - (void) fail(param_1 = nil)
  Calls Vertx::Promise#fail with the message.
- - (::Vertx::Future) future
  The associated with this promise, it can be used to be aware of the promise completion.
- - (Hash{String => Object}) get_raw_message
  Get the raw JSON message for the event.
- - (self) set_raw_message(message = nil)
  Get the raw JSON message for the event.
- - (true, false) try_complete?(result = nil)
  Like Vertx::Promise#complete but returns false when the promise is already completed instead of throwing an IllegalStateException, it returns true otherwise.
- - (true, false) try_fail?(param_1 = nil)
  Calls Vertx::Promise#fail with the message.
- - (:SOCKET_CREATED, ...) type
  The type of the event.

### Methods inherited from Vertx::Promise

failed_promise, promise, succeeded_promise

## Class Method Details

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

Returns:

- (`Boolean`)

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

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

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

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

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

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

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

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

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

## Instance Method Details

### - (`void`) complete(result = nil)

This method returns an undefined value.

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

Any handler set on the associated promise will be called.

Parameters:

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

Raises:

- (`ArgumentError`)

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

    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

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

This method returns an undefined value.

Calls Vertx::Promise#fail with the `message`.

Overloads:

- - (`void`) fail(cause)

  Parameters:

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

  Parameters:

  - message (`String`) —
    the failure message

Raises:

- (`ArgumentError`)

    56
    57
    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 56

    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

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

Returns the associated with this promise, it can be used to be aware of the promise completion

Returns:

- (`::Vertx::Future`) —
  the associated with this promise, it can be used to be aware of the promise completion

Raises:

- (`ArgumentError`)

    91
    92
    93
    94
    95
    96
    97
    98
    99
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 91

    def future
      if !block_given?
        if @cached_future != nil
          return @cached_future
        end
        return @cached_future = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:future, []).call(),::Vertx::Future, nil)
      end
      raise ArgumentError, "Invalid arguments when calling future()"
    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`)

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

    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

### - (`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`)

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

    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`) try_complete?(result = nil)

Like Vertx::Promise#complete but returns `false` when the promise is already completed instead of throwing an IllegalStateException, it returns `true` otherwise.

Parameters:

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

Returns:

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

Raises:

- (`ArgumentError`)

    68
    69
    70
    71
    72
    73
    74
    75
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 68

    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(message)

Calls Vertx::Promise#fail with the `message`.

Overloads:

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

  Parameters:

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

  Parameters:

  - message (`String`) —
    the failure message

Returns:

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

Raises:

- (`ArgumentError`)

    82
    83
    84
    85
    86
    87
    88
    89
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 82

    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`)

    101
    102
    103
    104
    105
    106
    107
    108
    109
    # 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 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