|
8 | 8 | import org.ocpsoft.rewrite.bind.Converter; |
9 | 9 | import org.ocpsoft.rewrite.bind.Validatable; |
10 | 10 | import org.ocpsoft.rewrite.bind.Validator; |
| 11 | +import org.ocpsoft.rewrite.config.ConditionParameterEnricher.Enricher; |
11 | 12 | import org.ocpsoft.rewrite.param.Constrainable; |
12 | 13 | import org.ocpsoft.rewrite.param.Constraint; |
| 14 | +import org.ocpsoft.rewrite.param.Parameter; |
| 15 | +import org.ocpsoft.rewrite.param.RegexConstraint; |
13 | 16 | import org.ocpsoft.rewrite.param.Transform; |
14 | 17 | import org.ocpsoft.rewrite.param.Transformable; |
15 | 18 |
|
@@ -63,59 +66,99 @@ public List<Rule> getRules() |
63 | 66 | } |
64 | 67 |
|
65 | 68 | @Override |
66 | | - public ConfigurationRuleParameterBuilder matches(String pattern) |
| 69 | + public ConfigurationRuleParameterBuilder matches(final String pattern) |
67 | 70 | { |
68 | | - // TODO Auto-generated method stub |
69 | | - return this; |
| 71 | + return constrainedBy(new RegexConstraint(pattern)); |
70 | 72 | } |
71 | 73 |
|
72 | 74 | @Override |
73 | | - public ConfigurationRuleParameterBuilder transformedBy(Transform<String> transform) |
| 75 | + public ConfigurationRuleParameterBuilder transformedBy(final Transform<String> transform) |
74 | 76 | { |
75 | | - // TODO Auto-generated method stub |
76 | | - return null; |
| 77 | + Visitor<Condition> visitor = new ConditionParameterEnricher(parameter, new Enricher() { |
| 78 | + @Override |
| 79 | + public void enrich(Parameter<?, String> parameter) |
| 80 | + { |
| 81 | + parameter.transformedBy(transform); |
| 82 | + } |
| 83 | + }); |
| 84 | + new ConditionVisit(parent.getRuleBuilder().getCondition()).accept(visitor); |
| 85 | + return this; |
77 | 86 | } |
78 | 87 |
|
79 | 88 | @Override |
80 | | - public ConfigurationRuleParameterBuilder constrainedBy(Constraint<String> pattern) |
| 89 | + public ConfigurationRuleParameterBuilder constrainedBy(final Constraint<String> constraint) |
81 | 90 | { |
82 | | - // TODO Auto-generated method stub |
83 | | - return null; |
| 91 | + Visitor<Condition> visitor = new ConditionParameterEnricher(parameter, new Enricher() { |
| 92 | + @Override |
| 93 | + public void enrich(Parameter<?, String> parameter) |
| 94 | + { |
| 95 | + parameter.constrainedBy(constraint); |
| 96 | + } |
| 97 | + }); |
| 98 | + new ConditionVisit(parent.getRuleBuilder().getCondition()).accept(visitor); |
| 99 | + return this; |
84 | 100 | } |
85 | 101 |
|
86 | 102 | @Override |
87 | | - public <X extends Validator<?>> ConfigurationRuleParameterBuilder validatedBy(Class<X> type) |
| 103 | + public <X extends Validator<?>> ConfigurationRuleParameterBuilder validatedBy(final Class<X> type) |
88 | 104 | { |
89 | | - // TODO Auto-generated method stub |
90 | | - return null; |
| 105 | + Visitor<Condition> visitor = new ConditionParameterEnricher(parameter, new Enricher() { |
| 106 | + @Override |
| 107 | + public void enrich(Parameter<?, String> parameter) |
| 108 | + { |
| 109 | + parameter.validatedBy(type); |
| 110 | + } |
| 111 | + }); |
| 112 | + new ConditionVisit(parent.getRuleBuilder().getCondition()).accept(visitor); |
| 113 | + return this; |
91 | 114 | } |
92 | 115 |
|
93 | 116 | @Override |
94 | | - public ConfigurationRuleParameterBuilder validatedBy(Validator<?> validator) |
| 117 | + public ConfigurationRuleParameterBuilder validatedBy(final Validator<?> validator) |
95 | 118 | { |
96 | | - // TODO Auto-generated method stub |
97 | | - return null; |
| 119 | + Visitor<Condition> visitor = new ConditionParameterEnricher(parameter, new Enricher() { |
| 120 | + @Override |
| 121 | + public void enrich(Parameter<?, String> parameter) |
| 122 | + { |
| 123 | + parameter.validatedBy(validator); |
| 124 | + } |
| 125 | + }); |
| 126 | + new ConditionVisit(parent.getRuleBuilder().getCondition()).accept(visitor); |
| 127 | + return this; |
98 | 128 | } |
99 | 129 |
|
100 | 130 | @Override |
101 | | - public <X extends Converter<?>> ConfigurationRuleParameterBuilder convertedBy(Class<X> type) |
| 131 | + public <X extends Converter<?>> ConfigurationRuleParameterBuilder convertedBy(final Class<X> type) |
102 | 132 | { |
103 | | - // TODO Auto-generated method stub |
104 | | - return null; |
| 133 | + Visitor<Condition> visitor = new ConditionParameterEnricher(parameter, new Enricher() { |
| 134 | + @Override |
| 135 | + public void enrich(Parameter<?, String> parameter) |
| 136 | + { |
| 137 | + parameter.convertedBy(type); |
| 138 | + } |
| 139 | + }); |
| 140 | + new ConditionVisit(parent.getRuleBuilder().getCondition()).accept(visitor); |
| 141 | + return this; |
105 | 142 | } |
106 | 143 |
|
107 | 144 | @Override |
108 | | - public ConfigurationRuleParameterBuilder convertedBy(Converter<?> converter) |
| 145 | + public ConfigurationRuleParameterBuilder convertedBy(final Converter<?> converter) |
109 | 146 | { |
110 | | - // TODO Auto-generated method stub |
111 | | - return null; |
| 147 | + Visitor<Condition> visitor = new ConditionParameterEnricher(parameter, new Enricher() { |
| 148 | + @Override |
| 149 | + public void enrich(Parameter<?, String> parameter) |
| 150 | + { |
| 151 | + parameter.convertedBy(converter); |
| 152 | + } |
| 153 | + }); |
| 154 | + new ConditionVisit(parent.getRuleBuilder().getCondition()).accept(visitor); |
| 155 | + return this; |
112 | 156 | } |
113 | 157 |
|
114 | 158 | @Override |
115 | 159 | public ConfigurationRuleParameterBuilder bindsTo(Binding binding) |
116 | 160 | { |
117 | | - // TODO Auto-generated method stub |
118 | | - return null; |
| 161 | + return this; |
119 | 162 | } |
120 | 163 |
|
121 | 164 | } |
0 commit comments