Skip to content

Handling Collection properties where getter returns unmodifiable collection #106

Open
@jonl-percsolutions-com

Description

@jonl-percsolutions-com

In DefaultResultSetHandler.instantiateCollectionPropertyIfAppropriate, of the propertyValue return is an instanceof an Unmodifiable collection, then a new collection should be called to be passed to the setter method, if it exists, instead of attempting to add objects to the unmodifiable collection.

OR

You should only use the collection returned by the getter in the case where a setter does not exist.

The reason for this is, the getter could return an unmodifiable collection, as in my case, or a collection that is not linked directly to the collection maintained by the owning object.

Ignoring the setter, when it exists, is ignoring the object design and Java Bean standard,breaking encapsulation, imo.

If an object doesn't have a "setter" you could also look for an addPropertyName method. Which would support allowing an object to manage it's own underlying collection.

My work around, currently, is to use a reference to the underlying backing collection to the property instead of the property name. However, I would like to be able to use a custom setter or adder instead of returning a direct reference to the underlying collection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprove a feature or add a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions