org.eclipse.jgit.lib
Class ObjectIdSubclassMap<V extends ObjectId>

java.lang.Object
  extended by org.eclipse.jgit.lib.ObjectIdSubclassMap<V>
Type Parameters:
V - type of subclass of ObjectId that will be stored in the map.
All Implemented Interfaces:
java.lang.Iterable<V>

public class ObjectIdSubclassMap<V extends ObjectId>
extends java.lang.Object
implements java.lang.Iterable<V>

Fast, efficient map specifically for ObjectId subclasses.

This map provides an efficient translation from any ObjectId instance to a cached subclass of ObjectId that has the same value.

Raw value equality is tested when comparing two ObjectIds (or subclasses), not reference equality and not .equals(Object) equality. This allows subclasses to override equals to supply their own extended semantics.


Constructor Summary
ObjectIdSubclassMap()
          Create an empty map.
 
Method Summary
<Q extends V>
void
add(Q newValue)
          Store an object for future lookup.
 void clear()
          Remove all entries from this map.
 V get(AnyObjectId toFind)
          Lookup an existing mapping.
 java.util.Iterator<V> iterator()
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectIdSubclassMap

public ObjectIdSubclassMap()
Create an empty map.

Method Detail

clear

public void clear()
Remove all entries from this map.


get

public V get(AnyObjectId toFind)
Lookup an existing mapping.

Parameters:
toFind - the object identifier to find.
Returns:
the instance mapped to toFind, or null if no mapping exists.

add

public <Q extends V> void add(Q newValue)
Store an object for future lookup.

An existing mapping for must not be in this map. Callers must first call get(AnyObjectId) to verify there is no current mapping prior to adding a new mapping.

Type Parameters:
Q - type of instance to store.
Parameters:
newValue - the object to store.

size

public int size()
Returns:
number of objects in map

iterator

public java.util.Iterator<V> iterator()
Specified by:
iterator in interface java.lang.Iterable<V extends ObjectId>