org.eclipse.viatra.query.runtime.base.api

## Class QueryResultMultimap<KeyType,ValueType>

- java.lang.Object
- - org.eclipse.viatra.query.runtime.base.api.QueryResultAssociativeStore<KeyType,ValueType>
  - - org.eclipse.viatra.query.runtime.base.api.QueryResultMultimap<KeyType,ValueType>

- Type Parameters:
    `KeyType` - the type of the keys stored in the multimap
    `ValueType` - the type of the values stored in the multimap
  All Implemented Interfaces:
    com.google.common.collect.Multimap<KeyType,ValueType>
  Direct Known Subclasses:
    EVMBasedQueryResultMultimap

      public abstract class QueryResultMultimap<KeyType,ValueType>
      extends QueryResultAssociativeStore<KeyType,ValueType>
      implements com.google.common.collect.Multimap<KeyType,ValueType>

  Implementation of `Multimap` interface to represent query results. A query result multimap takes a model query, with a specified key (input/source) parameter and a value (output/target) parameter.

  Apart from the standard multimap behavior, it is possible to register listeners that are notified when the contents of the multimap change.

  Subclasses of the query result multimap can attach to any query evaluation engine and shoug

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.base.api.QueryResultAssociativeStore

      `NOT_ALLOW_MODIFICATIONS`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `QueryResultMultimap(org.apache.log4j.Logger logger)` Constructor only visible to subclasses.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Map<KeyType,java.util.Collection<ValueType>>` | `asMap()`
    `void` | `clear()`
    `boolean` | `containsEntry(java.lang.Object key, java.lang.Object value)`
    `boolean` | `containsKey(java.lang.Object key)`
    `boolean` | `containsValue(java.lang.Object value)`
    `java.util.Collection<java.util.Map.Entry<KeyType,ValueType>>` | `entries()`
    `java.util.Collection<ValueType>` | `get(KeyType key)`
    `protected com.google.common.collect.Multimap<KeyType,ValueType>` | `getCache()`
    `protected java.util.Collection<java.util.Map.Entry<KeyType,ValueType>>` | `getCacheEntries()` Returns the entries in the cache as a collection.
    `protected boolean` | `internalCacheContainsEntry(KeyType key, ValueType value)`
    `protected boolean` | `internalCachePut(KeyType key, ValueType value)`
    `protected boolean` | `internalCacheRemove(KeyType key, ValueType value)`
    `protected int` | `internalCacheSize()`
    `boolean` | `isEmpty()`
    `com.google.common.collect.Multiset<KeyType>` | `keys()`
    `java.util.Set<KeyType>` | `keySet()`
    `boolean` | `put(KeyType key, ValueType value)`
    `boolean` | `putAll(KeyType key, java.lang.Iterable<? extends ValueType> values)`
    `boolean` | `putAll(com.google.common.collect.Multimap<? extends KeyType,? extends ValueType> multimap)`
    `boolean` | `remove(java.lang.Object key, java.lang.Object value)`
    `java.util.Collection<ValueType>` | `removeAll(java.lang.Object key)`
    `java.util.Collection<ValueType>` | `replaceValues(KeyType key, java.lang.Iterable<? extends ValueType> values)`
    `protected void` | `setCache(com.google.common.collect.Multimap<KeyType,ValueType> cache)`
    `int` | `size()`
    `java.util.Collection<ValueType>` | `values()`

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.base.api.QueryResultAssociativeStore

      `addCallbackOnQueryResultUpdate, checkModificationThroughQueryResultSetter, getListeners, getLogger, getSetter, internalClear, internalPut, internalRemove, modifyThroughQueryResultSetter, notifyListeners, removeCallbackOnQueryResultUpdate, setListeners, setLogger, setQueryResultSetter, setSetter`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.google.common.collect.Multimap

      `equals, hashCode`

- - ### Constructor Detail

    - #### QueryResultMultimap

          protected QueryResultMultimap(org.apache.log4j.Logger logger)

      Constructor only visible to subclasses.
      Parameters:
        `logger` - a logger that can be used for error reporting

  - ### Method Detail

    - #### getCacheEntries

          protected java.util.Collection<java.util.Map.Entry<KeyType,ValueType>> getCacheEntries()

      Description copied from class: `QueryResultAssociativeStore`
      Returns the entries in the cache as a collection.
      Specified by:
        `getCacheEntries` in class `QueryResultAssociativeStore<KeyType,ValueType>`
      Returns:
        the entries

    - #### internalCachePut

          protected boolean internalCachePut(KeyType key,
                                             ValueType value)

      Specified by:
        `internalCachePut` in class `QueryResultAssociativeStore<KeyType,ValueType>`

    - #### internalCacheRemove

          protected boolean internalCacheRemove(KeyType key,
                                                ValueType value)

      Specified by:
        `internalCacheRemove` in class `QueryResultAssociativeStore<KeyType,ValueType>`

    - #### internalCacheContainsEntry

          protected boolean internalCacheContainsEntry(KeyType key,
                                                       ValueType value)

      Specified by:
        `internalCacheContainsEntry` in class `QueryResultAssociativeStore<KeyType,ValueType>`

    - #### internalCacheSize

          protected int internalCacheSize()

      Specified by:
        `internalCacheSize` in class `QueryResultAssociativeStore<KeyType,ValueType>`

    - #### getCache

          protected com.google.common.collect.Multimap<KeyType,ValueType> getCache()

      Returns:
        the cache

    - #### setCache

          protected void setCache(com.google.common.collect.Multimap<KeyType,ValueType> cache)

      Parameters:
        `cache` - the cache to set

    - #### size

          public int size()

      Specified by:
        `size` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### containsKey

          public boolean containsKey(java.lang.Object key)

      Specified by:
        `containsKey` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### containsValue

          public boolean containsValue(java.lang.Object value)

      Specified by:
        `containsValue` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### containsEntry

          public boolean containsEntry(java.lang.Object key,
                                       java.lang.Object value)

      Specified by:
        `containsEntry` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### get

          public java.util.Collection<ValueType> get(KeyType key)

      The returned collection is immutable.

      Specified by:
        `get` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### keySet

          public java.util.Set<KeyType> keySet()

      The returned set is immutable.

      Specified by:
        `keySet` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### keys

          public com.google.common.collect.Multiset<KeyType> keys()

      The returned multiset is immutable.

      Specified by:
        `keys` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### values

          public java.util.Collection<ValueType> values()

      The returned collection is immutable.

      Specified by:
        `values` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### entries

          public java.util.Collection<java.util.Map.Entry<KeyType,ValueType>> entries()

      The returned collection is immutable.

      Specified by:
        `entries` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### asMap

          public java.util.Map<KeyType,java.util.Collection<ValueType>> asMap()

      The returned map is immutable.

      Specified by:
        `asMap` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### put

          public boolean put(KeyType key,
                             ValueType value)

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      Specified by:
        `put` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### remove

          public boolean remove(java.lang.Object key,
                                java.lang.Object value)

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      Specified by:
        `remove` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### putAll

          public boolean putAll(KeyType key,
                                java.lang.Iterable<? extends ValueType> values)

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      Specified by:
        `putAll` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### putAll

          public boolean putAll(com.google.common.collect.Multimap<? extends KeyType,? extends ValueType> multimap)

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      Specified by:
        `putAll` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### replaceValues

          public java.util.Collection<ValueType> replaceValues(KeyType key,
                                                               java.lang.Iterable<? extends ValueType> values)

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      The returned collection is immutable.

      Specified by:
        `replaceValues` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### removeAll

          public java.util.Collection<ValueType> removeAll(java.lang.Object key)

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      The returned collection is immutable.

      Specified by:
        `removeAll` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`

    - #### clear

          public void clear()

      Throws `UnsupportedOperationException` if there is no `IQueryResultSetter`

      Specified by:
        `clear` in interface `com.google.common.collect.Multimap<KeyType,ValueType>`