Skip to content

Enum: RoundingMode Key-Value Pairs Not Identical #2169

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

Closed
boghyon opened this issue Aug 17, 2018 · 2 comments
Closed

Enum: RoundingMode Key-Value Pairs Not Identical #2169

boghyon opened this issue Aug 17, 2018 · 2 comments

Comments

@boghyon
Copy link
Contributor

boghyon commented Aug 17, 2018

Currently, the RoundingMode key-value pairs are not identical to each other.

* @enum {string}
* @alias sap.ui.core.format.NumberFormat.RoundingMode
*/
var mRoundingMode = {
/**
* Rounding mode to round towards negative infinity
* @public
*/
FLOOR: "floor",
/**
* Rounding mode to round towards positive infinity
* @public
*/
CEILING: "ceiling",
/**
* Rounding mode to round towards zero
* @public
*/
TOWARDS_ZERO: "towards_zero",
/**
* Rounding mode to round away from zero
* @public
*/
AWAY_FROM_ZERO: "away_from_zero",
/**
* Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case round towards negative infinity.
* @public
*/
HALF_FLOOR: "half_floor",
/**
* Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case round towards positive infinity.
* @public
*/
HALF_CEILING: "half_ceiling",
/**
* Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case round towards zero.
* @public
*/
HALF_TOWARDS_ZERO: "half_towards_zero",
/**
* Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case round away from zero.
* @public
*/
HALF_AWAY_FROM_ZERO: "half_away_from_zero"
};

Why is this a problem?

Besides the doc saying to do so; when assigning enum values declaratively e.g. in XML or manifest.json, the actual values must be passed ("floor") instead of key names ("FLOOR").

  1. Usually in JS, we can get the real values via sap.ui.define / .require. We can't require and assign enums declaratively in XML or JSON.
  2. There is currently no way to discover the actual enum values without inspecting the source code since only keys are visible in API reference.

To make things worse; since the plain object that holds the roundingMode property is typically not derived from ManagedObject (e.g. the formatOptions object), there is no type validation either, unlike in #2166.

@GerganaKremenska
Copy link
Member

Hello @boghyon ,
Thank you for sharing this finding. I've created an internal incident 1870335948. The status of the issue will be updated here in GitHub.
Regards,
Gergana

@stopcoder
Copy link
Member

Hi @boghyon,

we finally made a fix and it's merged to the master branch a moment ago. We decided not to downport the fix. If you need this fix in the released branch as well, please reopen the ticket with the version info. We will then consider downporting the change.

Best regards,
Jiawei

@boghyon boghyon changed the title RoundingMode Key-Value Pairs Not Identical Enum: RoundingMode Key-Value Pairs Not Identical Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants