Skip to content

feat: Add PojoTableModel for POJO-based row management (Issue #658) - #669

Open
TunarJamalov wants to merge 1 commit into
mabe02:masterfrom
TunarJamalov:feature/issue-658-pojo-table-model
Open

feat: Add PojoTableModel for POJO-based row management (Issue #658)#669
TunarJamalov wants to merge 1 commit into
mabe02:masterfrom
TunarJamalov:feature/issue-658-pojo-table-model

Conversation

@TunarJamalov

Copy link
Copy Markdown

Introduce PojoTableModel<R, V> extending TableModel to allow rows to be represented as Plain Old Java Objects (POJOs), following the Java Swing MVC pattern more closely.

New capabilities:

  • addRow(R pojo) — add a POJO-backed row
  • insertRow(int, R) — insert a POJO at a specific index
  • getPojoRow(int) — retrieve the backing POJO for a row
  • getPojoRows() — get all POJOs as an unmodifiable list
  • setPojoRow(int, R) — update a row's backing POJO
  • removePojoRow(R) — remove a row by its POJO reference
  • indexOfPojo(R) — find the row index of a POJO

Full backward compatibility is maintained: all existing TableModel methods continue to work as before. Legacy rows (added via the Collection/varargs API) are tracked with null placeholders so that POJO and non-POJO rows can be mixed freely.

30 new unit tests added covering all new methods, edge cases, backward compatibility and listener integration.

Fixes #658

)

Introduce PojoTableModel<R, V> extending TableModel<V> to allow rows
to be represented as Plain Old Java Objects (POJOs), following the
Java Swing MVC pattern more closely.

New capabilities:
- addRow(R pojo)         — add a POJO-backed row
- insertRow(int, R)      — insert a POJO at a specific index
- getPojoRow(int)        — retrieve the backing POJO for a row
- getPojoRows()          — get all POJOs as an unmodifiable list
- setPojoRow(int, R)     — update a row's backing POJO
- removePojoRow(R)       — remove a row by its POJO reference
- indexOfPojo(R)         — find the row index of a POJO

Full backward compatibility is maintained: all existing TableModel
methods continue to work as before. Legacy rows (added via the
Collection/varargs API) are tracked with null placeholders so that
POJO and non-POJO rows can be mixed freely.

30 new unit tests added covering all new methods, edge cases,
backward compatibility and listener integration.

Fixes mabe02#658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table/TableModel - Allow for use of Java Objects to follow Java Swing MVC pattern

1 participant