Class RGoal

All Implemented Interfaces:
IElement, IFinishableElement<Void>, IGoal, IInternalPlan, IParameterElement, jadex.javaparser.IMapAccess

public class RGoal extends RFinishableElement implements IGoal, IInternalPlan
Goal instance implementation.
  • Field Details

    • lifecyclestate

      protected IGoal.GoalLifecycleState lifecyclestate
      The lifecycle state.
    • processingstate

      protected IGoal.GoalProcessingState processingstate
      The processing state.
    • parentplan

      protected RPlan parentplan
      The parent plan.
    • parentgoal

      protected RGoal parentgoal
    • childplan

      protected RPlan childplan
      The child plan.
    • candidate

      protected ICandidateInfo candidate
      The candidate from which this plan was created. Used for tried plans in proc elem.
  • Constructor Details

  • Method Details

    • getFetcherName

      public String getFetcherName()
      Get the name of the element in the fetcher (e.g. $goal).
      Specified by:
      getFetcherName in class RParameterElement
      Returns:
      The element name in the fetcher name.
    • adoptGoal

      public static void adoptGoal(RGoal rgoal)
      Adopt a goal so that the agent tries pursuing it.
    • getParentPlan

      public RPlan getParentPlan()
      Get the parentplan.
      Returns:
      The parentplan.
    • getParentGoal

      public RGoal getParentGoal()
      Get the parentgoal.
      Returns:
      The parentgoal.
    • getParent

      public RParameterElement getParent()
      Get parent (goal or plan).
    • setParent

      public void setParent(RGoal parent)
      Set parent (goal or plan).
    • setParent

      public void setParent(RPlan parent)
      Set parent (goal or plan).
    • getLifecycleState

      public IGoal.GoalLifecycleState getLifecycleState()
      Get the lifecycleState.
      Specified by:
      getLifecycleState in interface IGoal
      Returns:
      The lifecycleState.
    • doSetLifecycleState

      public void doSetLifecycleState(IGoal.GoalLifecycleState lifecyclestate)
      Set the lifecycleState.
      Parameters:
      lifecycleState - The lifecycleState to set.
    • getProcessingState

      public IGoal.GoalProcessingState getProcessingState()
      Get the processingState.
      Specified by:
      getProcessingState in interface IGoal
      Returns:
      The processingState.
    • doSetProcessingState

      public void doSetProcessingState(IGoal.GoalProcessingState processingstate)
      Set the processingState.
      Parameters:
      processingState - The processingState to set.
    • setProcessingState

      public void setProcessingState(IGoal.GoalProcessingState processingstate)
      Set the processingState.
      Parameters:
      processingState - The processingState to set.
    • setLifecycleState

      public void setLifecycleState(IGoal.GoalLifecycleState lifecyclestate)
      Set the lifecycle state.
      Parameters:
      processingState - The processingState to set.
    • abortPlans

      protected jadex.future.IFuture<Void> abortPlans()
      Abort the child plans.
    • getMGoal

      public MGoal getMGoal()
      Get the model element.
    • isSucceeded

      public boolean isSucceeded()
      Test if the element is succeeded.
      Specified by:
      isSucceeded in interface IFinishableElement<Void>
      Specified by:
      isSucceeded in class RFinishableElement
      Returns:
      True, if is succeeded.
    • isFailed

      public boolean isFailed()
      Test if the element is failed.
      Specified by:
      isFailed in interface IFinishableElement<Void>
      Specified by:
      isFailed in interface IInternalPlan
      Specified by:
      isFailed in class RFinishableElement
      Returns:
      True, if is failed.
    • isActive

      public boolean isActive()
      Test if the goal is in lifecyclestate 'active'.
      Specified by:
      isActive in interface IGoal
    • getChildPlan

      public RPlan getChildPlan()
      Get the childplan.
      Returns:
      The childplan.
    • setChildPlan

      public void setChildPlan(RPlan childplan)
      Set the childplan.
      Parameters:
      childplan - The childplan to set.
    • hashCode

      public int hashCode()
      Get the hashcode.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Test if equal to other object.
      Overrides:
      equals in class Object
    • planFinished

      public void planFinished(IInternalPlan rplan)
      Called when a plan is finished.
      Overrides:
      planFinished in class RProcessableElement
    • onActivate

      public boolean onActivate()
    • isRetry

      public boolean isRetry()
    • isRecur

      public boolean isRecur()
    • isProceduralSucceeded

      public boolean isProceduralSucceeded()
      Test if a goal has succeeded with respect to its plan execution.
    • isProceduralGoal

      public boolean isProceduralGoal()
    • getGoalResult

      public static Object getGoalResult(RGoal rgoal, ClassLoader cl)
      Get the goal result of the pojo element. Searches @GoalResult and delivers value.
    • drop

      public jadex.future.IFuture<Void> drop()
      Drop the goal.
      Specified by:
      drop in interface IGoal
    • addListener

      public void addListener(jadex.future.IResultListener<Void> listener)
      Add a new listener to get notified when the goal is finished.
      Specified by:
      addListener in interface IFinishableElement<Void>
      Overrides:
      addListener in class RFinishableElement
      Parameters:
      listener - The listener.
    • targetConditionTriggered

      public void targetConditionTriggered(jadex.rules.eca.IEvent event, jadex.rules.eca.IRule<Void> rule, Object context)
      Called when the target condition of a goal triggers.
    • setGoalResult

      public void setGoalResult(Object result, ClassLoader cl)
      Parameters:
      result -
      cl -
    • setGoalResult

      public void setGoalResult(Object result, ClassLoader cl, ChangeEvent<?> event, RPlan rplan, RProcessableElement rpe)
      Set the goal result from a plan.
    • callFinishedMethod

      public jadex.future.IFuture<Void> callFinishedMethod()
      Call the user finished method if available.
    • isPassed

      public boolean isPassed()
      Test if plan has passed.
      Specified by:
      isPassed in interface IInternalPlan
    • isAborted

      public boolean isAborted()
      Test if plan has been aborted.
      Specified by:
      isAborted in interface IInternalPlan
    • isAdopted

      public boolean isAdopted()
      Check if the element is currently part of the agent's reasoning. E.g. the bases are always adopted and all of their contents such as goals, plans and beliefs.
      Overrides:
      isAdopted in class RFinishableElement
    • isSame

      public boolean isSame(IGoal goal)
      Check if the goal is the same as another goal with respect to uniqueness settings. When two goals are the same this does not mean the objects are equal() in the Java sense!
    • isQueryGoalFinished

      public static boolean isQueryGoalFinished(RGoal goal)
      Test if a querygoal is finished. It is finished when all out parameters/sets are filled with a value.
    • getCandidate

      public ICandidateInfo getCandidate()
      Get the candidate.
      Specified by:
      getCandidate in interface IInternalPlan
      Returns:
      The candidate.
    • setCandidate

      public void setCandidate(ICandidateInfo candidate)
      Set the candidate.
      Parameters:
      candidate - The candidate to set.