Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » @Preference - check if value exists
@Preference - check if value exists [message #1737327] Thu, 07 July 2016 10:47 Go to next message
Kai Pervoelz is currently offline Kai PervoelzFriend
Messages: 14
Registered: August 2015
Junior Member
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 11:21 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
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 11:28 Go to previous messageGo to next message
Kai Pervoelz is currently offline Kai PervoelzFriend
Messages: 14
Registered: August 2015
Junior Member
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 11:49 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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 12:00 Go to previous messageGo to next message
Kai Pervoelz is currently offline Kai PervoelzFriend
Messages: 14
Registered: August 2015
Junior Member
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 10:07 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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: Sat Apr 20 04:24:17 GMT 2024

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

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

Back to the top