IPlan.java

  1. /*
  2.  * @cond LICENSE
  3.  * ######################################################################################
  4.  * # LGPL License                                                                       #
  5.  * #                                                                                    #
  6.  * # This file is part of the LightJason AgentSpeak(L++)                                #
  7.  * # Copyright (c) 2015-19, LightJason (info@lightjason.org)                            #
  8.  * # This program is free software: you can redistribute it and/or modify               #
  9.  * # it under the terms of the GNU Lesser General Public License as                     #
  10.  * # published by the Free Software Foundation, either version 3 of the                 #
  11.  * # License, or (at your option) any later version.                                    #
  12.  * #                                                                                    #
  13.  * # This program is distributed in the hope that it will be useful,                    #
  14.  * # but WITHOUT ANY WARRANTY; without even the implied warranty of                     #
  15.  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                      #
  16.  * # GNU Lesser General Public License for more details.                                #
  17.  * #                                                                                    #
  18.  * # You should have received a copy of the GNU Lesser General Public License           #
  19.  * # along with this program. If not, see http://www.gnu.org/licenses/                  #
  20.  * ######################################################################################
  21.  * @endcond
  22.  */

  23. package org.lightjason.agentspeak.language.instantiable.plan;

  24. import org.lightjason.agentspeak.agent.IAgent;
  25. import org.lightjason.agentspeak.language.ITerm;
  26. import org.lightjason.agentspeak.language.execution.IContext;
  27. import org.lightjason.agentspeak.language.fuzzy.CFuzzyValue;
  28. import org.lightjason.agentspeak.language.fuzzy.IFuzzyValue;
  29. import org.lightjason.agentspeak.language.instantiable.IInstantiable;
  30. import org.lightjason.agentspeak.language.instantiable.plan.trigger.ITrigger;
  31. import org.lightjason.agentspeak.language.variable.IVariable;

  32. import javax.annotation.Nonnull;
  33. import java.util.List;
  34. import java.util.stream.Stream;


  35. /**
  36.  * interface of plan
  37.  */
  38. public interface IPlan extends IInstantiable
  39. {
  40.     /**
  41.      * empty plan
  42.      */
  43.     IPlan EMPTY = new IPlan()
  44.     {
  45.         /**
  46.          * serial id
  47.          */
  48.         private static final long serialVersionUID = -8137749419571919583L;

  49.         @Nonnull
  50.         @Override
  51.         public final ITrigger trigger()
  52.         {
  53.             return ITrigger.EMPTY;
  54.         }

  55.         @Nonnull
  56.         @Override
  57.         public final IFuzzyValue<Boolean> condition( final IContext p_context )
  58.         {
  59.             return CFuzzyValue.from( true );
  60.         }

  61.         @Nonnull
  62.         @Override
  63.         public final IContext instantiate( @Nonnull final IAgent<?> p_agent, @Nonnull final Stream<IVariable<?>> p_variable )
  64.         {
  65.             return IContext.EMPTYPLAN;
  66.         }

  67.         @Nonnull
  68.         @Override
  69.         public final IFuzzyValue<Boolean> execute( final boolean p_parallel, @Nonnull final IContext p_context,
  70.                                                    @Nonnull final List<ITerm> p_argument, @Nonnull final List<ITerm> p_return )
  71.         {
  72.             return CFuzzyValue.from( true );
  73.         }

  74.         @Nonnull
  75.         @Override
  76.         public final Stream<IVariable<?>> variables()
  77.         {
  78.             return Stream.empty();
  79.         }
  80.     };

  81.     /**
  82.      * returns the trigger event
  83.      *
  84.      * @return trigger event
  85.      */
  86.     @Nonnull
  87.     ITrigger trigger();

  88.     /**
  89.      * execute the plan condition
  90.      *
  91.      * @param p_context execution context
  92.      * @return execution result
  93.      */
  94.     @Nonnull
  95.     IFuzzyValue<Boolean> condition( final IContext p_context );

  96. }