package uk.gov.register.db;

import uk.gov.register.core.Entry;
import uk.gov.register.core.Record;
import uk.gov.register.store.BackingStoreDriver;

import java.util.*;
import java.util.stream.Collectors;

public class RecordIndex {
    private final BackingStoreDriver backingStoreDriver;

    public RecordIndex(BackingStoreDriver backingStoreDriver) {
        this.backingStoreDriver = backingStoreDriver;
    }

    public void updateRecordIndex(String registerName, Record record) {
        backingStoreDriver.insertRecord(record, registerName);
    }

    public Optional<Record> getRecord(String key) {
        return backingStoreDriver.getRecord(key);
    }

    public int getTotalRecords() {
        return backingStoreDriver.getTotalRecords();
    }

    public List<Record> getRecords(int limit, int offset) {
        return backingStoreDriver.getRecords(limit, offset);
    }

    public List<Record> findMax100RecordsByKeyValue(String key, String value) {
        return backingStoreDriver.findMax100RecordsByKeyValue(key, value);
    }

    public Collection<Entry> findAllEntriesOfRecordBy(String registerName, String key) {
        return backingStoreDriver.findAllEntriesOfRecordBy(registerName, key);
    }

    private List<CurrentKey> extractCurrentKeys(String registerName, List<Record> records) {
        Map<String, Integer> currentKeys = new HashMap<>();
        records.forEach(r -> currentKeys.put(r.item.getKey(registerName), r.entry.getEntryNumber()));
        return currentKeys
                .entrySet()
                .stream()
                .map(e -> new CurrentKey(e.getKey(), e.getValue()))
                .collect(Collectors.toList());
    }
}

@@ -166,44 +166,8 @@
 l.*;
-%0Aimport java.util.stream.Collectors;
 %0A%0Apu
@@ -1187,465 +1187,7 @@
    %7D
-%0A%0A    private List%3CCurrentKey%3E extractCurrentKeys(String registerName, List%3CRecord%3E records) %7B%0A        Map%3CString, Integer%3E currentKeys = new HashMap%3C%3E();%0A        records.forEach(r -%3E currentKeys.put(r.item.getKey(registerName), r.entry.getEntryNumber()));%0A        return currentKeys%0A                .entrySet()%0A                .stream()%0A                .map(e -%3E new CurrentKey(e.getKey(), e.getValue()))%0A                .collect(Collectors.toList());%0A    %7D
 %0A%7D%0A

Remove unused code