From: <gca...@us...> - 2014-08-01 17:03:11
|
Revision: 4586 http://openutils.svn.sourceforge.net/openutils/?rev=4586&view=rev Author: gcatania Date: 2014-08-01 17:03:08 +0000 (Fri, 01 Aug 2014) Log Message: ----------- Merged revisions 4585 via svnmerge from svn+ssh://gca...@sv.../p/openutils/code/trunk/openutils-bshd5 ........ r4585 | gcatania | 2014-08-01 19:01:13 +0200 (ven, 01 ago 2014) | 1 line BSHD-25 improve error reporting in getValueFromCollection() ........ Revision Links: -------------- http://openutils.svn.sourceforge.net/openutils/?rev=4585&view=rev Modified Paths: -------------- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java Property Changed: ---------------- branches/openutils-bshd5-backport/ Index: branches/openutils-bshd5-backport =================================================================== --- branches/openutils-bshd5-backport 2014-08-01 17:01:13 UTC (rev 4585) +++ branches/openutils-bshd5-backport 2014-08-01 17:03:08 UTC (rev 4586) Property changes on: branches/openutils-bshd5-backport ___________________________________________________________________ Modified: svnmerge-integrated ## -1 +1 ## -/trunk/openutils-bshd5:1-4040,4042-4056,4058-4092,4095-4096,4098-4195,4197-4203,4383,4572-4573,4575,4577 +/trunk/openutils-bshd5:1-4040,4042-4056,4058-4092,4095-4096,4098-4195,4197-4203,4383,4572-4573,4575,4577,4585 \ No newline at end of property Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java =================================================================== --- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java 2014-08-01 17:01:13 UTC (rev 4585) +++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java 2014-08-01 17:03:08 UTC (rev 4586) @@ -310,7 +310,7 @@ Object propertyValue = classMetadata.getPropertyValue(entity, propertyName, entityMode); if (propertyType.isCollectionType()) { - propertyValue = ExampleTreeUtils.getValueFromCollection(propertyValue); + propertyValue = ExampleTreeUtils.getValueFromCollection(propertyName, propertyValue); } if (propertyValue == null) { @@ -369,7 +369,7 @@ * workaround to {@link Example} not exposing internal property selectors * @author gcatania */ -@SuppressWarnings({"serial", "static-method"}) +@SuppressWarnings({"serial", "static-method" }) class ExampleTreePropertySelectorSupport { @@ -382,6 +382,7 @@ static final class AllPropertySelector implements PropertySelector { + @Override public boolean include(Object object, String propertyName, Type type) { return true; @@ -396,6 +397,7 @@ static final class NotNullPropertySelector implements PropertySelector { + @Override public boolean include(Object object, String propertyName, Type type) { return object != null; @@ -410,6 +412,7 @@ static final class NotNullOrZeroPropertySelector implements PropertySelector { + @Override public boolean include(Object object, String propertyName, Type type) { return object != null && (!(object instanceof Number) || ((Number) object).longValue() != 0); Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java =================================================================== --- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java 2014-08-01 17:01:13 UTC (rev 4585) +++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java 2014-08-01 17:03:08 UTC (rev 4586) @@ -25,6 +25,7 @@ package it.openutils.hibernate.example; import java.lang.reflect.Array; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Collection; @@ -88,13 +89,15 @@ } /** - * retrieves a value from a collection + * retrieves a value from a collection property + * @param propertyName the property name (will be reported in the exception) * @param collectionValue the collection * @return a value * @see http://opensource2.atlassian.com/projects/hibernate/browse/HHH-879 * @throws IllegalArgumentException if the input collection contains more than one value */ - public static Object getValueFromCollection(Object collectionValue) throws IllegalArgumentException + public static Object getValueFromCollection(String propertyName, Object collectionValue) + throws IllegalArgumentException { if (collectionValue != null) { @@ -108,8 +111,10 @@ } if (size > 1) { - throw new IllegalArgumentException("More than one element in filter collection is unsupported.\n" - + coll); + throw new IllegalArgumentException(MessageFormat.format( + "More than one element in filter collection is unsupported.\nproperty: {0}, value: {1}", + propertyName, + coll)); } } Class< ? extends Object> clazz = collectionValue.getClass(); @@ -122,7 +127,13 @@ } if (length > 1) { - throw new IllegalArgumentException("More than one element in filter array is unsupported."); + throw new IllegalArgumentException( + MessageFormat + .format( + "More than one element in filter array is unsupported.\nproperty: {0}, value: {1} - length: {2}", + propertyName, + collectionValue, + length)); } } // TODO other cases? Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java =================================================================== --- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java 2014-08-01 17:01:13 UTC (rev 4585) +++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java 2014-08-01 17:03:08 UTC (rev 4586) @@ -145,7 +145,7 @@ if (propertyType.isCollectionType()) { - propertyValue = ExampleTreeUtils.getValueFromCollection(propertyValue); + propertyValue = ExampleTreeUtils.getValueFromCollection(propertyName, propertyValue); } if (propertyValue == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |