24 package org.lightjason.agentspeak.language.execution.action;
34 import javax.annotation.Nonnull;
35 import java.text.MessageFormat;
36 import java.util.Collections;
37 import java.util.LinkedList;
38 import java.util.List;
39 import java.util.Objects;
40 import java.util.stream.Collectors;
41 import java.util.stream.IntStream;
42 import java.util.stream.Stream;
68 m_righthand = p_righthand;
74 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return )
76 final List<ITerm> l_result =
new LinkedList<>();
77 if ( ( !m_righthand.execute( p_parallel, p_context, Collections.<
ITerm>emptyList(), l_result ).value() )
78 || ( l_result.isEmpty() ) )
83 final List<ITerm> l_flatresult =
CCommon.flatten( l_result ).collect( Collectors.toList() );
84 final List<ITerm> l_assign =
CCommon.replaceFromContext( p_context,
m_value );
86 IntStream.range( 0, Math.min( l_assign.size(), l_flatresult.size() ) )
92 if ( l_assign.size() < l_flatresult.size() )
93 l_assign.get( l_assign.size() - 1 ).<
IVariable<Object>>term().
set( l_flatresult.subList( l_assign.size() - 1, l_flatresult.size() ) );
101 return ( Objects.isNull(
m_value ) ? 0 :
m_value.hashCode() ) ^ m_righthand.hashCode();
105 public final boolean equals(
final Object p_object )
107 return ( p_object instanceof
IExecution ) && ( this.
hashCode() == p_object.hashCode() );
113 return MessageFormat.format(
"{0} = {1}",
m_value, m_righthand );
120 return Stream.concat(
122 m_righthand.variables()
IVariable< T > set( @Nullable final T p_value)
sets the value
internal execution interface
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
common structure for execution definition
final boolean equals(final Object p_object)
CMultiAssignment( @Nonnull final List< IVariable<?>> p_lefthand, @Nonnull final M p_righthand)
ctor
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)
static final long serialVersionUID
serial id
execution context with local data
final Stream< IVariable<?> > variables()
result for an immutable fuzzy value
assignment action of a multi-variable list
final M m_righthand
right-hand argument
class for any helper calls