|
14 | 14 | /**
|
15 | 15 | * Config Tree: A tree based representation of configurations that can be selected with a key-value map describing the selector.
|
16 | 16 | *
|
| 17 | + * <h2>Selector ↦ Configuration</h2> |
| 18 | + * |
| 19 | + * <dl> |
| 20 | + * <dt>configuration</dt> |
| 21 | + * <dd> |
17 | 22 | * A configuration is a value (Object) assigned to a selector (Map<String, Object>).
|
| 23 | + * </dd> |
| 24 | + * |
| 25 | + * <dt>selector</dt> |
| 26 | + * <dd> |
18 | 27 | * A selector is a key-value map where certain properties (String) have certain values (Object).
|
19 | 28 | * Properties of the selector are checked in a fixed order,
|
20 | 29 | * such that a tree is formed, where each property corresponds to a level (depth) in the tree.
|
21 |
| - * Each level has a special branch for DEFAULT VALUES, if the selector value does not match any value of other nodes. |
| 30 | + * </dd> |
| 31 | + * |
| 32 | + * <dt>default values</dt> |
| 33 | + * <dd> |
| 34 | + * Each level has a special branch for DEFAULT VALUES, if the given selector value does not match any value of other nodes. |
| 35 | + * </dd> |
| 36 | + * </dl> |
| 37 | + * |
| 38 | + * <h2>Selector Key Order</h2> |
| 39 | + * |
| 40 | + * The selector is matched against the configurtion list by checking the keys in a certain order. This oder does not matter if there is a unique value |
| 41 | + * for the given selector, but it may matter if default values have to be assign. See the following example. |
| 42 | + * |
| 43 | + * <h2>Example</h2> |
| 44 | + * |
| 45 | + * The configuration is determied by the value of two properties ("prop1" and "prop2") (the keys). The correspondig configuration value is |
| 46 | + * |
| 47 | + * <p></p> |
| 48 | +
|
| 49 | + * <table border="1"> |
| 50 | + * <tr><th style="text-align: center;">prop1</th><th style="text-align: center;">prop2</th><th style="text-align: center;">value</th></tr> |
| 51 | + * <tr><td style="text-align: center;">A</td><td style="text-align: center;">1</td><td style="text-align: center;">42.0</td></tr> |
| 52 | + * <tr><td style="text-align: center;">A</td><td style="text-align: center;">2</td><td style="text-align: center;">3141</td></tr> |
| 53 | + * <tr><td style="text-align: center;">B</td><td style="text-align: center;">1</td><td style="text-align: center;">1</td></tr> |
| 54 | + * <tr><td style="text-align: center;">B</td><td style="text-align: center;">2</td><td style="text-align: center;">2</td></tr> |
| 55 | + * <tr><td style="text-align: center;">A</td><td style="text-align: center;">DEFAULT_VALUE</td><td style="text-align: center;">12</td></tr> |
| 56 | + * <tr><td style="text-align: center;">DEFAULT_VALUE</td><td style="text-align: center;">2</td><td style="text-align: center;">13</td></tr> |
| 57 | + * <tr><td style="text-align: center;">DEFAULT_VALUE</td><td style="text-align: center;">DEFAULT_VALUE</td><td style="text-align: center;">66</td></tr> |
| 58 | + * <caption>The list of maps that defines all configurations.</caption> |
| 59 | + * </table> |
| 60 | + * |
| 61 | + * <p></p> |
| 62 | + * |
| 63 | + * Initialising the class with this configuration we have: |
| 64 | + * <ul> |
| 65 | + * <li> |
| 66 | + * If the class is initialized with keyOder = { "prop1" , "prop2" } |
| 67 | + * <ul> |
| 68 | + * <li>The <i>selector</i> { "prop1" = "A", "prop2" = 2 } results in the value 3141.</li> |
| 69 | + * <li>The <i>selector</i> { "prop1" = "C", "prop2" = 2 } results in the value 13 (the default branch for prop1 is selected first, under that branch value 2 for "prop2" exists).</li> |
| 70 | + * <li>The <i>selector</i> { "prop1" = "C", "prop2" = 1 } results in the value 66 (the default branch for prop1 is selected first, under that branch no value 1 for "prop2" exists).</li> |
| 71 | + * </ul> |
| 72 | + * </li> |
| 73 | + * <li> |
| 74 | + * If the class is initialized with keyOder = { "prop2" , "prop1" } |
| 75 | + * <ul> |
| 76 | + * <li>The <i>selector</i> { "prop1" = "A", "prop2" = 2 } results in the value 3141.</li> |
| 77 | + * <li>The <i>selector</i> { "prop1" = "C", "prop2" = 2 } results in the value 13 (the branch "2" for prop2 is selected first, under that branch no value C for "prop1" exists).</li> |
| 78 | + * <li>The <i>selector</i> { "prop1" = "C", "prop2" = 1 } results in an exception that no configuration is found (the branch 1 for prop2 is selected first, under that branch no value C for "prop1" exists).</li> |
| 79 | + * </ul> |
| 80 | + * </li> |
| 81 | + * </ul> |
22 | 82 | *
|
23 | 83 | * @author Christian Fries
|
24 | 84 | */
|
|
0 commit comments