24 package org.lightjason.agentspeak.language.instantiable.plan;
26 import org.apache.commons.lang3.StringUtils;
40 import javax.annotation.Nonnull;
41 import java.text.MessageFormat;
42 import java.util.Collections;
43 import java.util.LinkedList;
44 import java.util.List;
45 import java.util.Objects;
47 import java.util.stream.Stream;
90 @Nonnull
final List<IExecution> p_body, @Nonnull
final Set<
IAnnotation<?>> p_annotation )
99 p_condition.hashCode()
101 p_body.stream().map( Object::hashCode ),
102 p_annotation.stream().map( Object::hashCode )
103 ).reduce( 0, ( i, j ) -> i ^ j )
106 m_triggerevent = p_event;
107 m_condition = p_condition;
120 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return
123 final IFuzzyValue<Boolean> l_result = super.execute( p_parallel, p_context, p_argument, p_return );
126 if ( !p_context.agent().fuzzy().getValue().defuzzify( l_result ) )
149 final List<ITerm> l_return =
new LinkedList<>();
151 m_condition.
execute(
false, p_context, Collections.emptyList(), l_return ).value()
152 && ( l_return.size() == 1 )
153 ? l_return.get( 0 ).<Boolean>raw()
161 return MessageFormat.format(
162 "{0} ({1} | {2}{3} ==>> {4})",
166 Objects.isNull( m_condition ) ?
"" : MessageFormat.format(
" |- {0}", m_condition ),
176 m_condition != null ? m_condition.
variables() : Stream.empty(),
final Map< IAnnotation.EType, IAnnotation<?> > m_annotation
map with annotation (enum value for getting annotation object)
base structure of instantiable elements
IExpression EMPTY
empty expression, is always true
IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
Stream< IVariable<?> > variables()
returns a stream with all used variables
static final long serialVersionUID
serial id
internal execution interface
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
common structure for execution definition
Stream< ITerm > orderedvalues( @Nullable final IPath... p_path)
returns a stream over the ordered values in sequential ordering
final IExpression m_condition
execution condition / expression
static Stream< ITerm > flattenrecursive( @Nonnull final Stream< ITerm > p_input)
recursive stream of term values
static ITrigger from( @Nonnull final EType p_event, @Nonnull final ILiteral p_literal)
creates a trigger event^
ILiteral unify( @Nonnull final IContext p_context)
unifies variables if exists
final ITrigger m_triggerevent
trigger event
execution context with local data
final List< IExecution > m_action
action list
Stream< IVariable<?> > variables()
returns a stream of variables
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
result for an immutable fuzzy value
CPlan( @Nonnull final ITrigger p_event, @Nonnull final List< IExecution > p_body, @Nonnull final Set< IAnnotation<?>> p_annotation)
ctor
final Stream< IVariable<?> > variables()
returns a stream with all used variables
final ITrigger trigger()
returns the trigger event
static< T > Stream< T > streamconcat( @Nonnull final Stream< T >... p_streams)
concat multiple streams
ILiteral literal()
returns the literal of the event
final IFuzzyValue< Boolean > condition(final IContext p_context)
execute the plan condition
CPlan( @Nonnull final ITrigger p_event, @Nonnull final IExpression p_condition, @Nonnull final List< IExecution > p_body, @Nonnull final Set< IAnnotation<?>> p_annotation)
ctor