Skip to content

Conversation

@davejbur
Copy link

Further to #744 & #714, I've:

  • Renamed the object methods from ...Obj to ...Object.
  • Added an object method for optDoubleObject (returns Double vice double).
  • Added similar methods in JSONArray.
  • Added test methods.

To recap, #744 was the following:
- optBooleanObj (returns Boolean vice boolean)
- optFloatObj (returns Float vice float)
- optIntegerObj (returns Integer vice integer)
- optLongObj (returns Long vice long)
The reason for doing so is that, sometimes, I want (e.g.) optInt to return null if a value isn't found (i.e. I want to do optInt(theKey,null)). However, that gives a compiler error cannot be converted to int, since optInt needs to return an int. Hence adding an almost identical function that returns an Integer instead.

I don't know why I couldn't update the existing PR, it wouldn't let me, hence the new one containing all the above changes in one hit.

Added object method for optDoubleObject (returns Double vice double).
Added similar methods in JSONArray.
Added test methods.
@stleary
Copy link
Owner

stleary commented Jul 10, 2023

Sorry, I lost track of this PR. Will review tonight.

@stleary
Copy link
Owner

stleary commented Jul 11, 2023

What problem does this code solve?
API should allow optional wrapper class access (e.g. Double object vs double primitive)

Risks
Low

Changes to the API?
New opt* methods have been added

Will this require a new release?
No

Should the documentation be updated?
No

Does it break the unit tests?
No, unit tests were added

Was any code refactored in this commit?
No

Review status
APPROVED

Starting 3-day comment window

@stleary stleary merged commit 402db6a into stleary:master Jul 15, 2023
@davejbur davejbur deleted the add-object-methods-and-test branch July 15, 2023 06:57
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.

2 participants