I'm working on an app where it would be useful to know the "Type" of a particular setting. I've tried object.getClass() and instanceof but the first one seems to be blocked and the second one does not recognize "bool" as datatype.
I expect (and this is me recalling uni lectures from about 20+ years ago...) the second one would fail if the setting is a raw data type, or whatever the correct term is. e.g. strings are an object with a class definition, whereas I'm pretty sure a bool is the raw data type, but Boolean is a class / object. Not sure if that helps at all.
Unfortunately this is still an open question. Using the above method on different datatypes represents by color, boolean, enum and text controls on a page.
Can you share the use case you have for this? It's possible to get the underlying object type (what you'reseeing in logs above), but I don't know of a way for the setting itself. (EDIT: Actually there is; see Bruce's post below.) There could be another approach to meet your goals if you share more that might give someone an idea.
I’m writing an app where I need to restore a group of settings, like a profile. Each group of settings has multiple colors, booleans enums and text values in them.
To work around the issue I keep a set of maps, one would contain all the color settings and then I know to use type;color when I use app.updateSettings.
It works OK but keeping internal lists is kludgy vs making a function call.
I was going to suggest using instanceOf and checking the underlying data type yourself somehow (e.g., with an if or switch) since there are only a finite number of data types a setting can be, but the above approach is probably easier and something I didn't know existed.
I do see you have at least one device in your screenshot. I want to say that there is no way to transfer the value of a selected device from one setting to another (e.g., for your capability.battery input above), but thinking about webCoRE, it looks like does this from the parent to child apps/pistons (across apps at that!), so there is probably something for that, too—but I'm not able to say how, if this even is a need for you. If the list of types you provided is exhaustive, I suppose not. The others shouldn't be an issue.