Menu

#14 Collection factories should be type-specific

0.0.6
open
API (4)
5
2011-02-13
2011-02-13
No

Currently the built-in collection Factories generate collections with types that do not necessarily correspond to the specific collection type of the given property. This will work successfully if the setter merely sets the provided collection to a member field and the getter return it:

private List<Address> addresses;

public void setAddresses(List<Address> addresses) {
this.addresses = addresses;
}

public List<Address> getAddresses() {
return this.addresses;
}

However if anything more advanced is performed within either the getter or setter, such as the creation of a defensive copy, then the test will throw an exception and the developer must either register a property-specific factory or ignore the property.

Create a new dynamic generic collection factory that will create type-specific collections on the fly in a manner similar to EnumFactory. Do this by inspecting the type-specifics of either the field or the getter/setter parameters.

Discussion

  • g.williamson

    g.williamson - 2011-02-13

    We'll review the request and get back to you soon.

     
  • g.williamson

    g.williamson - 2011-02-13

    We've accepted the request and will process it.

     
  • g.williamson

    g.williamson - 2011-02-13

    We're implementing this request at present.

     
  • g.williamson

    g.williamson - 2011-02-17

    property.getWriteMethod().getGenericParameterTypes();

    BasicFactoryLookupStrategy ?

     

Log in to post a comment.