Skip to content

Commit 2531851

Browse files
author
nicolaiparlog
committed
Documented package 'org.codefx.libfx.listener.handle'.
1 parent 380bc96 commit 2531851

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/main/java/org/codefx/libfx/listener/handle/ListenerHandleBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import java.util.function.BiConsumer;
66

77
/**
8-
* A builder for a {@link ListenerHandle}.
8+
* A builder for a {@link ListenerHandle}. Note that it is abstract enough to be used for all kinds of
9+
* observable/listener relation and not just for those occurring in JavaFX.
910
* <p>
1011
* The created handle manages whether the listener is currently attached. The functions specified to
1112
* {@link #onAttach(BiConsumer)} and {@link #onDetach(BiConsumer)} are only called when necessary. This is the case
@@ -16,7 +17,8 @@
1617
* This implies that they can be stateless functions which simply add and remove the listener. The functions are called
1718
* with the observable and listener specified during construction.
1819
* <p>
19-
* The {@link ListenerHandle} returned by this builder is not yet attached.
20+
* The {@link ListenerHandle} returned by this builder is not yet attached, i.e. it does not initially call the
21+
* functions give to {@code onAttach} or {@code onDetach}.
2022
* <p>
2123
* <h2>Example</h2> A typical use looks like this:
2224
*
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
/**
2-
* TODO
2+
* This package provides classes which make it easier to add and remove listeners from observable instances.
3+
* <p>
4+
* Using the default JavaFX 8 features, it is necessary to store both the observed instance and the listener if the
5+
* latter has to be added or removed repeatedly. A {@link org.codefx.libfx.listener.handle.ListenerHandle
6+
* ListenerHandle} encapsulates those references and the state whether a listener is currently added or not. It provides
7+
* an {@link org.codefx.libfx.listener.handle.ListenerHandle#attach() attach()} and a
8+
* {@link org.codefx.libfx.listener.handle.ListenerHandle#detach() detach} method which add or remove the listener.
9+
* Redundant calls (i.e. attaching when the listener is already added) are no-ops.
10+
* <p>
11+
* All features of <b>LibFX</b> which deal with listeners are aware of {@code ListenerHandle}s and respective methods
12+
* will return them. For observable classes included in the JDK, the factory
13+
* {@link org.codefx.libfx.listener.handle.ListenerHandles ListenerHandles} provides methods to easily create a handle.
14+
*
15+
* @see org.codefx.libfx.listener.handle.ListenerHandle ListenerHandle
16+
* @see org.codefx.libfx.listener.handle.ListenerHandles ListenerHandles
317
*/
418
package org.codefx.libfx.listener.handle;

0 commit comments

Comments
 (0)