Package org.jgrapes.core
Interface Associator
- All Known Subinterfaces:
IOSubchannel
,MailChannel
,SocketIOChannel
,Subchannel
- All Known Implementing Classes:
Accepted
,ActionEvent
,Attached
,ClientConnected
,Close
,Closed
,CompletionEvent
,ConfigurationUpdate
,Connected
,ConnectError
,ConnectionManager.Connection
,DataInput
,Detached
,DiscardSession
,Error
,Event
,EventBase
,FileChanged
,FileOpened
,HalfClosed
,Handler.NoEvent
,HandlingError
,HostUnresolved
,HttpConnected
,InitialConfiguration
,InitialPreferences
,Input
,IOError
,IOEvent
,IOSubchannel.DefaultIOSubchannel
,JsonParsingError
,KeyValueStoreData
,KeyValueStoreQuery
,KeyValueStoreUpdate
,LinkedIOSubchannel
,MailConnectionManager.AbstractMailChannel
,MailFoldersUpdated
,MailMonitor.MonitorChannel
,MailMonitorOpened
,MailSender.SenderChannel
,MessageReceived
,NamedEvent
,NioRegistration
,NioRegistration.Completed
,Opened
,OpenFile
,Opening
,OpenMailConnection
,OpenMailMonitor
,OpenMailSender
,OpenSocketConnection
,Output
,ProcessExited
,ProcessManager.ProcessChannel
,ProcessStarted
,ProtocolSwitchAccepted
,Purge
,Ready
,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
,SocketConnectionManager.SocketChannelImpl
,Start
,Started
,StartProcess
,StartProcessError
,Stop
,StreamFile
,Subchannel.DefaultSubchannel
,UpdateMailFolders
,Upgraded
,WatchFile
,WebSocketClose
public interface Associator
Implemented by classes that allow arbitrary objects to be associated
with instances.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <V> Optional
<V> associated
(Class<V> by) 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”.associated
(String by) Retrieves the associated object following the association with the given name.default <V> Optional
<V> associatedGet
(Class<V> by) Assumes the associated object to be of typeSupplier<Optional<V>>
.<A extends Associator>
AsetAssociated
(Object by, Object with) 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 parameterwith
clears the association.- Type Parameters:
A
- the associator’s type- Parameters:
by
- the “name”with
- the object to be associated- Returns:
- the sub channel for easy chaining
-
associated
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
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
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
Assumes the associated object to be of typeSupplier<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
-