Class Model
- All Implemented Interfaces:
 IModel
public class Model extends java.lang.Object implements IModel
A Singleton IModel implementation.
In PureMVC, the Model class provides
 access to model objects (Proxies) by named lookup.
The Model assumes these responsibilities:
- Maintain a cache of 
IProxyinstances. - Provide methods for registering, retrieving, and removing
 
IProxyinstances. 
Your application must register IProxy instances
 with the Model. Typically, you use an
 ICommand to create and register IProxy
 instances once the Facade has initialized the Core
 actors.
- 
Field Summary
Fields Modifier and Type Field Description protected static IModelinstanceprotected java.util.concurrent.ConcurrentMap<java.lang.String,IProxy>proxyMapprotected java.lang.StringSINGLETON_MSG - 
Constructor Summary
Constructors Constructor Description Model()Constructor. - 
Method Summary
Modifier and Type Method Description static IModelgetInstance(java.util.function.Supplier<IModel> factory)ModelSingleton Factory method.booleanhasProxy(java.lang.String proxyName)Check if a Proxy is registeredprotected voidinitializeModel()Initialize the SingletonModelinstance.voidregisterProxy(IProxy proxy)Register anIProxywith theModel.IProxyremoveProxy(java.lang.String proxyName)Remove anIProxyfrom theModel.IProxyretrieveProxy(java.lang.String proxyName)Retrieve anIProxyfrom theModel. 
- 
Field Details
- 
proxyMap
 - 
instance
 - 
SINGLETON_MSG
protected final java.lang.String SINGLETON_MSG- See Also:
 - Constant Field Values
 
 
 - 
 - 
Constructor Details
- 
Model
public Model()Constructor.
This
IModelimplementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory methodModel.getInstance()- Throws:
 java.lang.Error- Error if Singleton instance has already been constructed
 
 - 
 - 
Method Details
- 
initializeModel
protected void initializeModel()Initialize the Singleton
Modelinstance.Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.
 - 
getInstance
ModelSingleton Factory method.- Parameters:
 factory- model supplier function- Returns:
 - the Singleton instance
 
 - 
registerProxy
Register an
IProxywith theModel.- Specified by:
 registerProxyin interfaceIModel- Parameters:
 proxy- anIProxyto be held by theModel.
 - 
retrieveProxy
Retrieve an
IProxyfrom theModel.- Specified by:
 retrieveProxyin interfaceIModel- Parameters:
 proxyName- proxy name- Returns:
 - the 
IProxyinstance previously registered with the givenproxyName. 
 - 
hasProxy
public boolean hasProxy(java.lang.String proxyName)Check if a Proxy is registered
 - 
removeProxy
Remove an
IProxyfrom theModel.- Specified by:
 removeProxyin interfaceIModel- Parameters:
 proxyName- name of theIProxyinstance to be removed.- Returns:
 - the 
IProxythat was removed from theModel 
 
 -