I wrote earlier about my Beany component for handling Beans (especially immutable ones) easily. I thought this time I'd just cover a few extra little features that I've added to it to make it a bit easier to use.
Beany offers a few ways to know about the data it has, other than asking for fields directly.
This will return a comma-delimited list of the keys in the current instance of Beany.
This will return all of the data in the current instance of Beany as a structure.
Will return a boolean indicating whether or not the given property exists within the current instance of Beany (can be used with any string value).
Beyond the "set" methods, Beany also has other ways to change data, if the current instance is mutable.
Firstly, you might want to remove a property altogether. Easy enough:
Another thing that I run into is that I often want to add to some existing data in a bean. For this, I have a series of "AddTo" methods.
In each case, Beany will create the property if it doesn't already exist and will add to it appropriately for the given data type.
That's it! Beany is a pretty simple little component and is part of my free com.sebtools package for ColdFusion. Let me know what you think!