ConfigMe icon indicating copy to clipboard operation
ConfigMe copied to clipboard

Allow Property impl to transform value before setting

Open ljacqu opened this issue 2 years ago • 0 comments

A property like LowercaseStringSetProperty or any other property type where not every value of the Java type is considered valid, proper validation/transformation happens when values are loaded from the resource, but if a property's value is programmatically set later on, no such validation occurs. While there is Property#isValidValue and it gets called when a value is set, this makes the SettingsManager throw an exception if it's false.

Ideally, values are valid when the application sets them for a property, but it might make sense to promote the idea that properties manage their values a bit more by maybe allowing the property to slightly transform the value (or throw if the value is unusable) also when a property's value is set by the application.

Examples:

  • A set with upper-case text is set for a LowercaseStringSetProperty
  • A collection is provided for any collection property where one of the entries is null (I believe nothing checks this at all at the moment)
  • InlineArrayProperty does not escape the chosen delimiter in the value -> would need to be done by the developer himself

ljacqu avatar Aug 20 '23 14:08 ljacqu