Stream reuse in superclass (original) (raw)
Jose jgetino at telefonica.net
Fri Apr 5 06:48:49 PDT 2013
- Previous message: CFV: New Lambda committer: Karen Kinnear
- Next message: Stream reuse in superclass
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Maybe you could zoom out and actually tell people what problem you are trying to solve? There is almost certainly a better solution here.
OK, ill try
The base class, called PropertyTable, extends AbstractTableModel. It maintains a List of records. The fields visible in the table are defined by a list of properties of R.
A method of this class add rows (records) to the table:
public void addRows(Stream rows) { rows.forEach(records::add); fireTableDataChanged(); }
- A subclass LevelTable extends PropertyTable for a certain type Foo A LevelTable instance needs to be notified on user input changes on the individual cells of the table to ensure they satify some global relations between records. I particular it must clamp the values of some fields of a row between the values on the previous and the next row.
So, when adding new rows to the table I must also register the table as a listener to the added rows, which forces me to override the base method that consumes the stream of Foos.
This is the point I'm now. The cuurent code is below, I can't imagine any bad with it:
public void addRows(Stream rows) { rows=rows.peek(row -> row.addReceiver(this)); super.addRows(rows); }
- Previous message: CFV: New Lambda committer: Karen Kinnear
- Next message: Stream reuse in superclass
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]