On 2009-12-28 08.10, Niclas Hedhman wrote:
Quite often I come into the situation of the following code in
ConfigurationComposites;

@Optional
Property<String>  something();


String something = conf.configuration().something().get();
if( something == null )
{
     something = "some default";
     conf.configuration().something().set( something );
}


And it just struck me; Why is that? Why can't this be handled behind
the scenes gracefully by Qi4j Runtime?

It already is, in two ways. First, you can set these defaults by using properties files, which is probably the best way for most cases. You can alternatively set them in assemblies, in which case it is easier to set non-primitive values.

In any case the default value has little to do with the property being optional or not. If anything it would make more sense to put it in the @UseDefaults annotation. But I'd prefer if any of the two above variants are used.

Would that work for you? Is there any reason you don't want to use any of the above?

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to