Commit 42ce0f5
Implement comprehensive targeted type-safe improvements across metadata framework
PHASE 2: Add type-safe alternatives alongside existing methods to eliminate unsafe casting
## Core Improvements:
### MetaData.java (+29 lines)
- Add getSuperDataSafe() with Optional return and type checking
- Add addMetaAttrSafe() returning concrete MetaData type
- Add addChildSafe() returning concrete MetaData type
- Maintains backward compatibility while providing type-safe alternatives
### ValidationChain.java (+19 lines)
- Add type-hinted builder() methods with Class<T> parameter
- Enable cleaner type inference: builder(MetaData.class)
- Reduces need for explicit type parameters
### IndexedMetaDataCollection.java (+14 lines)
- Add findByClassSafe() with stream-based filtering and casting
- Eliminates unsafe List<MetaData> to List<T> cast
- Guarantees returned items match specified type
### MetaField.java (+10 lines)
- Add addMetaViewSafe() returning concrete MetaField<T> type
- Eliminates generic T cast in fluent interface
## Benefits Achieved:
✅ Eliminate ClassCastException risks in collection operations
✅ Improve IDE IntelliSense and compile-time type checking
✅ Provide Optional-based APIs for safer null handling
✅ Maintain 100% backward compatibility
✅ All 72 lines of improvements compile and test successfully
No breaking changes - existing code continues to work unchanged while new type-safe alternatives are available for adoption.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 0278a2b commit 42ce0f5
4 files changed
Lines changed: 72 additions & 0 deletions
File tree
- metadata/src/main/java/com/draagon/meta
- collections
- field
- validation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
523 | 532 | | |
524 | 533 | | |
525 | 534 | | |
| |||
540 | 549 | | |
541 | 550 | | |
542 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
543 | 562 | | |
544 | 563 | | |
545 | 564 | | |
| |||
652 | 671 | | |
653 | 672 | | |
654 | 673 | | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
655 | 684 | | |
656 | 685 | | |
657 | 686 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
165 | 179 | | |
166 | 180 | | |
167 | 181 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
437 | 447 | | |
438 | 448 | | |
439 | 449 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
209 | 228 | | |
210 | 229 | | |
211 | 230 | | |
| |||
0 commit comments