Class ActionDBEntry.Builder

java.lang.Object
edu.tufts.hrilab.action.db.ActionDBEntry.Builder
Enclosing class:
ActionDBEntry

public static class ActionDBEntry.Builder extends Object
  • Constructor Details

    • Builder

      public Builder(ActionDBEntry entryToCopy)
      Seed the Builder with an existing ActionDBEntry. This will copy all the existing action's fields into the Builder's fields. This is useful if you want to modify an existing action.
      Parameters:
      entryToCopy -
    • Builder

      public Builder(String type)
  • Method Details

    • getDefaultActorType

      public String getDefaultActorType()
      Getter for default semantic type for ?actor role.
      Returns:
    • setType

      public ActionDBEntry.Builder setType(String type)
      Set the action type (i.e., action method name).
      Parameters:
      type -
      Returns:
    • setDescription

      public ActionDBEntry.Builder setDescription(String val)
    • popEventSpec

      public ActionDBEntry.Builder popEventSpec()
    • addEventSpec

      public ActionDBEntry.Builder addEventSpec(EventSpec val)
      Add a new script event specification to a script
      Parameters:
      val - the event to be added to the (ordered) eventSpecs list (an event specification includes the name of the action to be executed and its parameters)
      Returns:
      this Builder instance
    • prependEventSpecs

      public ActionDBEntry.Builder prependEventSpecs(List<EventSpec> eventSpecs)
      Prepend a sequence of actions to the event specs.
      Parameters:
      eventSpecs -
      Returns:
    • appendEventSpecs

      public ActionDBEntry.Builder appendEventSpecs(List<EventSpec> eventSpecs)
      Append a sequence of actions to the event specs.
      Parameters:
      eventSpecs -
      Returns:
    • clearEventSpecList

      public ActionDBEntry.Builder clearEventSpecList()
    • addCondition

      public ActionDBEntry.Builder addCondition(Condition c)
      Add a condition that must hold for this action to be possible.
      Parameters:
      c - the condition to be added
      Returns:
      this Builder instance
    • removeCondition

      public ActionDBEntry.Builder removeCondition(Condition c)
      Remove a condition.
      Parameters:
      c - condition to be removed
      Returns:
    • addConditions

      public ActionDBEntry.Builder addConditions(Collection<Condition> conditionCollection)
      Add collection of conditions that must hold for this action to be possible
      Parameters:
      conditionCollection - collection of conditions to be added
      Returns:
      this Builder instance
    • addEffect

      public ActionDBEntry.Builder addEffect(Effect effect)
      Add an effect to be sent as a planner update whenever the action is executed.
      Parameters:
      effect - the effect to be added
      Returns:
      this Builder instance
    • addEffects

      public ActionDBEntry.Builder addEffects(Collection<Effect> effectCollection)
      Add a collection of effects to be sent as a planner update whenever the action is executed.
      Parameters:
      effectCollection - collection of effects to be added
      Returns:
      this Builder instance
    • prependEffect

      public ActionDBEntry.Builder prependEffect(Effect effect)
      Add an effect to the beginning of the Effect list to be sent as a planner update whenever the action is executed.
      Parameters:
      effect - the effect to be added
      Returns:
      this Builder instance
    • replaceEffect

      public ActionDBEntry.Builder replaceEffect(Effect toRemove, Effect toAdd)
      Replace an effect at the same location in the effects list.
      Parameters:
      toRemove - the effect to be removed
      toAdd - the effect to be added
      Returns:
      this Builder instance
    • removeEffect

      public ActionDBEntry.Builder removeEffect(Effect effect)
      Remove an effect.
      Parameters:
      effect - the effect to be removed
      Returns:
      this Builder instance
    • hasEffect

      public boolean hasEffect(Effect effect)
      Contains an effect.
      Parameters:
      effect - the effect
      Returns:
      this Builder instance
    • addObservation

      public ActionDBEntry.Builder addObservation(Predicate obs)
      Adds a state that this action can observe.
      Parameters:
      obs - observable fact
      Returns:
      this Builder instance
    • addRecoveryPolicyConstraint

      public ActionDBEntry.Builder addRecoveryPolicyConstraint(PolicyConstraints constraint)
      Adds a recovery policy constraint.
      Parameters:
      constraint - policy constraint
      Returns:
      this Builder instance
    • addOnCancelEvent

      public ActionDBEntry.Builder addOnCancelEvent(EventSpec onCancelEvent)
      Add EventSpec specifying what to do when this action is cancelled.
      Parameters:
      onCancelEvent -
      Returns:
    • addOnSuspendEvent

      public ActionDBEntry.Builder addOnSuspendEvent(EventSpec onSuspendEvent)
      Add EventSpec specifying what to do when this action is suspended.
      Parameters:
      onSuspendEvent -
      Returns:
    • addOnResumeEvent

      public ActionDBEntry.Builder addOnResumeEvent(EventSpec onResumeEvent)
      Add EventSpec specifying what to do when this action is resumed (after being suspended).
      Parameters:
      onResumeEvent -
      Returns:
    • hasOnCancelEvent

      public boolean hasOnCancelEvent()
      Checks if OnCancel Event has been added to the Builder.
      Returns:
    • hasOnSuspendEvent

      public boolean hasOnSuspendEvent()
      Checks if OnSuspend Event has been added to the Builder.
      Returns:
    • hasOnResumeEvent

      public boolean hasOnResumeEvent()
      Checks if OnResume Event has been added to the Builder.
      Returns:
    • addTranslationInfo

      public ActionDBEntry.Builder addTranslationInfo(TranslationInfo t)
      Adds info to translate a context of this dbEntry into another representation
      Parameters:
      t - the TranslationInfo for the action being built
      Returns:
      this Builder instance
    • addAgent

      public ActionDBEntry.Builder addAgent(Symbol agentName)
      Adds an agent on which this action will have an effect.
      Parameters:
      agentName - agent name
      Returns:
      this Builder instance
    • setRoles

      public ActionDBEntry.Builder setRoles(List<ActionBinding> roles)
      Replace all existing roles with the passed in roles.
      Parameters:
      roles -
      Returns:
    • addRole

      public ActionDBEntry.Builder addRole(ActionBinding newRole)
      Add new role.
      Parameters:
      newRole -
      Returns:
    • addRoles

      public ActionDBEntry.Builder addRoles(List<ActionBinding> newRoles)
      Convenience method for adding set of new roles. Internally calls the single addRole method to do any necessary checks before appending to roles list.
      Parameters:
      newRoles -
      Returns:
    • getRoles

      public List<ActionBinding> getRoles()
      Shallow copy of roles.
      Returns:
    • addResourceLock

      public ActionDBEntry.Builder addResourceLock(String name)
    • setPosAffect

      public ActionDBEntry.Builder setPosAffect(String val)
    • setNegAffect

      public ActionDBEntry.Builder setNegAffect(String val)
    • setCost

      public ActionDBEntry.Builder setCost(String val)
    • setBenefit

      public ActionDBEntry.Builder setBenefit(String val)
    • setTimeout

      public ActionDBEntry.Builder setTimeout(String val)
    • setTimeout

      public ActionDBEntry.Builder setTimeout(Long val)
    • setMinUrg

      public ActionDBEntry.Builder setMinUrg(String val)
    • setMaxUrg

      public ActionDBEntry.Builder setMaxUrg(String val)
    • setIsVarArgs

      public ActionDBEntry.Builder setIsVarArgs(boolean val)
    • setActionImplementer

      public ActionDBEntry.Builder setActionImplementer(ai.thinkingrobots.trade.TRADEServiceInfo tsi)
    • setDBFile

      public ActionDBEntry.Builder setDBFile(String file)
    • build

      public ActionDBEntry build(boolean addToDatabase)