Fix to pass mutable list into postRecordActions

This commit is contained in:
2022-08-23 09:57:06 -05:00
parent 3410c76c81
commit b9d498b57e
2 changed files with 21 additions and 5 deletions

View File

@ -45,17 +45,28 @@ public class RecordPipe
private Consumer<List<QRecord>> postRecordActions = null;
/////////////////////////////////////
// See usage below for explanation //
/////////////////////////////////////
private List<QRecord> singleRecordListForPostRecordActions = new ArrayList<>();
/*******************************************************************************
** Add a record to the pipe
** Returns true iff the record fit in the pipe; false if the pipe is currently full.
** Add a record to the pipe. Will block if the pipe is full.
*******************************************************************************/
public void addRecord(QRecord record)
{
if(postRecordActions != null)
{
postRecordActions.accept(List.of(record));
////////////////////////////////////////////////////////////////////////////////////
// the initial use-case of this method is to call QueryAction.postRecordActions //
// that method requires that the list param be modifiable. Originally we used //
// List.of here - but that is immutable, so, instead use this single-record-list //
// (which we'll create as a field in this class, to avoid always re-constructing) //
////////////////////////////////////////////////////////////////////////////////////
singleRecordListForPostRecordActions.add(record);
postRecordActions.accept(singleRecordListForPostRecordActions);
record = singleRecordListForPostRecordActions.remove(0);
}
doAddRecord(record);

View File

@ -84,11 +84,16 @@ public class QueryAction
/*******************************************************************************
**
** Run the necessary actions on a list of records (which must be a mutable list - e.g.,
** not one created via List.of()). This may include setting display values,
** translating possible values, and running post-record customizations.
*******************************************************************************/
public void postRecordActions(List<QRecord> records)
{
this.postQueryRecordCustomizer.ifPresent(qRecordQRecordFunction -> records.replaceAll(qRecordQRecordFunction::apply));
if(this.postQueryRecordCustomizer.isPresent())
{
records.replaceAll(t -> postQueryRecordCustomizer.get().apply(t));
}
if(queryInput.getShouldGenerateDisplayValues())
{