Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make generics more correct

  • Loading branch information...
commit 3a3f78d62605e50546a9760b901887304941ca03 1 parent 84de08d
@jodastephen jodastephen authored
View
4 src/main/java/org/joda/beans/BeanBuilder.java
@@ -51,7 +51,7 @@
* @return {@code this}, for chaining, not null
* @throws RuntimeException optionally thrown if the property name is invalid
*/
- BeanBuilder<T> set(MetaProperty<Object> property, Object value);
+ BeanBuilder<T> set(MetaProperty<?> property, Object value);
/**
* Sets the value of a single property into the builder.
@@ -83,7 +83,7 @@
* @return {@code this}, for chaining, not null
* @throws RuntimeException optionally thrown if the property name is invalid
*/
- BeanBuilder<T> setString(MetaProperty<Object> property, String value);
+ BeanBuilder<T> setString(MetaProperty<?> property, String value);
/**
* Sets the value of a map of properties into the builder.
View
4 src/main/java/org/joda/beans/impl/BasicBeanBuilder.java
@@ -77,7 +77,7 @@ protected T getTargetBean() {
}
@Override
- public BeanBuilder<T> set(MetaProperty<Object> property, Object value) {
+ public BeanBuilder<T> set(MetaProperty<?> property, Object value) {
property.set(bean, value);
return this;
}
@@ -88,7 +88,7 @@ protected T getTargetBean() {
}
@Override
- public BeanBuilder<T> setString(MetaProperty<Object> property, String value) {
+ public BeanBuilder<T> setString(MetaProperty<?> property, String value) {
property.setString(bean, value);
return this;
}
View
15 src/test/java/org/joda/beans/TestAddress.java
@@ -66,7 +66,7 @@ public void test_bean_invalidPropertyName() {
}
}
- public void test_bean_builder() {
+ public void test_bean_builder1() {
BeanBuilder<? extends Address> builder = Address.meta().builder();
builder.set("street", "Main Street");
Map<String, Object> map = new HashMap<String, Object>();
@@ -81,6 +81,19 @@ public void test_bean_builder() {
assertEquals(test, expected);
}
+ public void test_bean_builder2() {
+ BeanBuilder<? extends Address> builder = Address.meta().builder();
+ builder.set(Address.meta().street(), "Main Street");
+ builder.setString(Address.meta().number(), "12");
+
+ Address test = builder.build();
+ Address expected = new Address();
+ expected.setStreet("Main Street");
+ expected.setNumber(12);
+
+ assertEquals(test, expected);
+ }
+
//-----------------------------------------------------------------------
public void test_metaBean() {
MetaBean test = Address.meta();
Please sign in to comment.
Something went wrong with that request. Please try again.