org.sonar.batch.index
Class Cache<V>

java.lang.Object
  extended by org.sonar.batch.index.Cache<V>

public class Cache<V>
extends Object

This cache is not thread-safe, due to direct usage of Exchange


Nested Class Summary
static class Cache.Entry<V>
           
 
Method Summary
 void clear()
          Clears the default as well as all group caches.
 Cache<V> clear(Object key)
          Removes everything in the specified group.
 Cache<V> clear(Object[] key)
           
 Cache<V> clear(Object firstKey, Object secondKey)
           
 Cache<V> clear(Object firstKey, Object secondKey, Object thirdKey)
           
 boolean containsKey(Object key)
           
 boolean containsKey(Object[] key)
           
 boolean containsKey(Object firstKey, Object secondKey)
           
 boolean containsKey(Object firstKey, Object secondKey, Object thirdKey)
           
 Iterable<Cache.Entry<V>> entries()
           
 Iterable<Cache.Entry<V>> entries(Object firstKey)
           
 V get(Object key)
          Returns the value object associated with keys, or null if not found.
 V get(Object[] key)
          Returns the value object associated with keys, or null if not found.
 V get(Object firstKey, Object secondKey)
          Returns the value object associated with keys, or null if not found.
 V get(Object firstKey, Object secondKey, Object thirdKey)
          Returns the value object associated with keys, or null if not found.
 Set<Object> keySet()
          Returns the set of keys associated with this cache.
 Set keySet(Object key)
          Returns the set of cache keys associated with this group.
 Set keySet(Object firstKey, Object secondKey)
           
 Cache<V> put(Object[] key, V value)
           
 Cache<V> put(Object firstKey, Object secondKey, Object thirdKey, V value)
           
 Cache<V> put(Object firstKey, Object secondKey, V value)
           
 Cache<V> put(Object key, V value)
           
 boolean remove(Object key)
           
 boolean remove(Object[] key)
           
 boolean remove(Object firstKey, Object secondKey)
           
 boolean remove(Object firstKey, Object secondKey, Object thirdKey)
           
 Iterable<V> values()
          Lazy-loading values
 Iterable<V> values(Object firstKey)
          Lazy-loading values for a given key
 Iterable<V> values(Object firstKey, Object secondKey)
          Lazy-loading values for given keys
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

put

public Cache<V> put(Object key,
                    V value)

put

public Cache<V> put(Object firstKey,
                    Object secondKey,
                    V value)

put

public Cache<V> put(Object firstKey,
                    Object secondKey,
                    Object thirdKey,
                    V value)

put

public Cache<V> put(Object[] key,
                    V value)

get

public V get(Object key)
Returns the value object associated with keys, or null if not found.


get

@CheckForNull
public V get(Object firstKey,
                          Object secondKey)
Returns the value object associated with keys, or null if not found.


get

@CheckForNull
public V get(Object firstKey,
                          Object secondKey,
                          Object thirdKey)
Returns the value object associated with keys, or null if not found.


get

@CheckForNull
public V get(Object[] key)
Returns the value object associated with keys, or null if not found.


containsKey

public boolean containsKey(Object key)

containsKey

public boolean containsKey(Object firstKey,
                           Object secondKey)

containsKey

public boolean containsKey(Object firstKey,
                           Object secondKey,
                           Object thirdKey)

containsKey

public boolean containsKey(Object[] key)

remove

public boolean remove(Object key)

remove

public boolean remove(Object firstKey,
                      Object secondKey)

remove

public boolean remove(Object firstKey,
                      Object secondKey,
                      Object thirdKey)

remove

public boolean remove(Object[] key)

clear

public Cache<V> clear(Object key)
Removes everything in the specified group.

Parameters:
group - The group name.

clear

public Cache<V> clear(Object firstKey,
                      Object secondKey)

clear

public Cache<V> clear(Object firstKey,
                      Object secondKey,
                      Object thirdKey)

clear

public Cache<V> clear(Object[] key)

clear

public void clear()
Clears the default as well as all group caches.


keySet

public Set keySet(Object key)
Returns the set of cache keys associated with this group. TODO implement a lazy-loading equivalent with Iterator/Iterable

Parameters:
group - The group.
Returns:
The set of cache keys for this group.

keySet

public Set keySet(Object firstKey,
                  Object secondKey)

keySet

public Set<Object> keySet()
Returns the set of keys associated with this cache.

Returns:
The set containing the keys for this cache.

values

public Iterable<V> values(Object firstKey,
                          Object secondKey)
Lazy-loading values for given keys


values

public Iterable<V> values(Object firstKey)
Lazy-loading values for a given key


values

public Iterable<V> values()
Lazy-loading values


entries

public Iterable<Cache.Entry<V>> entries()

entries

public Iterable<Cache.Entry<V>> entries(Object firstKey)


Copyright © 2009–2015 SonarSource. All rights reserved.