Class ProjectionDryer<T extends Projection>
java.lang.Object
repast.simphony.freezedry.freezedryers.proj.ProjectionDryer<T>
- Direct Known Subclasses:
ContinuousProjectionDryer
,GeographyProjectionDryer
,GridProjectionDryer2
,NetworkProjectionDryer
Implementations of this class will handle storing settings for some projections. Implementations
should override the
handles(Class)
, #addProperties(Context, T, Map)
,
instantiate(Context, Map)
, and #loadProperties(Context, T, Map)
methods.
By default this adds (through it's static {}) a
NetworkProjectionDryer
, a
ContinuousProjectionDryer
, and a
repast.simphony.freezedry.freezedryers.proj.GridProjectionDryer
.- Author:
- Jerry Vos
- See Also:
-
handles(Class)
#addProperties(Context, T, Map)
instantiate(Context, Map)
#loadProperties(Context, T, Map)
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Adds a dryer to be used by theContextFreezeDryer
.protected abstract void
Called when attempting to save the given projection.buildAndAddProjection
(Context<?> context, Map<String, Object> properties) Creates a projection based on the given properties.static <T extends Projection>
ProjectionDryer<T>Retrieves the last added dryer that handles the given type.getProperties
(Context<?> context, T t) Retrieves the serializable properties for a given projection that is a member of the given context.abstract boolean
This should return true if the implementation handles projections of the given type.protected abstract T
instantiate
(Context<?> context, Map<String, Object> properties) Should createa a Projection for the given context.protected void
This handles loading of properties into the instantiated projection.
-
Field Details
-
NAME_KEY
- See Also:
-
PROJ_LISTENING_KEY
- See Also:
-
CONTEXT_LISTENING_KEY
- See Also:
-
-
Constructor Details
-
ProjectionDryer
public ProjectionDryer()
-
-
Method Details
-
addProperties
Called when attempting to save the given projection. Implementations should store the settings they require to build the projection later during this method, and also call their super's method so that it can store its properties.- Parameters:
context
- the context this projection is a member oft
- the projection to store properties forproperties
- a place to store the properties for a projection
-
instantiate
Should createa a Projection for the given context. Implementing classes do not have to add the created projection to the context, that will be done after calling this method.- Parameters:
context
- the context the projection will be a member ofproperties
- the properties specified when saving the projection- Returns:
- a created projection
-
handles
This should return true if the implementation handles projections of the given type.- Parameters:
type
- the type of the projection- Returns:
- if the implementation handles the given type
-
loadProperties
This handles loading of properties into the instantiated projection. Implementations should override this method and load their properties here. If the properties are loaded in theirinstantiate(Context, Map)
method, then if a subclass overrides the instantiate method it will have to duplicate the property loading (or that loading will not be done). Implementations should call their super's#loadProperties(Context, T, Map)
method so that all properties can be loaded. This implementation loads the projection as a context listener (if it originally one) and the context as a projection listener if it was. This then adds the projection to the context.- Parameters:
context
- the context the projection is a member ofproj
- the projection that was instantiatedproperties
- the properties that should be used to loaded into the projection
-
getProperties
Retrieves the serializable properties for a given projection that is a member of the given context. These properties should be reloaded and passed to thebuildAndAddProjection(Context, Map)
method when deserializing the projection.- Parameters:
context
- the context the projection is a member oft
- the projection to serialize- Returns:
- a Map of properties used to recreate the given projection
- See Also:
-
buildAndAddProjection
Creates a projection based on the given properties. It will also add the created projection to the given context.- Parameters:
context
- the context to build a projection forproperties
- the properties for building the projection- Returns:
- the created projection
-
addProjectionDryer
Adds a dryer to be used by theContextFreezeDryer
. This will be added to the front of the dryer list, so it will override any equivalent dryer added before it that dries the same class.- Parameters:
dryer
- a projection dryer
-
getDryer
Retrieves the last added dryer that handles the given type. If none is found this returns null.- Parameters:
type
- the projection type to dry- Returns:
- a dryer for the given type
-