Skip to main content



      Home
Home » Eclipse Projects » e(fx)clipse » @Preference - check if value exists
@Preference - check if value exists [message #1737327] Thu, 07 July 2016 06:47 Go to next message
Eclipse UserFriend
Hey,

I just started using the (efxclipse) @Preference annotation to handle preferences in my application. I am wondering how to figure out if there is a value in the preference store for a specific key.

For example:
@Inject
@Preference(key = "myKey")
double value;

As long as I don't publish any own value for this key, the DI will give a 0.0 value. How can I distinguish this from a real stored 0.0.

My problem is, that I want to publish some initial values but only if there is no value stored already. Any suggestions how I can figure out if there is a value stored for a specific key?


Kai
Re: @Preference - check if value exists [message #1737335 is a reply to message #1737327] Thu, 07 July 2016 07:21 Go to previous messageGo to next message
Eclipse UserFriend
Maybe you can use the object "Double" instead of the primitive value "double"?

@Inject
@Preference(key = "myKey")
Double value;
Re: @Preference - check if value exists [message #1737338 is a reply to message #1737335] Thu, 07 July 2016 07:28 Go to previous messageGo to next message
Eclipse UserFriend
no, same result. I tried
Double value
double value
Value<Double> value

No difference.
Re: @Preference - check if value exists [message #1737343 is a reply to message #1737327] Thu, 07 July 2016 07:49 Go to previous messageGo to next message
Eclipse UserFriend
Ok can you file a bug for the Double case - I think we need to modify
the PreferenceValueSupplier for that case.

A work around would be to provide a default value like -1 to find out if
the value is not coming from the preference store.

Tom

On 07.07.16 12:47, Kai Pervoelz wrote:
> Hey,
>
> I just started using the (efxclipse) @Preference annotation to handle
> preferences in my application. I am wondering how to figure out if there
> is a value in the preference store for a specific key.
> For example:
> @Inject
> @Preference(key = "myKey")
> double value;
>
> As long as I don't publish any own value for this key, the DI will give
> a 0.0 value. How can I distinguish this from a real stored 0.0.
> My problem is, that I want to publish some initial values but only if
> there is no value stored already. Any suggestions how I can figure out
> if there is a value stored for a specific key?
>
> Kai
Re: @Preference - check if value exists [message #1737344 is a reply to message #1737343] Thu, 07 July 2016 08:00 Go to previous messageGo to next message
Eclipse UserFriend
okay, thanx. The -1 workaround is what I am doing right now but it would be nice to really know if the value exists already in the prefs.

What do you think about adding this information to the Value<T> type, too? As far as I understand I need the Value<T> type to publish the preference to the context, right? So it would be great to only deal with the 'Value' instead of checking the 'Double' first for null and then using the 'Value' for publishing an initial value to the context.


Kai
Re: @Preference - check if value exists [message #1737729 is a reply to message #1737344] Tue, 12 July 2016 06:07 Go to previous message
Eclipse UserFriend
Not sure I can follow your proposal. Can you rephrase or even provide an
example?

Tom

On 07.07.16 14:00, Kai Pervoelz wrote:
> okay, thanx. The -1 workaround is what I am doing right now but it would
> be nice to really know if the value exists already in the prefs.
> What do you think about adding this information to the Value<T> type,
> too? As far as I understand I need the Value<T> type to publish the
> preference to the context, right? So it would be great to only deal with
> the 'Value' instead of checking the 'Double' first for null and then
> using the 'Value' for publishing an initial value to the context.
>
>
> Kai
Previous Topic:Eclipse Neon 4.6.0 with E(fx)clipse 2.4.0 not working
Next Topic:How to create and run JUnit tests on FX plugins?
Goto Forum:
  


Current Time: Fri Jul 04 02:50:55 EDT 2025

Powered by FUDForum. Page generated in 0.03919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top