public abstract class AgentTrait extends AgentProtectedAPIObject
Modifier | Constructor and Description |
---|---|
protected |
AgentTrait()
Construct a trait.
|
protected |
AgentTrait(agent : Agent)
Construct a trait to the given agent.
|
Modifier and Type | Method and Description |
---|---|
protected <S extends Capacity> |
clearSkill(capacity : Class<S>)
Clears the Skill associated with the capacity.
|
UUID |
getID()
Replies the identifier of the agent that has this trait.
|
Agent |
getOwner()
Replies the agent that has this trait.
|
protected <S extends Capacity> |
getSkill(capacity : Class<S>)
Replies the skill corresponding to the given capacity.
|
protected boolean |
hasSkill(capacity : Class<? extends Capacity>)
Checks if this agent has a Skill that implements the
Capacity
capacity . |
boolean |
isFromMe(event : Event)
Replies if the given event was emitted by this agent.
|
boolean |
isMe(address : Address)
Replies if the given address is one of the addresses of this agent.
|
boolean |
isMe(uID : UUID)
Replies if the given identifier corresponds to the identifier
of this agent.
|
protected <S extends Skill> |
operator_mappedTo(capacity : Class<? extends Capacity>,
skill : S)
Defines the implementation of the "capacity maps-to skill" operator.
|
protected <S extends Skill> |
setSkill(skill : S,
capacities : Class<? extends Capacity>*)
Set the skill for the
Capacity capacity . |
protected void |
setSkillIfAbsent(skill : Skill,
capacities : Class<? extends Capacity>*)
Set the skill for the
Capacity capacity if the mapping is not yet set. |
protected void |
toString(builder : org.eclipse.xtext.xbase.lib.util.ToStringBuilder)
fill the given builder with the string representation of this object.
|
toString
protected new
(agent : Agent)
agent
- the owner of this trait.protected new
()
protected def
toString(builder : org.eclipse.xtext.xbase.lib.util.ToStringBuilder) : void
AgentProtectedAPIObject
toString
in class AgentProtectedAPIObject
builder
- the string builder.@Pure
public def
getOwner() : Agent
AgentTrait
@Pure
public def
getID() : UUID
AgentTrait
@Pure protected finaldef
getSkill(capacity : Class<S>) : Swith
<S extends Capacity>
AgentProtectedAPIObject
The return may never be null
. If not capacity
was set, the exception UnimplementedCapacityException
is thrown.
getSkill
in class AgentProtectedAPIObject
S
- - type of the capacity.capacity
- the capacity to search for the implementation.null
protecteddef
operator_mappedTo(capacity : Class<? extends Capacity>, skill : S) : voidwith
<S extends Skill>
AgentProtectedAPIObject
operator_mappedTo
in class AgentProtectedAPIObject
S
- - type of skill to be mapped to.capacity
- the implemented capacity.skill
- the skill to associate to the capacity.@SafeVarargs protected finaldef
setSkill(skill : S, capacities : Class<? extends Capacity>*) : Swith
<S extends Skill>
AgentProtectedAPIObject
Capacity
capacity
.setSkill
in class AgentProtectedAPIObject
S
- - type of the skill.skill
- implementation of capacity
.capacities
- the capacity or the capacities to set.AgentProtectedAPIObject.setSkillIfAbsent(Skill, Class...)
@SafeVarargs
protected final def
setSkillIfAbsent(skill : Skill,
capacities : Class<? extends Capacity>*) : void
AgentProtectedAPIObject
Capacity
capacity
if the mapping is not yet set.setSkillIfAbsent
in class AgentProtectedAPIObject
skill
- implementation of capacity
.capacities
- the capacity or the capacities to set.AgentProtectedAPIObject.setSkill(Skill, Class...)
protecteddef
clearSkill(capacity : Class<S>) : Swith
<S extends Capacity>
AgentProtectedAPIObject
clearSkill
in class AgentProtectedAPIObject
S
- - the type of the capacity.capacity
- the capacity for which the skill must be cleared.@Pure
protected def
hasSkill(capacity : Class<? extends Capacity>) : boolean
AgentProtectedAPIObject
Capacity
capacity
.hasSkill
in class AgentProtectedAPIObject
capacity
- capacity to checktrue
if it has a skill associate to this capacity,
false
otherwise@Pure
public def
isMe(address : Address) : boolean
AgentProtectedAPIObject
Address.getID()
.isMe
in class AgentProtectedAPIObject
address
- the address to test.true
if the given address is one of this agent,
otherwise false
.@Pure
public def
isMe(uID : UUID) : boolean
AgentProtectedAPIObject
This function is equivalent to:
id.equals( agent.getID() )
isMe
in class AgentProtectedAPIObject
uID
- the identifier to test.true
if the given identifier is the one of this agent,
otherwise false
.@Pure
public def
isFromMe(event : Event) : boolean
AgentProtectedAPIObject
isFromMe
in class AgentProtectedAPIObject
event
- the event to test.true
if the given event was emitted by
this agent; otherwise false
.Copyright © 2021 the original authors or authors.