Skip to content

Commit be62df7

Browse files
committed
Merged DefaultBindable into ParameterBuilder
1 parent e5169e0 commit be62df7

2 files changed

Lines changed: 22 additions & 64 deletions

File tree

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

Lines changed: 0 additions & 55 deletions
This file was deleted.

‎api/src/main/java/org/ocpsoft/rewrite/param/ParameterBuilder.java‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
import java.util.ArrayList;
1919
import java.util.List;
2020

21+
import org.ocpsoft.rewrite.bind.Bindable;
2122
import org.ocpsoft.rewrite.bind.Binding;
2223
import org.ocpsoft.rewrite.bind.Converter;
23-
import org.ocpsoft.rewrite.bind.DefaultBindable;
2424
import org.ocpsoft.rewrite.bind.Validator;
2525
import org.ocpsoft.rewrite.context.EvaluationContext;
2626
import org.ocpsoft.rewrite.event.Rewrite;
@@ -31,9 +31,10 @@
3131
*
3232
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
3333
*/
34-
public abstract class ParameterBuilder<IMPLTYPE extends ParameterBuilder<IMPLTYPE>> extends DefaultBindable<IMPLTYPE>
35-
implements Parameter<IMPLTYPE>
34+
public abstract class ParameterBuilder<IMPLTYPE extends ParameterBuilder<IMPLTYPE>>
35+
implements Parameter<IMPLTYPE>, Bindable<IMPLTYPE>
3636
{
37+
private final List<Binding> bindings = new ArrayList<Binding>();
3738
private final List<Transform<String>> transforms = new ArrayList<Transform<String>>();
3839
private final List<Constraint<String>> constraints = new ArrayList<Constraint<String>>();
3940
private Converter<?> converter = null;
@@ -48,6 +49,24 @@ protected ParameterBuilder(String name)
4849
this.name = name;
4950
}
5051

52+
53+
@Override
54+
@SuppressWarnings("unchecked")
55+
public IMPLTYPE bindsTo(final Binding binding)
56+
{
57+
/*
58+
* Bindings must be added to the front of the list, since we want the
59+
* ability to override the default binding if necessary.
60+
*/
61+
this.bindings.add(0, binding);
62+
return (IMPLTYPE) this;
63+
}
64+
65+
@Override
66+
public List<Binding> getBindings()
67+
{
68+
return bindings;
69+
}
5170
@Override
5271
public String getName()
5372
{
@@ -66,12 +85,6 @@ public boolean validate(Rewrite event, EvaluationContext context, Object value)
6685
return ValueHolderUtil.validates(event, context, validator, value);
6786
}
6887

69-
@Override
70-
public IMPLTYPE bindsTo(Binding binding)
71-
{
72-
return super.bindsTo(binding);
73-
}
74-
7588
@Override
7689
@SuppressWarnings("unchecked")
7790
public IMPLTYPE convertedBy(Converter<?> converter)

0 commit comments

Comments
 (0)