org.callbackparams.sandbox
Class Property
java.lang.Object
org.callbackparams.sandbox.Property
public class Property
- extends Object
This class has nested resources that can be used to produce callback-values
for Property.Callback
through annotations.
Example usage ...
@RunWith(CallbackParamsRunner
)
public class MyTest {
@Test
public void runTest(Property.Callback<MyBean> beanCallback) {
// ...
}
@Property.BeanClass(MyBean.class)
@Property.Name("myIntProperty")
enum MyEnum {
@Property.Value("21") FOO,
@Property.Value("67") BAR;
}
}
The annotations around and within MyEnum
are meant as a shortcut
that is equivalent with this ...
enum MyEnum implements Property.Callback<MyBean> {
FOO(21), BAR(67);
int value;
MyEnum(int value) {
this.value = value;
}
void setValues(MyBean bean) {
bean.setMyIntProperty(value);
}
void assertValues(MyBean bean) {
Assert.assertEquals("Value for property \"myIntProperty\" on " + bean,
value, bean.getMyIntProperty());
}
}
Thus, a considerable amount of (bold) boilerplate code
can be excluded by using the
annotations, as shown in the first case.
This class is meant as a proof-of-concept for the Wrapping API that can
be used to specify an implementation of a callback-interface from a
callback-value that neither implements the callback-interface nor provides
any implementation
through CallbackFactory.getCallback()
.
This class being a proof-of-concept means that it applies to a
concept that is generally understood among developers (i.e. beans and
their properties) but unlike the other sandbox utility Collector
the reusability of this class is probably more limited.
- Author:
- Henrik Kaipe
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Copyright © 2010-2013 Henrik Kaipe. All Rights Reserved.