LightJason - AgentSpeak(L++)
CRulePlaceholder.java
Go to the documentation of this file.
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 
24 package org.lightjason.agentspeak.language.instantiable.rule;
25 
26 import com.google.common.collect.Multimap;
36 
37 import javax.annotation.Nonnull;
38 import java.text.MessageFormat;
39 import java.util.List;
40 import java.util.stream.Stream;
41 
42 
51 public final class CRulePlaceholder implements IRule
52 {
56  private static final long serialVersionUID = 6857304030640970668L;
60  private final ILiteral m_id;
61 
67  public CRulePlaceholder( final ILiteral p_id )
68  {
69  m_id = p_id;
70  }
71 
72 
73  @Nonnull
74  @Override
75  public final ILiteral identifier()
76  {
77  return m_id;
78  }
79 
80  @Nonnull
81  @Override
82  public final IRule replaceplaceholder( @Nonnull final Multimap<IPath, IRule> p_rules )
83  {
84  return this;
85  }
86 
87  @Nonnull
88  @Override
89  public final IContext instantiate( @Nonnull final IAgent<?> p_agent, @Nonnull final Stream<IVariable<?>> p_variable )
90  {
91  return CCommon.instantiate( this, p_agent, p_variable );
92  }
93 
94  @Nonnull
95  @Override
96  public IFuzzyValue<Boolean> execute( final boolean p_parallel, @Nonnull final IContext p_context,
97  @Nonnull final List<ITerm> p_argument, @Nonnull final List<ITerm> p_return
98  )
99  {
100  return CFuzzyValue.from( false );
101  }
102 
103  @Nonnull
104  @Override
105  public final Stream<IVariable<?>> variables()
106  {
107  return Stream.empty();
108  }
109 
110  @Override
111  public final int hashCode()
112  {
113  return m_id.hashCode();
114  }
115 
116  @Override
117  public final boolean equals( final Object p_object )
118  {
119  return ( p_object instanceof IRule ) && ( this.hashCode() == p_object.hashCode() );
120  }
121 
122  @Override
123  public final String toString()
124  {
125  return MessageFormat.format(
126  "{0} ({1} ==>> ?)",
127  super.toString(),
128  m_id
129  );
130  }
131 
132 }
placeholder rule to define correct rule referencing
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
final ILiteral identifier()
returns the identifier of the rule
common structure for execution definition
final IRule replaceplaceholder( @Nonnull final Multimap< IPath, IRule > p_rules)
replaces all placeholder objects and reinstantiate object
execution context with local data
Definition: IContext.java:42
result for an immutable fuzzy value
final IContext instantiate( @Nonnull final IAgent<?> p_agent, @Nonnull final Stream< IVariable<?>> p_variable)
creates an individual execution context
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
final Stream< IVariable<?> > variables()
returns a stream with all used variables
static IContext instantiate( @Nonnull final IInstantiable p_instance, @Nonnull final IAgent<?> p_agent, @Nonnull final Stream< IVariable<?>> p_variable)
creates the instantiate execution context with default variables