Commit 96efa14
refactor: Improve Value.objectToValue() consistency and remove unnecessary exception handling
## Value.objectToValue() Enhancement
- Add support for Long and Float types in objectToValue() method
- Long and Float now use generic Value(Object) constructor with proper exception handling
- Maintains same exception handling approach as other numeric types
## ImmutableMetadata Builder Consistency
- Remove unnecessary try-catch blocks from addLong() and addFloat() methods
- Both methods now use Value.objectToValue() consistently with other add methods
- Eliminates redundant exception wrapping that was inconsistent with addInteger/addDouble
- All builder methods now follow the same pattern
## Technical Details
- Long and Float are Number subtypes, so Value(Object) constructor accepts them
- The isNumber() check validates them as valid numeric types
- No functional changes - same behavior with cleaner, consistent code
## Results
- All 319 tests passing ✅
- Consistent exception handling across all ImmutableMetadata add methods
- Cleaner code without unnecessary try-catch blocks
- Better API consistency for developers
This resolves the inconsistency where some builder methods used try-catch
blocks while others used Value.objectToValue() directly.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent cc73673 commit 96efa14
File tree
2 files changed
+14
-10
lines changed- openfeature-api/src/main/java/dev/openfeature/api
2 files changed
+14
-10
lines changedLines changed: 2 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
| 224 | + | |
229 | 225 | | |
230 | 226 | | |
231 | 227 | | |
| |||
236 | 232 | | |
237 | 233 | | |
238 | 234 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
| 235 | + | |
244 | 236 | | |
245 | 237 | | |
246 | 238 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
326 | 338 | | |
327 | 339 | | |
328 | 340 | | |
| |||
0 commit comments