open-feature/java-sdk

Why the SDK does not provide a way to fetch Long value?

Opened this issue · 3 comments

I see we have getDoubleValue and getIntegerValue, but not for Long type.
I can open a PR to add that.

@apulbere thank you for raising your concern.

From your description, I assume you are referring to the feature flag evaluation contract [1]. I am not sure about the historical reason for ignoring the Long type. However, it could be a valuable addition for providers.

From the spec point of view, we only enforce number evaluation [2]. When it comes to implementation, this translates into language-specific representations.

Maybe we could aim for a generic representation of numbers via Java Number [3] type evaluation instead of supporting each sub-type of Number such as Long and Short 🤔

cc - @toddbaert @justinabrahms appreciate opnion here

[1] - https://github.com/open-feature/java-sdk/blob/main/src/main/java/dev/openfeature/sdk/FeatureProvider.java#L16-L24
[2] - https://github.com/open-feature/spec/blob/main/specification/sections/01-flag-evaluation.md#13-flag-evaluation
[3] - https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html

I'd support something around Number. I don't think I knew about it at the time.

I think Number makes sense.

If we add it though, what do we do with providers that don't specifically implement this? Or would we even expect them to? Might we instead just call resolveDoublevalue on the provider and use that value to create a Number?

I'm not sure...