Package repast.simphony.context
Class FormerDefaultContext<T>
java.lang.Object
repast.simphony.context.FormerDefaultContext<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Context<T>,RepastElement
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from interface repast.simphony.context.Context
SYN_CONTEXT_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionFormerDefaultContext(Object name) FormerDefaultContext(Object name, Object typeID) FormerDefaultContext(Object name, Object typeID, FormerDefaultContext.ContextHint hint) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> collection) voidaddContextListener(ContextListener<T> listener) voidaddProjection(Projection<? super T> projection) Adds the specified Projection to this Context.voidaddSubContext(Context<? extends T> context) voidaddValueLayer(ValueLayer valueLayer) Adds the specified ValueLayer to this Context.voidclear()booleanbooleancontainsAll(Collection<?> c) findContext(Object id) This searches the specified context and its descendants for the context with the specified id.findParent(Object o) Retrieves the context of the specified object starting with the specified Context.getAgentLayer(Class<T> agentType) getId()getObjects(Class<?> clazz) Gets a IndexedIterable over the all the objects in this context (and thus in the sub contexts) that are of the specified type.getObjectsAsStream(Class<?> clazz) Gets a sequential Stream over the all the objects in this context (and thus in the sub contexts) that are of the specified type.<X extends Projection<?>>
XgetProjection(Class<X> projection, String name) Gets the named projection.Projection<?>getProjection(String name) Gets the named projection.Collection<Projection<?>>Gets an iterable over all the projections contained by this Context.<X extends Projection<?>>
Iterable<X>getProjections(Class<X> clazz) Gets all the projections in this Context of the specified type.Gets an object in this context chosen at random from a uniform distribution.getRandomObjects(Class<? extends T> clazz, long count) Gets an iterable over a collection of objects chosen at random.getRandomObjectsAsStream(Class<? extends T> clazz, long count) Gets a sequential Stream over a collection of objects chosen at random.getSubContext(Object id) Gets an id that indentifies the user-defined type of this context.getValueLayer(String name) Gets the named ValueLayer.Gets an iterable over the ValueLayer-s contained by this Context.booleanMethod to check if subcontext(s) are present in the contextbooleanisEmpty()iterator()query(org.apache.commons.collections15.Predicate query) booleanbooleanremoveAll(Collection<?> c) voidremoveContextListener(ContextListener<T> listener) Projection<? super T>removeProjection(String projectionName) Removes the named projection from this Context.voidremoveSubContext(Context<? extends T> context) removeValueLayer(String name) Removes the named ValueLayer from this Context.booleanretainAll(Collection<?> c) voidvoidSets an id that indentifies the user-defined type of this context.intsize()Object[]toArray()<U> U[]toArray(U[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
hint
-
delegate
-
-
Constructor Details
-
FormerDefaultContext
public FormerDefaultContext() -
FormerDefaultContext
-
FormerDefaultContext
-
FormerDefaultContext
-
FormerDefaultContext
-
-
Method Details
-
addContextListener
- Specified by:
addContextListenerin interfaceContext<T>
-
addProjection
Description copied from interface:ContextAdds the specified Projection to this Context.- Specified by:
addProjectionin interfaceContext<T>- Parameters:
projection- the projection to add
-
removeProjection
Removes the named projection from this Context.- Specified by:
removeProjectionin interfaceContext<T>- Parameters:
projectionName- the name projection to remove- Returns:
- the removed projection.
-
addSubContext
- Specified by:
addSubContextin interfaceContext<T>
-
getAgentLayer
- Specified by:
getAgentLayerin interfaceContext<T>
-
getAgentTypes
- Specified by:
getAgentTypesin interfaceContext<T>
-
getContextListeners
- Specified by:
getContextListenersin interfaceContext<T>
-
getProjection
Description copied from interface:ContextGets the named projection. This does not search subcontexts.- Specified by:
getProjectionin interfaceContext<T>- Parameters:
name- the name of the projection to get- Returns:
- the named projection.
-
getProjection
Description copied from interface:ContextGets the named projection. This does not query subcontexts.- Specified by:
getProjectionin interfaceContext<T>- Parameters:
projection- the type of the projectionname- the name of the projection to get- Returns:
- the named projection.
-
getProjections
Description copied from interface:ContextGets an iterable over all the projections contained by this Context.- Specified by:
getProjectionsin interfaceContext<T>- Returns:
- an iterable over all the projections contained by this Context.
-
getProjections
Description copied from interface:ContextGets all the projections in this Context of the specified type. This does not query subcontexts.- Specified by:
getProjectionsin interfaceContext<T>- Parameters:
clazz- the type of projections to get- Returns:
- all the projections in this Context of the specified type.
-
getSubContext
- Specified by:
getSubContextin interfaceContext<T>
-
findParent
Retrieves the context of the specified object starting with the specified Context. This will traverse into the specified context's sub contexts until it finds the lowest level context the object is in.- Specified by:
findParentin interfaceContext<T>- Parameters:
o- an object to find in the contexts- Returns:
- the context that contains the object
-
findContext
This searches the specified context and its descendants for the context with the specified id. This searches through the contexts in a breadth-first manner, and will return the first context whose getId() method returns the specified id. This includes the start context.- Specified by:
findContextin interfaceContext<T>- Parameters:
id- the id of the context to search for- Returns:
- the first context found with the given id, or null if no context is found
-
getSubContexts
- Specified by:
getSubContextsin interfaceContext<T>
-
query
-
removeContextListener
- Specified by:
removeContextListenerin interfaceContext<T>
-
removeSubContext
- Specified by:
removeSubContextin interfaceContext<T>
-
getObjects
Gets a IndexedIterable over the all the objects in this context (and thus in the sub contexts) that are of the specified type.- Specified by:
getObjectsin interfaceContext<T>- Parameters:
clazz- the type of objects to return- Returns:
- a IndexedIterable over the all the objects in this context (and thus in the sub contexts) that are of the specified type.
-
getRandomObjects
Gets an iterable over a collection of objects chosen at random. The number of objects is determined by the specified count and the type of objects by the specified class. If the context contains less objects than the specified count, all the appropriate objects in the context will be returned. If this is repeatedly called with a count equal to the number of objects in the context, the iteration order will be shuffled each time.- Specified by:
getRandomObjectsin interfaceContext<T>- Parameters:
clazz- the class of the objects to returncount- the number of random objects to return- Returns:
- an iterable over a collection of random objects
-
getRandomObject
Gets an object in this context chosen at random from a uniform distribution.- Specified by:
getRandomObjectin interfaceContext<T>- Returns:
- an object in this context chosen at random from a uniform distribution.
-
getId
- Specified by:
getIdin interfaceRepastElement
-
setId
- Specified by:
setIdin interfaceRepastElement
-
getTypeID
Gets an id that indentifies the user-defined type of this context. A context type typically refers to the role the context plays in a particular model. For example, the type of the context may be "School" and the agents in that context would be "Pupils". -
setTypeID
Sets an id that indentifies the user-defined type of this context. A context type typically refers to the role the context plays in a particular model. For example, the type of the context may be "School" and the agents in that context would be "Pupils". -
clear
public void clear()- Specified by:
clearin interfaceCollection<T>
-
contains
- Specified by:
containsin interfaceCollection<T>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>
-
iterator
-
remove
- Specified by:
removein interfaceCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>
-
toArray
- Specified by:
toArrayin interfaceCollection<T>
-
toArray
public <U> U[] toArray(U[] a) - Specified by:
toArrayin interfaceCollection<T>
-
add
- Specified by:
addin interfaceCollection<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>
-
addValueLayer
Adds the specified ValueLayer to this Context.- Specified by:
addValueLayerin interfaceContext<T>- Parameters:
valueLayer- the ValueLayer to add
-
getValueLayer
Gets the named ValueLayer. This does not search subcontexts.- Specified by:
getValueLayerin interfaceContext<T>- Parameters:
name- the name of the ValueLayer to get- Returns:
- the named ValueLayer.
-
getValueLayers
Gets an iterable over the ValueLayer-s contained by this Context.- Specified by:
getValueLayersin interfaceContext<T>- Returns:
- an iterable over the ValueLayer-s contained by this Context.
-
removeValueLayer
Removes the named ValueLayer from this Context.- Specified by:
removeValueLayerin interfaceContext<T>- Parameters:
name- the name of the ValueLayer to remove.- Returns:
- the removed ValueLayer or null if the named ValueLayer was not found.
-
hasSubContext
public boolean hasSubContext()Description copied from interface:ContextMethod to check if subcontext(s) are present in the context- Specified by:
hasSubContextin interfaceContext<T>- Returns:
- true if subcontext(s) are present and false if not
-
getObjectsAsStream
Gets a sequential Stream over the all the objects in this context (and thus in the sub contexts) that are of the specified type.- Specified by:
getObjectsAsStreamin interfaceContext<T>- Parameters:
clazz- the type of objects to return- Returns:
- a Stream over the all the objects in this context (and thus in the sub contexts) that are of the specified type.
-
getRandomObjectsAsStream
Gets a sequential Stream over a collection of objects chosen at random. The number of objects is determined by the specified count and the type of objects by the specified class. If the context contains less objects than the specified count, all the appropriate objects in the context will be returned.If this is repeatedly called with a count equal to the number of objects in the context, the iteration order will be shuffled each time.
- Specified by:
getRandomObjectsAsStreamin interfaceContext<T>- Parameters:
clazz- the class of the objects to returncount- the number of random objects to return- Returns:
- a sequential Stream over a collection of random objects
-