Skip to content

Commit

Permalink
fix #900 Add the ability to insert/remove records from LocalListDataS…
Browse files Browse the repository at this point in the history
…tore by index
  • Loading branch information
vegegoku committed Jan 14, 2024
1 parent dd159da commit 56599e0
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,19 @@ public void addRecord(T record) {
setData(newData);
}

/**
* Inserts a single record to the data store at the specified index, updating both the original
* and filtered lists.
*
* @param index The insertion index.
* @param record The record to be added.
*/
public void insertRecord(int index, T record) {
original.add(index, record);
List<T> newData = new ArrayList<>(original);
setData(newData);
}

/**
* Removes a single record from the data store, updating both the original and filtered lists.
*
Expand All @@ -566,6 +579,16 @@ public void removeRecord(T record) {
}
}

/**
* Removes a single record from the data store from the specified index, updating both the
* original and filtered lists.
*
* @param index The index of the record to be removed
*/
public void removeRecord(int index) {
removeRecord(original.get(index));
}

/**
* Updates a single record in the data store by replacing it with a new record, updating both the
* original and filtered lists.
Expand Down

0 comments on commit 56599e0

Please sign in to comment.