LightJason - AgentSpeak(L++)
beliefbase/storage/IStorage.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.beliefbase.storage;
25 
27 
28 import javax.annotation.Nonnull;
29 import java.util.Collection;
30 import java.util.stream.Stream;
31 
32 
41 public interface IStorage<N, M>
42 {
43 
49  @Nonnull
50  Stream<N> streamMultiElements();
51 
57  @Nonnull
58  Stream<M> streamSingleElements();
59 
66  boolean containsMultiElement( @Nonnull final String p_key );
67 
74  boolean containsSingleElement( @Nonnull final String p_key );
75 
83  boolean putMultiElement( @Nonnull final String p_key, final N p_value );
84 
92  boolean putSingleElement( @Nonnull final String p_key, final M p_value );
93 
101  boolean putSingleElementIfAbsent( @Nonnull final String p_key, final M p_value );
102 
110  boolean removeMultiElement( @Nonnull final String p_key, final N p_value );
111 
118  boolean removeSingleElement( @Nonnull final String p_key );
119 
126  M getSingleElement( @Nonnull final String p_key );
127 
135  M getSingleElementOrDefault( @Nonnull final String p_key, final M p_default );
136 
143  @Nonnull
144  Collection<N> getMultiElement( @Nonnull final String p_key );
145 
149  void clear();
150 
156  boolean empty();
157 
164  @Nonnull
165  IAgent<?> update( @Nonnull final IAgent<?> p_agent );
166 
172  int size();
173 
174 }
Stream< N > streamMultiElements()
returns a stream over all multi-elements
boolean containsSingleElement( @Nonnull final String p_key)
contains a single-element
boolean putSingleElementIfAbsent( @Nonnull final String p_key, final M p_value)
puts a single-element if it is absent
Stream< M > streamSingleElements()
returns a stream over all single-elements
boolean putMultiElement( @Nonnull final String p_key, final N p_value)
puts a multi-element into the storage
boolean removeMultiElement( @Nonnull final String p_key, final N p_value)
removes a multi-element from the storage
Collection< N > getMultiElement( @Nonnull final String p_key)
returns a collection of multi-elementy by name
boolean empty()
checks if a storage is empty
boolean containsMultiElement( @Nonnull final String p_key)
contains a multi-element
M getSingleElementOrDefault( @Nonnull final String p_key, final M p_default)
returns a single-element by the name
IAgent<?> update( @Nonnull final IAgent<?> p_agent)
updates all items
M getSingleElement( @Nonnull final String p_key)
returns a single-element by the name
boolean putSingleElement( @Nonnull final String p_key, final M p_value)
puts a single-element into the storage
boolean removeSingleElement( @Nonnull final String p_key)
removes a single-element from the storage