-
Notifications
You must be signed in to change notification settings - Fork 9
fix: fix ArrayStoreException #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
""" WalkthroughThis change refactors the way grid header and footer information is represented and propagated throughout the grid exporter codebase. It introduces new classes Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java (1)
104-121
: Well-implemented getGridHeader helper method.This new method effectively collects all header texts for a given column from all header rows and encapsulates them with the column in a
GridHeader
instance. The implementation preserves all the previous functionality while providing a cleaner abstraction.One minor issue: on line 120, the raw type
new GridHeader(headerTexts, column)
is used without the type parameter. This could be improved for better type safety.- return new GridHeader(headerTexts, column); + return new GridHeader<T>(headerTexts, column);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java
(2 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java
(1 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java
(1 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java
(3 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java
(1 hunks)
🔇 Additional comments (9)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java (1)
1-15
: Good encapsulation of grid header data.The new
GridHeader<T>
class provides a well-structured representation of grid headers, replacing the previous use ofPair<List<String>, Column<T>>
. The use of Lombok annotations for generating boilerplate code keeps the class concise while providing all necessary functionality.src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java (1)
64-64
: Updated to use the new GridHeader abstraction.The code now correctly uses
GridHeader::getHeaderTexts
instead of accessing the left element of pairs, aligning with the refactored return type ofgetGridHeaders
.src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java (1)
131-134
: Properly maps GridHeader to the expected Pair format.The mapping has been updated to extract the header text and column from the new
GridHeader
class rather than using pairs directly. The use ofheader.getHeaderTexts().get(0)
assumes that only the first header text is relevant for this context, which matches the previous behavior.src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java (1)
98-102
: Successfully refactored getGridHeaders to return GridHeader objects.The method now returns a list of
GridHeader<T>
objects, mapping each column through the newgetGridHeader
helper method. This provides a more type-safe and semantically clear approach compared to using pairs.src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java (5)
98-98
: LGTM - Method signature refactoring aligns with the new abstractionThe change from receiving Pair objects to GridHeader objects improves code clarity and maintainability. This is consistent with the overall refactor described in the PR.
349-349
: Consistent code style improvementAdded appropriate spacing between
if
and the opening parenthesis.
427-431
: Good adapter implementationThe conversion from legacy Pair objects to the new GridHeader abstraction is well implemented. The stream operation creates single-element header lists, maintaining backwards compatibility while moving to the new data structure.
434-434
: Method signature update aligns with the new abstractionChanging the parameter type from the previous List<Pair<...>> to List<GridHeader> improves the method's type safety and readability.
440-442
: Clean migration to accessor methodsThe code now properly uses GridHeader's getter methods instead of pair accessors, making the intent clearer and improving readability.
4b4a9ed
to
e1265ca
Compare
e1265ca
to
05be7e6
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java (1)
16-18
: Consider adding null/empty list check.The
getText()
method assumes thattexts
is never null and contains at least one element. Consider adding a defensive check to prevent potentialNullPointerException
orIndexOutOfBoundsException
.@Override public String getText() { - return texts.get(0); + return texts != null && !texts.isEmpty() ? texts.get(0) : ""; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java
(2 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java
(1 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java
(5 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java
(4 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridFooter.java
(1 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java
(1 hunks)src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeaderOrFooter.java
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeaderOrFooter.java
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridFooter.java
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java (1)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridFooter.java (1)
Getter
(8-20)
🔇 Additional comments (5)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java (1)
8-20
: Implementation aligns well with GridFooter class.The implementation is clean and maintains consistency with the parallel
GridFooter
class. Both implement the commonGridHeaderOrFooter<T>
interface while handling their data slightly differently - headers can have multiple texts while footers have a single text.src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java (4)
130-131
: Type refactoring looks good.The change from using generic Pair objects to domain-specific
GridHeader<T>
types improves type safety and code clarity.
140-143
: Type refactoring looks good.The change from using generic Pair objects to domain-specific
GridFooter<T>
types improves type safety and code clarity, consistent with the header implementation.
271-276
: Good use of polymorphism.Updating the method signature to accept
List<? extends GridHeaderOrFooter<T>>
is a good use of polymorphism that allows the same method to handle both headers and footers, reducing code duplication.
286-302
: Method call changes are consistent.The changes from presumed
Pair
methods to the new interface methods (header.getText()
andheader.getColumn().getTextAlign()
) are consistently applied throughout the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Close #155 and fix #170
Summary by CodeRabbit