LightJason - AgentSpeak(L++)
CIntersection.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.fuzzy.operator.bool;
25 
30 
31 import javax.annotation.Nonnull;
32 import java.util.Arrays;
33 import java.util.Collections;
34 import java.util.Set;
35 import java.util.function.BiConsumer;
36 import java.util.function.BinaryOperator;
37 import java.util.function.Function;
38 import java.util.function.Supplier;
39 
40 
44 public final class CIntersection implements IFuzzyOperator<Boolean>
45 {
46 
47  @Override
48  public final Supplier<IFuzzyValueMutable<Boolean>> supplier()
49  {
51  }
52 
53  @Override
54  public final BiConsumer<IFuzzyValueMutable<Boolean>, IFuzzyValue<Boolean>> accumulator()
55  {
56  return ( i, j ) -> i.fuzzy( Math.min( i.fuzzy(), j.fuzzy() ) ).value( i.value() && j.value() );
57  }
58 
59  @Override
60  public final BinaryOperator<IFuzzyValueMutable<Boolean>> combiner()
61  {
62  return ( i, j ) -> i.fuzzy( Math.min( i.fuzzy(), j.fuzzy() ) ).value( i.value() && j.value() );
63  }
64 
65  @Override
66  public final Function<IFuzzyValueMutable<Boolean>, IFuzzyValue<Boolean>> finisher()
67  {
69  }
70 
71  @Override
72  public final Set<Characteristics> characteristics()
73  {
74  return Collections.emptySet();
75  }
76 
77  @Nonnull
78  @Override
79  @SafeVarargs
80  @SuppressWarnings( "varargs" )
81  public final IFuzzyValue<Boolean> result( @Nonnull final IFuzzyValue<Boolean>... p_values )
82  {
83  return Arrays.stream( p_values ).collect( this );
84  }
85 
92  {
93  return CFuzzyValueMutable.from( true, 1 );
94  }
95 
96 }
static IFuzzyValueMutable< Boolean > factory()
factory of the initialize value
final IFuzzyValue< Boolean > result( @Nonnull final IFuzzyValue< Boolean >... p_values)
final Function< IFuzzyValueMutable< Boolean >, IFuzzyValue< Boolean > > finisher()
final Supplier< IFuzzyValueMutable< Boolean > > supplier()
result for an immutable fuzzy value
final BinaryOperator< IFuzzyValueMutable< Boolean > > combiner()
static< N > IFuzzyValueMutable< N > from( @Nonnull final N p_value)
factory
final BiConsumer< IFuzzyValueMutable< Boolean >, IFuzzyValue< Boolean > > accumulator()
IFuzzyValue< T > immutable()
returns an immutable instance of the object