T
- the event class this handler can handlepublic final class WeakEventHandler<T extends Event> extends Object implements EventHandler<T>
WeakEventHandler
proxy, the
proxy itself references the original handler only weakly and so doesn't
prevent it from being garbage collected. Until this weak reference is broken,
any event notification received by the proxy is forwarded to the original
handler.Constructor and Description |
---|
WeakEventHandler(EventHandler<T> eventHandler)
Creates a new instance of
WeakEventHandler . |
Modifier and Type | Method and Description |
---|---|
void |
handle(T event)
Forwards event notification to the associated event handler.
|
boolean |
wasGarbageCollected()
Indicates whether the associated event handler has been garbage
collected.
|
public WeakEventHandler(EventHandler<T> eventHandler)
WeakEventHandler
.eventHandler
- the original event handler to which to forward event
notificationspublic boolean wasGarbageCollected()
WeakEventHandler
is no longer necessary.true
if the associated handler has been garbage
collected, false
otherwisepublic void handle(T event)
handle
in interface EventHandler<T extends Event>
event
- the event which occurredSubmit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2019, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.