Hi,
You could use a default value after each property, something like this:
(label="Just some Property")
String myProperty() default "someValue";
But it looks like you are more interested in validation, which is not possible using the out of the box with CA properties, you don't have such options (required, non-null, unique) for a property, check here: https://sling.apache.org/apidocs/sling9/org/apache/sling/caconfig/annotation/Property.html.
Another alternative is to keep the key/value pair in the same property, separated by a special character. While this approach can make the property harder to read, it allows you to avoid the dependency between prop1
and prop2
. For example:
(label="Just some Property")
String myKeyAndValue() default "key1:value1;key2:value2";
Although I understand your concern, please keep in mind that these configurations will be managed by a developer or someone with the expertise to set them correctly, not by an author. As long as you stay within this realm, you should be safe and not have to worry too much about it. Please check this thread for more information: https://cqdump.joerghoh.de/2018/04/23/content-and-configuration/
Hope this helps
Esteban Bustamante