This message was deleted.
# community-support
s
This message was deleted.
v
What do you mean with "can have a null string"? If you set it to
null
, the convention value is used. If there is no convention value or you set it to
provider { null }
, the provider has no value and gives an exception if you query it for its value. (This inconsistency is topic of https://github.com/gradle/gradle/issues/14768 btw.)
j
What I mean is
Property<String>
is like Java development (at least old versions). You get the null in runtime if you don't do manual checks with
if
or whatever. I would like to have null safety to ensure a property cannot be null, currently you can
Copy code
val someProp: Property<String> = objects.property<String>().convention() // you don't set any value
And it will crash, but it shouldn't compile.
Based on that issue, what I mean is, the next snippet shouldn't compile in some situation where
null
must not be valid, only if explicitly the type is
String?
(or there is a
NullableProperty
)
Copy code
someProperty.set(null)
And
restoreConvention
is the way I would choose so in the future we can have null safety on properties
v
Setting to
null
does not set it to
null
, it sets it to the convention or to unset if there is no convention. You can chain providers, so that if it is unset a different provider is evaluated and so on. No provider can have a
null
value currently. And regarding "is like Java development", well, it is Java development. It is a Java class.