public final class SREutils extends Object
These utilities are provided for enabling the implementation of high-performance SRE by giving storage area into the instances of SARL concepts.
The data that is set and get by the functions in this utility class are SRE-dependent. The instance type of the data is known only by the SRE.
Note that any SRE-specific data stored into a SARL object has the following properties:
Object.equals(Object)
function;Object.hashCode()
function;Object.toString()
function.Modifier and Type | Method and Description |
---|---|
static <S extends Capacity> |
castInternalSkillReference(container : AbstractSkillContainer,
reference : AtomicSkillReference,
type : Class<S>)
Casts the internal skill reference of a skill container.
|
static void |
doBehaviorInstallation(behavior : Behavior)
Do the installation of the given behavior.
|
static void |
doBehaviorUninstallation(behavior : Behavior)
Do the uninstallation of the given behavior.
|
static void |
doEvaluateBehaviorGuards(receiver : IBehaviorGuardEvaluatorReceiver,
event : Object,
behaviorsMethodsToExecute : Collection<Runnable>)
Do the guard evaluations of the behavior units.
|
static void |
doGetSupportedEvents(receiver : IBehaviorGuardEvaluatorReceiver,
events : Set<Class<? extends Event>>)
Retrieve the events' types that are supported by the given receiver.
|
static boolean |
doIsSupportedEvent(receiver : IBehaviorGuardEvaluatorReceiver,
event : Class<? extends Event>)
Replies if the given event is supported by the given receiver.
|
static void |
doSkillInstallation(skill : Skill)
Do the installation of the given skill.
|
static void |
doSkillUninstallation(skill : Skill)
Do the uninstallation of the given skill.
|
static void |
doSkillUninstallationPreparation(skill : Skill)
Do the uninstallation preparation of the given skill.
|
static <S extends Capacity> |
getInternalSkill(container : AbstractSkillContainer,
type : Class<S>)
Replies the internal skill of a skill container.
|
static AtomicSkillReference |
getInternalSkillReference(container : AbstractSkillContainer,
type : Class<? extends Capacity>)
Replies the internal skill reference of a skill container.
|
static ConcurrentMap<Class<? extends Capacity>,AtomicSkillReference> |
getSkillRepository(container : AbstractSkillContainer)
Replies the skill repository of the given container.
|
static <S> S |
getSreSpecificData(container : SRESpecificDataContainer,
type : Class<S>)
Replies the data associated to the container by the SRE.
|
static void |
setDynamicSkillProvider(container : AbstractSkillContainer,
provider : DynamicSkillProvider)
Change the dynamic skill provider of a skill container.
|
static AtomicSkillReference |
setInternalSkill(container : AbstractSkillContainer,
skill : Skill,
capacities : Class<? extends Capacity>[])
Set the internal skill of a skill container.
|
static AtomicSkillReference |
setInternalSkillIfAbsent(container : AbstractSkillContainer,
skill : Skill,
capacities : Class<? extends Capacity>[])
Set the internal skill of a skill container if the skill is not yet mapped.
|
static void |
setSkillInstallationCallback(agent : Agent,
callback : (Agent,Skill)=>void)
Provide an agent with a callback function for the skill installation.
|
static void |
setSreSpecificData(container : SRESpecificDataContainer,
data : Object)
Change the data associated to the given container by the SRE.
|
static <S> S |
setSreSpecificData(container : SRESpecificDataContainer,
data : S,
type : Class<S>)
Change the data associated to the given container by the SRE.
|
@Pure public staticdef
getSreSpecificData(container : SRESpecificDataContainer, type : Class<S>) : Swith
<S>
SREutils
S
- the type of the data.type
- the type of the data.container
- the container.public static def
setSreSpecificData(container : SRESpecificDataContainer,
data : Object) : void
SREutils
container
- the container.data
- the SRE-specific data.public staticdef
setSreSpecificData(container : SRESpecificDataContainer, data : S, type : Class<S>) : Swith
<S>
SREutils
S
- the type of the data.type
- the type of the data.container
- the container.data
- the SRE-specific data.@Pure
public static def
getInternalSkillReference(container : AbstractSkillContainer,
type : Class<? extends Capacity>) : AtomicSkillReference
SREutils
container
- the container.type
- the type of the capacity.@Pure public staticdef
castInternalSkillReference(container : AbstractSkillContainer, reference : AtomicSkillReference, type : Class<S>) : Swith
<S extends Capacity>
SREutils
S
- the type of the capacity.container
- the container.reference
- the reference to cast.type
- the type of the capacity.public static def
setInternalSkill(container : AbstractSkillContainer,
skill : Skill,
capacities : Class<? extends Capacity>[]) : AtomicSkillReference
SREutils
container
- the container.skill
- the skill instance to attach to the container.capacities
- the list of implemented capacities. This array cannot be null
.public static def
setInternalSkillIfAbsent(container : AbstractSkillContainer,
skill : Skill,
capacities : Class<? extends Capacity>[]) : AtomicSkillReference
SREutils
container
- the container.skill
- the skill instance to attach to the container.capacities
- the list of implemented capacities. This array cannot be null
.@Pure public staticdef
getInternalSkill(container : AbstractSkillContainer, type : Class<S>) : Swith
<S extends Capacity>
SREutils
S
- the type of the capacity.container
- the container.type
- the type of the capacity.public static def
getSkillRepository(container : AbstractSkillContainer) : ConcurrentMap<Class<? extends Capacity>,AtomicSkillReference>
SREutils
The replied repository is not protected against asynchronous accesses.
container
- the container.public static def
setDynamicSkillProvider(container : AbstractSkillContainer,
provider : DynamicSkillProvider) : void
SREutils
container
- the container.provider
- the provider.public static def
doSkillInstallation(skill : Skill) : void
SREutils
This function invokes Skill.install()
and nothing more.
skill
- the skill to be installed.SREutils.doSkillUninstallationPreparation(Skill)
,
SREutils.doSkillUninstallation(Skill)
public static def
doSkillUninstallationPreparation(skill : Skill) : void
SREutils
This function invokes Skill.prepareUninstallation()
and nothing more.
skill
- the skill to be uninstalled.SREutils.doSkillInstallation(Skill)
,
SREutils.doSkillUninstallation(Skill)
public static def
doSkillUninstallation(skill : Skill) : void
SREutils
This function invokes Skill.uninstall()
and nothing more.
skill
- the skill to be uninstalled.SREutils.doSkillInstallation(Skill)
,
SREutils.doSkillUninstallationPreparation(Skill)
public static def
doEvaluateBehaviorGuards(receiver : IBehaviorGuardEvaluatorReceiver,
event : Object,
behaviorsMethodsToExecute : Collection<Runnable>) : void
SREutils
receiver
- is the object that receives the events.event
- is the event that causes the evaluation.behaviorsMethodsToExecute
- receives the behavior unit methods.public static def
doGetSupportedEvents(receiver : IBehaviorGuardEvaluatorReceiver,
events : Set<Class<? extends Event>>) : void
SREutils
receiver
- is the object that receives the events.events
- is the set to fill out with the supported events' types.public static def
doIsSupportedEvent(receiver : IBehaviorGuardEvaluatorReceiver,
event : Class<? extends Event>) : boolean
SREutils
receiver
- is the object that receives the events.event
- is the event to test.true
if the event is supported; false
otherwise.public static def
doBehaviorInstallation(behavior : Behavior) : void
SREutils
This function invokes Behavior.install()
and nothing more.
behavior
- the behavior to be installed.SREutils.doBehaviorUninstallation(Behavior)
public static def
doBehaviorUninstallation(behavior : Behavior) : void
SREutils
This function invokes Behavior.uninstall()
and nothing more.
behavior
- the behavior to be uninstalled.SREutils.doBehaviorInstallation(Behavior)
public static def
setSkillInstallationCallback(agent : Agent,
callback : (Agent,Skill)=>void) : void
SREutils
agent
- is the agent to equip.callback
- is the callback to install.Copyright © 2021 the original authors or authors.