public abstract class Model
extends java.lang.Object
Model
class describes all the basic functionality of a model
within the MVC architecture.
From Wikipedia:
A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands.
Constructor and Description |
---|
Model(Application application)
Initialize a new
Model instance for the specified
Application . |
Modifier and Type | Method and Description |
---|---|
protected Application |
application()
Access the
Application that the Model is associated with. |
protected boolean |
emit(java.lang.String event)
Emit an event with the specified name.
|
protected <T> boolean |
emit(java.lang.String event,
T data)
Emit an event with the specified name and data.
|
<T> boolean |
off(java.lang.String event,
java.util.function.Consumer<T> consumer)
Detach a
Consumer from the specified event. |
<T> boolean |
on(java.lang.String event,
java.util.function.Consumer<T> consumer)
Attach a
Consumer to the specified event. |
public Model(Application application)
Model
instance for the specified
Application
.application
- The Application
that the Model
is
associated with.protected final Application application()
Application
that the Model
is associated with.Application
that the Model
is associated with.protected final boolean emit(java.lang.String event)
event
- The name of the event to emit.Consumer
.protected final <T> boolean emit(java.lang.String event, T data)
T
- The type of data to utilize in Consumers
.event
- The name of the event to emit.data
- The data to pass on to Consumers
.Consumer
.public final <T> boolean on(java.lang.String event, java.util.function.Consumer<T> consumer)
Consumer
to the specified event.T
- The type of data to utilize in Consumers
.event
- The name of the event to attach the Consumer
to.consumer
- The Consumer
to attach to the specified event.Consumers
attached to the
specified event.public final <T> boolean off(java.lang.String event, java.util.function.Consumer<T> consumer)
Consumer
from the specified event.T
- The type of data to utilize in Consumers
.event
- The name of the event to detach the Consumer
from.consumer
- The Consumer
to detach from the specified event.Consumers
attached to the
specified event.