There are 2 comments.
 
 
XWiki Commons / cid:jira-generated-image-avatar-4187f009-917d-4b40-b46b-3bb9a0e632d8 XCOMMONS-2738 Open

Introduce the notion of mandatory property feature

 
View issue   ยท   Add comment
 

2 comments

 
cid:jira-generated-image-avatar-ea6f7965-f16e-4109-afa0-fc9373062e51 Charpentier Lucas on 27/Feb/25 18:05
 
From what I understand, the features are just arbitrary String values.
Groups have an actual PropertyGroupDescriptor that can handle its own metadata.

AFAIU, a `mandatory property group` would make more sense to implement.

As a bonus, all property groups are associated to 0 or 1 feature.
 
cid:jira-generated-image-avatar-ea6f7965-f16e-4109-afa0-fc9373062e51 Charpentier Lucas on 27/Feb/25 18:12
 

In order to implement this functionality, we need to update the `populateBean` method of the DefaultBeanManager.
We'll probably need a new Exception type along the lines of "None of the properties for the feature has been set."

My idea on how to implement it:

  • First we iterate on properties as usual. Do everything regularly but keep traces of the features for Properties that have the `MandatoryFeature` tag.
  • Iterate on all mandatoryfeatures. For each mandatory feature, we retrieve all the properties that implement this feature, and we check if at least one is set (in most cases, it would also make sense to avoid having more than one implementation at a time for a feature). If none (or more than one) property has a value for this feature, throw a `FeatureMandatoryException`.

I'm not sure I understand everything here, but it looks like a complete solution to me.

Note that implementing things this way would mean that the feature needs only one property tagged with `MandatoryFeature` to be mandatory. IMO it's more lenient than needing a `MandatoryFeature` on all properties using it.