[
http://www.stripesframework.org/jira/browse/STS-830?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ben Gunter resolved STS-830.
----------------------------
Resolution: Fixed
Fix Version/s: Release 1.5.7
Assignee: Ben Gunter
Thank you. Fixed for 1.5.7.
> Handling EnumSets in DefaultActionBeanPropertyBinder
> ----------------------------------------------------
>
> Key: STS-830
> URL: http://www.stripesframework.org/jira/browse/STS-830
> Project: Stripes
> Issue Type: Improvement
> Reporter: David Bitkowski
> Assignee: Ben Gunter
> Labels: binding
> Fix For: Release 1.5.7
>
> Attachments: DefaultActionBeanPropertyBinder.patch
>
>
> Hi guys,
> I had some problems with the DefaultActionBeanPropertyBinder binding
> correctly with an EnumSet bean. I traced it and found it was a small
> modification to DefaultActionBeanPropertyBinder. Here is the additional code
> that will allow for handling EnumSets. It is just a small modification to
> bindNonNullValue:
> @SuppressWarnings({ "unchecked", "rawtypes" })
> protected void bindNonNullValue(ActionBean bean,
> PropertyExpressionEvaluation propertyEvaluation, List<Object>
> valueOrValues,
> Class targetType, Class scalarType) throws Exception {
> Class valueType = valueOrValues.iterator().next().getClass();
> // If the target type is an array, set it as one, otherwise set as
> scalar
> if (targetType.isArray() && !valueType.isArray()) {
> Object typedArray = Array.newInstance(scalarType,
> valueOrValues.size());
> for (int i = 0; i < valueOrValues.size(); ++i) {
> Array.set(typedArray, i, valueOrValues.get(i));
> }
> propertyEvaluation.setValue(typedArray);
> }
> else if (Collection.class.isAssignableFrom(targetType)
> && !Collection.class.isAssignableFrom(valueType)) {
> Collection collection = null;
> if (targetType.isInterface()) {
> collection = (Collection)
> ReflectUtil.getInterfaceInstance(targetType);
> }
> else if(EnumSet.class.isAssignableFrom(targetType) &&
> Enum.class.isAssignableFrom(scalarType)) {
> collection = EnumSet.noneOf(scalarType.asSubclass(Enum.class));
> }
> else {
> collection = (Collection) targetType.newInstance();
> }
> collection.addAll(valueOrValues);
> propertyEvaluation.setValue(collection);
> }
> else {
> propertyEvaluation.setValue(valueOrValues.get(0));
> }
> }
> Cheers, and lovin' Stripes!
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development