Class IndexedCollection<K,T extends Comparable>
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.IndexedCollection<K,T>
-
- All Implemented Interfaces:
ReadOnlyIndexedCollection<K,T>
public class IndexedCollection<K,T extends Comparable> extends Object implements ReadOnlyIndexedCollection<K,T>
A collection of sorted objects with fast index by id. By default objects are sorted by their Comparable implementation. Ordering could be changed with custom comparator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IndexedCollection.CollectionListener<K,T>
static class
IndexedCollection.CollectionListenerAdapter<K,T>
static interface
IndexedCollection.Processor<T>
-
Field Summary
Fields Modifier and Type Field Description static String
INDEX_CACHE_DELAY_MILLIS_PROP
static String
INDEX_CACHE_SIZE_THRESHOLD_PROP
-
Constructor Summary
Constructors Constructor Description IndexedCollection()
IndexedCollection(Map<K,T> objectsMap)
IndexedCollection(Map<K,T> objectsMap, Comparator<? super T> comparator)
IndexedCollection(IndexedCollection<K,T> collection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFirstListener(IndexedCollection.CollectionListener<K,T> collectionListener)
void
addListener(IndexedCollection.CollectionListener<K,T> collectionListener)
void
afterObjectLoad(T loadedObject)
void
clear()
boolean
containsKey(K key)
T
find(K id)
<C extends Collection<? super T>>
CfindAll(C result, Collection<K> ids)
Collection<T>
getAll()
int
getChangesNumber()
Comparator<? super T>
getComparator()
Set<K>
getKeys()
Map<K,T>
getMap()
List<T>
getSorted()
<C extends List<? super T>>
CgetSorted(C result, Filter<? super T> filter)
void
processItems(Collection<K> ids, ItemProcessor<T> itemProcessor)
void
processItems(ItemProcessor<T> itemProcessor)
T
put(K id, T obj)
T
remove(K id)
T
replace(K id, T obj)
void
resort()
void
setComparator(Comparator<? super T> comparator)
int
size()
protected Lock
writeLock()
-
-
-
Field Detail
-
INDEX_CACHE_DELAY_MILLIS_PROP
public static final String INDEX_CACHE_DELAY_MILLIS_PROP
- See Also:
- Constant Field Values
-
INDEX_CACHE_SIZE_THRESHOLD_PROP
public static final String INDEX_CACHE_SIZE_THRESHOLD_PROP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndexedCollection
public IndexedCollection()
-
IndexedCollection
public IndexedCollection(@NotNull IndexedCollection<K,T> collection)
-
IndexedCollection
public IndexedCollection(@NotNull Map<K,T> objectsMap, @NotNull Comparator<? super T> comparator)
-
-
Method Detail
-
setComparator
public void setComparator(@Nullable Comparator<? super T> comparator)
-
getComparator
public Comparator<? super T> getComparator()
-
afterObjectLoad
public void afterObjectLoad(@NotNull T loadedObject)
-
writeLock
@NotNull protected Lock writeLock()
-
find
@Nullable public T find(@NotNull K id)
- Specified by:
find
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
findAll
@NotNull public <C extends Collection<? super T>> C findAll(@NotNull C result, @NotNull Collection<K> ids)
- Specified by:
findAll
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
containsKey
public boolean containsKey(K key)
- Specified by:
containsKey
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
getSorted
@NotNull public List<T> getSorted()
- Specified by:
getSorted
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
getAll
@NotNull public Collection<T> getAll()
- Specified by:
getAll
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
getSorted
@NotNull public <C extends List<? super T>> C getSorted(@NotNull C result, @NotNull Filter<? super T> filter)
- Specified by:
getSorted
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
getKeys
@NotNull public Set<K> getKeys()
- Specified by:
getKeys
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
- Returns:
- key set copy
- Since:
- 7.0
-
size
public int size()
- Specified by:
size
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
addListener
public void addListener(@NotNull IndexedCollection.CollectionListener<K,T> collectionListener)
-
addFirstListener
public void addFirstListener(@NotNull IndexedCollection.CollectionListener<K,T> collectionListener)
-
clear
public void clear()
-
resort
public void resort()
-
getChangesNumber
public int getChangesNumber()
- Specified by:
getChangesNumber
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
processItems
public void processItems(@NotNull Collection<K> ids, @NotNull ItemProcessor<T> itemProcessor)
- Specified by:
processItems
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
processItems
public void processItems(@NotNull ItemProcessor<T> itemProcessor)
- Specified by:
processItems
in interfaceReadOnlyIndexedCollection<K,T extends Comparable>
-
-