24 package org.lightjason.agentspeak.beliefbase.storage;
26 import javax.annotation.Nonnull;
27 import java.util.Collection;
28 import java.util.Collections;
30 import java.util.concurrent.ConcurrentHashMap;
31 import java.util.stream.Stream;
42 private final Map<String, M>
m_elements =
new ConcurrentHashMap<>();
48 return Stream.empty();
55 return m_elements.values().stream();
67 return m_elements.containsKey( p_key );
71 public final boolean putMultiElement( @Nonnull
final String p_key,
final N p_value )
79 return !p_value.equals( m_elements.put( p_key, p_value ) );
85 return !p_value.equals( m_elements.putIfAbsent( p_key, p_value ) );
97 return m_elements.remove( p_key ) != null;
103 return m_elements.get( p_key );
109 return m_elements.getOrDefault( p_key, p_default );
116 return Collections.emptySet();
128 return m_elements.isEmpty();
final boolean putSingleElementIfAbsent( @Nonnull final String p_key, final M p_value)
puts a single-element if it is absent
final void clear()
clears all elements
final boolean containsSingleElement( @Nonnull final String p_key)
contains a single-element
final boolean empty()
checks if a storage is empty
default structure of a storage
final boolean containsMultiElement( @Nonnull final String p_key)
contains a multi-element
final boolean putMultiElement( @Nonnull final String p_key, final N p_value)
puts a multi-element into the storage
final M getSingleElement( @Nonnull final String p_key)
returns a single-element by the name
final boolean putSingleElement( @Nonnull final String p_key, final M p_value)
puts a single-element into the storage
final boolean removeMultiElement( @Nonnull final String p_key, final N p_value)
removes a multi-element from the storage
final M getSingleElementOrDefault( @Nonnull final String p_key, final M p_default)
returns a single-element by the name
final boolean removeSingleElement( @Nonnull final String p_key)
removes a single-element from the storage
final int size()
number of multi elements
Stream< M > streamSingleElements()
returns a stream over all single-elements
storage only for single elements
final Collection< N > getMultiElement( @Nonnull final String p_key)
returns a collection of multi-elementy by name
final Stream< N > streamMultiElements()
returns a stream over all multi-elements
final Map< String, M > m_elements
map with single elements