Interface Associator

All Known Subinterfaces:
IOSubchannel, Subchannel, TcpChannel
All Known Implementing Classes:
Accepted, ActionEvent, Attached, ClientConnected, Close, Closed, CompletionEvent, ConfigurationUpdate, Connected, ConnectError, Detached, DiscardSession, Error, Event, EventBase, FileOpened, HalfClosed, Handler.NoEvent, HandlingError, HostUnresolved, HttpConnected, InitialConfiguration, InitialPreferences, Input, IOError, IOEvent, IOSubchannel.DefaultIOSubchannel, KeyValueStoreData, KeyValueStoreQuery, KeyValueStoreUpdate, LinkedIOSubchannel, MessageReceived, NamedEvent, NioRegistration, NioRegistration.Completed, Opened, OpenFile, Opening, OpenTcpConnection, Output, ProtocolSwitchAccepted, Purge, Ready, ReceivedMailMessage, Request, Request.In, Request.In.Completed, Request.In.Connect, Request.In.Delete, Request.In.Get, Request.In.Head, Request.In.Options, Request.In.Post, Request.In.Put, Request.In.Trace, Request.Out, Request.Out.Connect, Request.Out.Delete, Request.Out.Get, Request.Out.Head, Request.Out.Options, Request.Out.Post, Request.Out.Put, Request.Out.Trace, Response, SaveInput, SaveOutput, SendMailMessage, Start, Started, Stop, StreamFile, Subchannel.DefaultSubchannel, TcpConnectionManager.TcpChannelImpl, Upgraded, WebSocketClose

public interface Associator
Implemented by classes that allow arbitrary objects to be associated with instances.
  • Method Summary

    Modifier and Type
    Method
    Description
    default <V> Optional<V>
    Retrieves the associated object following the association with the given class.
    <V> Optional<V>
    associated(Object by, Class<V> type)
    Retrieves the associated object following the association with the given “name”.
    default <V> V
    associated(Object by, Supplier<V> supplier)
    Retrieves the associated object following the association with the given “name”.
    default Optional<String>
    Retrieves the associated object following the association with the given name.
    default <V> Optional<V>
    Assumes the associated object to be of type Supplier<Optional<V>>.
    Establishes a “named” association to an associated object.
  • Method Details

    • setAssociated

      Establishes a “named” association to an associated object.

      Note that anything that represents an id can be used as value for parameter name, it does not necessarily have to be a string.

      Passing null as parameter with clears the association.

      Parameters:
      by - the “name”
      with - the object to be associated
      Returns:
      the sub channel for easy chaining
    • associated

      <V> Optional<V> associated(Object by, Class<V> type)
      Retrieves the associated object following the association with the given “name”.

      This general version of the method supports the retrieval of values of arbitrary types associated by any “name” types.

      Type Parameters:
      V - the type of the value to be retrieved
      Parameters:
      by - the “name”
      type - the type of the value to be retrieved
      Returns:
      the associate with the given type, if any
    • associated

      default <V> V associated(Object by, Supplier<V> supplier)
      Retrieves the associated object following the association with the given “name”.

      If no association exists, the object is created and the association is established.

      Type Parameters:
      V - the type of the value to be retrieved
      Parameters:
      by - the “name”
      supplier - the supplier
      Returns:
      the associate, if any
    • associated

      Retrieves the associated object following the association with the given name.

      This convenience methods simplifies the retrieval of String values associated by a (real) name.

      Parameters:
      by - the name
      Returns:
      the associate, if any
    • associated

      default <V> Optional<V> associated(Class<V> by)
      Retrieves the associated object following the association with the given class.

      The associated object must be an instance of the given class.

      Type Parameters:
      V - the type of the value
      Parameters:
      by - the name
      Returns:
      the associate, if any
    • associatedGet

      default <V> Optional<V> associatedGet(Class<V> by)
      Assumes the associated object to be of type Supplier<Optional<V>>.

      Invokes the supplier and returns the result.

      Type Parameters:
      V - the type of the value
      Parameters:
      by - the name
      Returns:
      the associate, if any