Skip to content

Commit 6bc8d41

Browse files
committed
Configuration visiting now possible, Fixed generic hierarchy of Parameter/Parameterized
1 parent 4e4b461 commit 6bc8d41

65 files changed

Lines changed: 2445 additions & 1204 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎api-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/HttpCondition.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.ocpsoft.rewrite.servlet.config;
1717

18-
import org.ocpsoft.rewrite.config.ConditionBuilder;
18+
import org.ocpsoft.rewrite.config.DefaultConditionBuilder;
1919
import org.ocpsoft.rewrite.context.EvaluationContext;
2020
import org.ocpsoft.rewrite.event.Rewrite;
2121
import org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite;
@@ -25,7 +25,7 @@
2525
*
2626
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
2727
*/
28-
public abstract class HttpCondition extends ConditionBuilder
28+
public abstract class HttpCondition extends DefaultConditionBuilder
2929
{
3030
/**
3131
* Evaluate this condition against the given {@link org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite} event. If this condition does not apply to

‎api-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/HttpOperation.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.ocpsoft.rewrite.servlet.config;
1717

1818
import org.ocpsoft.rewrite.config.Operation;
19-
import org.ocpsoft.rewrite.config.OperationBuilder;
19+
import org.ocpsoft.rewrite.config.DefaultOperationBuilder;
2020
import org.ocpsoft.rewrite.context.EvaluationContext;
2121
import org.ocpsoft.rewrite.event.Rewrite;
2222
import org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite;
@@ -27,7 +27,7 @@
2727
*
2828
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
2929
*/
30-
public abstract class HttpOperation extends OperationBuilder
30+
public abstract class HttpOperation extends DefaultOperationBuilder
3131
{
3232
/**
3333
* Perform this operation for the given {@link HttpServletRewrite} event.

‎api/src/main/java/org/ocpsoft/rewrite/bind/Bindings.java‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.Map.Entry;
2323

2424
import org.ocpsoft.rewrite.config.Condition;
25-
import org.ocpsoft.rewrite.config.ConditionBuilder;
25+
import org.ocpsoft.rewrite.config.DefaultConditionBuilder;
2626
import org.ocpsoft.rewrite.config.Operation;
2727
import org.ocpsoft.rewrite.context.EvaluationContext;
2828
import org.ocpsoft.rewrite.event.Rewrite;
@@ -120,9 +120,9 @@ public static List<Object> performRetrieval(final Rewrite event, final Evaluatio
120120
* Return a new {@link Condition} which compares the expected value against the actual retrieved {@link Retrieval}
121121
* {@link Binding} value. This evaluates to true when the values are equal.
122122
*/
123-
public static ConditionBuilder equals(final Object expected, final Retrieval binding)
123+
public static DefaultConditionBuilder equals(final Object expected, final Retrieval binding)
124124
{
125-
return new ConditionBuilder() {
125+
return new DefaultConditionBuilder() {
126126
@Override
127127
public boolean evaluate(final Rewrite event, final EvaluationContext context)
128128
{
@@ -136,9 +136,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
136136
* Return a new {@link Condition} which compares the expected value against the actual retrieved {@link Submission}
137137
* {@link Binding} value. This evaluates to true when the values are equal.
138138
*/
139-
public static ConditionBuilder equals(final Object expected, final Submission binding, final Object submission)
139+
public static DefaultConditionBuilder equals(final Object expected, final Submission binding, final Object submission)
140140
{
141-
return new ConditionBuilder() {
141+
return new DefaultConditionBuilder() {
142142
@Override
143143
public boolean evaluate(final Rewrite event, final EvaluationContext context)
144144
{
@@ -152,9 +152,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
152152
* Return a new {@link Condition} which compares the value of two {@link Retrieval} {@link Binding} instances. This
153153
* evaluates to true when the values are equal.
154154
*/
155-
public static ConditionBuilder equals(final Retrieval left, final Retrieval right)
155+
public static DefaultConditionBuilder equals(final Retrieval left, final Retrieval right)
156156
{
157-
return new ConditionBuilder() {
157+
return new DefaultConditionBuilder() {
158158
@Override
159159
public boolean evaluate(final Rewrite event, final EvaluationContext context)
160160
{
@@ -167,9 +167,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
167167
* Return a new {@link Condition} which compares the values of each given {@link Retrieval} and {@link Submission}
168168
* {@link Binding} instance, respectively. This evaluates to true when the values are equal.
169169
*/
170-
public static ConditionBuilder equals(final Retrieval left, final Submission right, final Object submission)
170+
public static DefaultConditionBuilder equals(final Retrieval left, final Submission right, final Object submission)
171171
{
172-
return new ConditionBuilder() {
172+
return new DefaultConditionBuilder() {
173173
@Override
174174
public boolean evaluate(final Rewrite event, final EvaluationContext context)
175175
{
@@ -182,10 +182,10 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
182182
* Return a new {@link Condition} which compares the value of two {@link Submission} {@link Binding} instances. This
183183
* evaluates to true when the values are equal.
184184
*/
185-
public static ConditionBuilder equals(final Submission left, final Object leftSubmission, final Submission right,
185+
public static DefaultConditionBuilder equals(final Submission left, final Object leftSubmission, final Submission right,
186186
final Object rightSubmission)
187187
{
188-
return new ConditionBuilder() {
188+
return new DefaultConditionBuilder() {
189189
@Override
190190
public boolean evaluate(final Rewrite event, final EvaluationContext context)
191191
{
@@ -198,9 +198,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
198198
* Return a new {@link Condition} which compares the expected value against the actual retrieved {@link Retrieval}
199199
* {@link Binding} value. This evaluates to true when the values are not equal.
200200
*/
201-
public static ConditionBuilder notEquals(final Object expected, final Retrieval binding)
201+
public static DefaultConditionBuilder notEquals(final Object expected, final Retrieval binding)
202202
{
203-
return new ConditionBuilder() {
203+
return new DefaultConditionBuilder() {
204204
@Override
205205
public boolean evaluate(final Rewrite event, final EvaluationContext context)
206206
{
@@ -214,9 +214,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
214214
* Return a new {@link Condition} which compares the expected value against the actual retrieved {@link Submission}
215215
* {@link Binding} value. This evaluates to true when the values are not equal.
216216
*/
217-
public static ConditionBuilder notEquals(final Object expected, final Submission binding, final Object submission)
217+
public static DefaultConditionBuilder notEquals(final Object expected, final Submission binding, final Object submission)
218218
{
219-
return new ConditionBuilder() {
219+
return new DefaultConditionBuilder() {
220220
@Override
221221
public boolean evaluate(final Rewrite event, final EvaluationContext context)
222222
{
@@ -230,9 +230,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
230230
* Return a new {@link Condition} which compares the value of two {@link Retrieval} {@link Binding} instances. This
231231
* evaluates to true when the values are not equal.
232232
*/
233-
public static ConditionBuilder notEquals(final Retrieval left, final Retrieval right)
233+
public static DefaultConditionBuilder notEquals(final Retrieval left, final Retrieval right)
234234
{
235-
return new ConditionBuilder() {
235+
return new DefaultConditionBuilder() {
236236
@Override
237237
public boolean evaluate(final Rewrite event, final EvaluationContext context)
238238
{
@@ -245,9 +245,9 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
245245
* Return a new {@link Condition} which compares the values of each given {@link Retrieval} and {@link Submission}
246246
* {@link Binding} instance, respectively. This evaluates to true when the values are not equal.
247247
*/
248-
public static ConditionBuilder notEquals(final Retrieval left, final Submission right, final Object submission)
248+
public static DefaultConditionBuilder notEquals(final Retrieval left, final Submission right, final Object submission)
249249
{
250-
return new ConditionBuilder() {
250+
return new DefaultConditionBuilder() {
251251
@Override
252252
public boolean evaluate(final Rewrite event, final EvaluationContext context)
253253
{
@@ -260,10 +260,10 @@ public boolean evaluate(final Rewrite event, final EvaluationContext context)
260260
* Return a new {@link Condition} which compares the value of two {@link Submission} {@link Binding} instances. This
261261
* evaluates to true when the values are not equal.
262262
*/
263-
public static ConditionBuilder notEquals(final Submission left, final Object leftSubmission, final Submission right,
263+
public static DefaultConditionBuilder notEquals(final Submission left, final Object leftSubmission, final Submission right,
264264
final Object rightSubmission)
265265
{
266-
return new ConditionBuilder() {
266+
return new DefaultConditionBuilder() {
267267
@Override
268268
public boolean evaluate(final Rewrite event, final EvaluationContext context)
269269
{

‎api/src/main/java/org/ocpsoft/rewrite/config/And.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
2929
*/
30-
public class And extends ConditionBuilder implements CompositeCondition
30+
public class And extends DefaultConditionBuilder implements CompositeCondition
3131
{
3232
private final List<Condition> conditions;
3333

‎api/src/main/java/org/ocpsoft/rewrite/config/Condition.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/**
2222
* A condition that must be met in order for evaluation to return true. You may create custom {@link Condition}
23-
* implementations. If creating custom implementations, you should likely extend {@link ConditionBuilder}, which adds
23+
* implementations. If creating custom implementations, you should likely extend {@link DefaultConditionBuilder}, which adds
2424
* logical operators to any class extending it.
2525
*
2626
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>

‎api/src/main/java/org/ocpsoft/rewrite/config/ConditionBuilder.java‎

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,36 @@
1515
*/
1616
package org.ocpsoft.rewrite.config;
1717

18-
import org.ocpsoft.rewrite.context.EvaluationContext;
19-
import org.ocpsoft.rewrite.event.Rewrite;
20-
2118
/**
22-
* Used as a base class to create fluent relationships between {@link Condition} objects; this class adds logical
23-
* operators to any class extending it.
19+
* A {@link Condition} capable of logical operations with other {@link Condition} objects.
2420
*
2521
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
22+
*
2623
*/
27-
public abstract class ConditionBuilder implements Condition
24+
public interface ConditionBuilder extends Condition
2825
{
2926

30-
/**
31-
* Return a new {@link ConditionBuilder} that evaluates to {@link True} when
32-
* {@link #evaluate(Rewrite, EvaluationContext)} is invoked.
33-
*/
34-
public static Condition create()
35-
{
36-
return new True();
37-
}
38-
39-
/**
40-
* Wrap a given {@link Condition} as a new {@link ConditionBuilder} that evaluates the the original {@link Condition}
41-
* when {@link #evaluate(Rewrite, EvaluationContext)} is invoked.
42-
*/
43-
public static Condition wrap(Condition condition)
44-
{
45-
return And.all(condition);
46-
}
4727
/**
4828
* Append a new {@link Condition} to this builder, which must evaluate to true in order for this composite
4929
* {@link Condition} to evaluate to true.
5030
*/
51-
public ConditionBuilder and(final Condition condition)
52-
{
53-
return And.all(this, condition);
54-
}
31+
public ConditionBuilder and(final Condition condition);
5532

5633
/**
5734
* Append a new {@link Condition} to this builder, which must not evaluate to true in order for this composite
5835
* {@link Condition} to evaluate to true.
5936
*/
60-
public ConditionBuilder andNot(final Condition condition)
61-
{
62-
return And.all(this, Not.any(condition));
63-
}
37+
public ConditionBuilder andNot(final Condition condition);
6438

6539
/**
6640
* Append a new {@link Condition} to this builder. If either this or the given {@link Condition} evaluate to true,
6741
* the composite {@link Condition} will evaluate to true.
6842
*/
69-
public ConditionBuilder or(final Condition condition)
70-
{
71-
return Or.any(this, condition);
72-
}
43+
public ConditionBuilder or(final Condition condition);
7344

74-
public ConditionBuilder orNot(final Condition condition)
75-
{
76-
return Or.any(this, Not.any(condition));
77-
}
45+
/**
46+
* Append a new {@link Condition} to this builder. If either this evaluates to true or the given {@link Condition}
47+
* evaluates to false, the composite {@link Condition} will evaluate to true.
48+
*/
49+
public ConditionBuilder orNot(final Condition condition);
7850
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright 2011 <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.ocpsoft.rewrite.config;
17+
18+
import org.ocpsoft.rewrite.context.EvaluationContext;
19+
import org.ocpsoft.rewrite.event.Rewrite;
20+
21+
/**
22+
* Used as a base class to create fluent relationships between {@link Condition} objects; this class adds logical
23+
* operators to any class extending it.
24+
*
25+
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
26+
*/
27+
public abstract class DefaultConditionBuilder implements ConditionBuilder
28+
{
29+
/**
30+
* Return a new {@link DefaultConditionBuilder} that evaluates to {@link True} when
31+
* {@link #evaluate(Rewrite, EvaluationContext)} is invoked.
32+
*/
33+
public static ConditionBuilder create()
34+
{
35+
return new True();
36+
}
37+
38+
/**
39+
* Wrap a given {@link Condition} as a new {@link DefaultConditionBuilder} that evaluates the the original {@link Condition}
40+
* when {@link #evaluate(Rewrite, EvaluationContext)} is invoked.
41+
*/
42+
public static ConditionBuilder wrap(Condition condition)
43+
{
44+
if (condition == null)
45+
return create();
46+
return And.all(condition);
47+
}
48+
49+
@Override
50+
public ConditionBuilder and(final Condition condition)
51+
{
52+
if (condition == null)
53+
return this;
54+
return And.all(this, condition);
55+
}
56+
57+
@Override
58+
public ConditionBuilder andNot(final Condition condition)
59+
{
60+
if (condition == null)
61+
return this;
62+
return And.all(this, Not.any(condition));
63+
}
64+
65+
@Override
66+
public ConditionBuilder or(final Condition condition)
67+
{
68+
if (condition == null)
69+
return this;
70+
return Or.any(this, condition);
71+
}
72+
73+
@Override
74+
public ConditionBuilder orNot(final Condition condition)
75+
{
76+
if (condition == null)
77+
return this;
78+
return Or.any(this, Not.any(condition));
79+
}
80+
}

0 commit comments

Comments
 (0)