E - a type of Listenerpublic abstract class Model<E extends Listener<? extends Model>> extends Listenable<E>
| Modifier and Type | Field and Description |
|---|---|
private boolean |
isConnected
Whether or not the model has connected with the Pathfinder server.
|
private static org.slf4j.Logger |
logger |
private Path |
path
The path of the model.
|
private PathfinderServices |
services
A pathfinder services object to have access to the model registry
and the web socket.
|
| Constructor and Description |
|---|
Model(String path,
ModelType type,
PathfinderServices services)
Creates a basic object that all pathfinder models should use.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract JsonObject |
createValueJson()
Returns the value used in create request to the Pathfinder server
|
protected Path |
getChildPath(String name,
ModelType type)
Returns the path of a child of this model.
|
ModelType |
getModelType()
Returns the type of the model
|
String |
getName()
Returns the name of the model.
|
Cluster |
getParentCluster()
Returns the parent cluster of this model.
|
Path |
getParentPath()
Returns the path of the parent of this model.
|
protected Path |
getPath()
Returns the path of the model.
|
String |
getPathName()
Returns the string of the path of the model.
|
protected PathfinderServices |
getServices()
Returns the pathfinder services object.
|
boolean |
isConnected()
Returns if the model has connected to the Pathfinder server.
|
protected boolean |
notifyUpdate(String reason,
JsonObject json)
Method called when an update occurs.
|
protected abstract void |
route(JsonObject json,
PathfinderServices services)
Updates the models routes.
|
protected void |
setConnected(boolean connected)
Sets if the model has connected with the Pathfinder server.
|
protected abstract boolean |
updateFields(JsonObject json)
Updates the fields of the model.
|
private boolean |
updateType(String reason,
JsonObject json)
Invokes the model unspecific notifications.
|
addListener, getListeners, removeListenerprivate static final org.slf4j.Logger logger
private final Path path
private final PathfinderServices services
private boolean isConnected
public Model(String path, ModelType type, PathfinderServices services)
path - to the model on the Pathfinder server.type - of the model.services - a pathfinder services object.protected Path getPath()
public String getPathName()
protected Path getChildPath(String name, ModelType type)
name - the name to added on to the path.type - of the model.public Path getParentPath()
public String getName()
public Cluster getParentCluster()
public ModelType getModelType()
protected PathfinderServices getServices()
protected void setConnected(boolean connected)
connected - has connected with the Pathfinder server.public boolean isConnected()
private boolean updateType(String reason, JsonObject json)
reason - message typejson - the messageprotected boolean notifyUpdate(String reason, JsonObject json)
notifyUpdate in class Listenable<E extends Listener<? extends Model>>reason - for notifying the model.json - object of the updated model.protected abstract JsonObject createValueJson()
protected abstract boolean updateFields(JsonObject json)
json - of the model.protected abstract void route(JsonObject json, PathfinderServices services)
json - of the model.services - pathfinder services object.