Package org.gephi.project.spi
Interface Controller<T extends Model>
-
- Type Parameters:
T- the model class this controller handles
public interface Controller<T extends Model>Singleton controllers that want to store data in workspaces can implement this interface.When a new workspace is created, the project controller will be requesting from this singleton a new model via
newModel(Workspace)to be put in the workspace's lookup.Implementations should register themselves in the default lookup via the
ServiceProviderannotation.- See Also:
Model
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default TgetModel()Returns the model of the current workspace, ornullif no workspace is selected.default TgetModel(Workspace workspace)Returns the model of the given workspace.Class<T>getModelClass()Returns the model class this controller handles.TnewModel(Workspace workspace)Creates a new model instance for the given workspace.
-
-
-
Method Detail
-
newModel
T newModel(Workspace workspace)
Creates a new model instance for the given workspace.The model is not added to the workspace, it is the responsibility of the caller to do so.
- Parameters:
workspace- the workspace to create the model for- Returns:
- new instance of a model
-
getModelClass
Class<T> getModelClass()
Returns the model class this controller handles.- Returns:
- the model class
-
getModel
default T getModel(Workspace workspace)
Returns the model of the given workspace. If the model is not found, it returnsnull.This method is just a wrapper to
workspace.getLookup().lookup(getModelClass()).- Parameters:
workspace- workspace to retrieve the model from- Returns:
- the model of the given workspace or
nullif not found
-
getModel
default T getModel()
Returns the model of the current workspace, ornullif no workspace is selected.- Returns:
- model associated with the current workspace if it exists, or
nullotherwise
-
-