Package repast.simphony.context
Class ContextEvent<T>
- java.lang.Object
-
- repast.simphony.context.ContextEvent<T>
-
public class ContextEvent<T> extends Object
Represents a change occuring to a Context. This includes when objects are added to and removed from a Context (with thegetTarget()
being valid) or when projections are added and removed (with thegetProjection()
being valid).- Author:
- Tom Howe
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ContextEvent.EventType
Enum of the types of events.
-
Field Summary
Fields Modifier and Type Field Description static ContextEvent.EventType
ADDED
Represents an event where an object is added to the context.static ContextEvent.EventType
MOVED
static ContextEvent.EventType
REMOVED
Represents an event where an object is removed from the context.
-
Constructor Summary
Constructors Constructor Description ContextEvent(ContextEvent.EventType type, Context<T> context, Context<? extends T> subContext)
Creates a new instance of ContextEvent with a given type, context and sub-Context.ContextEvent(ContextEvent.EventType type, Context<T> context, Projection<? super T> projection)
Creates a new instance of ContextEvent with a given type, context and Projection.ContextEvent(ContextEvent.EventType type, Context<T> context, T target)
Creates a new instance of ContextEvent with a given type, context and target.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Context<T>
getContext()
Get the context to which the event occured.Projection<? super T>
getProjection()
Gets the project that was the target of the event.Context<? extends T>
getSubContext()
Gets the subcontext that was the target of the event, assuming this was a subcontext event.T
getTarget()
Get the target of the event.ContextEvent.EventType
getType()
Get the type of event this represents.
-
-
-
Field Detail
-
ADDED
public static ContextEvent.EventType ADDED
Represents an event where an object is added to the context.
-
MOVED
public static ContextEvent.EventType MOVED
-
REMOVED
public static ContextEvent.EventType REMOVED
Represents an event where an object is removed from the context.
-
-
Constructor Detail
-
ContextEvent
public ContextEvent(ContextEvent.EventType type, Context<T> context, T target)
Creates a new instance of ContextEvent with a given type, context and target.- Parameters:
type
- The type of event which occured.context
- The context to which the event occured.target
- The object which was the target of the event.
-
ContextEvent
public ContextEvent(ContextEvent.EventType type, Context<T> context, Projection<? super T> projection)
Creates a new instance of ContextEvent with a given type, context and Projection.- Parameters:
type
- The type of event which occured.context
- The context to which the event occured.projection
- The projection which was the target of the event.
-
ContextEvent
public ContextEvent(ContextEvent.EventType type, Context<T> context, Context<? extends T> subContext)
Creates a new instance of ContextEvent with a given type, context and sub-Context.- Parameters:
type
- The type of event which occured.context
- The context to which the event occured.subContext
- The subcontext which was the target of the event.
-
-
Method Detail
-
getType
public ContextEvent.EventType getType()
Get the type of event this represents.- Returns:
- The type of event.
-
getContext
public Context<T> getContext()
Get the context to which the event occured.- Returns:
- The effected Context.
-
getTarget
public T getTarget()
Get the target of the event.- Returns:
- The object which was the target of the event.
-
getProjection
public Projection<? super T> getProjection()
Gets the project that was the target of the event.- Returns:
- a projection that was added or removed
-
-