From 4f6594388c09c54488a22e7e22726ee96170785a Mon Sep 17 00:00:00 2001 From: Joerg Hohwiller Date: Sat, 6 Aug 2016 12:40:37 +0200 Subject: [PATCH] #166: Workarounds for bugs in Eclipse compiler --- .../sf/mmm/util/value/api/ValueConverter.java | 56 ++++++++----------- .../resource/base/ClasspathScannerTest.java | 7 ++- .../sf/mmm/util/io/base/StreamUtilTest.java | 3 - 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/core/src/main/java/net/sf/mmm/util/value/api/ValueConverter.java b/core/src/main/java/net/sf/mmm/util/value/api/ValueConverter.java index 3ae7c58a0..2525e76ae 100644 --- a/core/src/main/java/net/sf/mmm/util/value/api/ValueConverter.java +++ b/core/src/main/java/net/sf/mmm/util/value/api/ValueConverter.java @@ -7,8 +7,8 @@ import net.sf.mmm.util.reflect.api.GenericType; /** - * This is the interface for a converter that {@link #convert(Object, Object, GenericType) converts} a value - * from a {@link #getSourceType() source-type} to a specific {@link #getTargetType() target-type}.
+ * This is the interface for a converter that {@link #convert(Object, Object, GenericType) converts} a value from a + * {@link #getSourceType() source-type} to a specific {@link #getTargetType() target-type}.
* ATTENTION:
* An implementation of this interface should be stateless and thread-safe. * @@ -22,53 +22,45 @@ public interface ValueConverter extends SimpleValueConverter { /** - * This the type of the value accepted by this converter. Use {@link Object} if you want to accept any - * value. A very common {@link #getSourceType() source-type} is {@link String}. + * This the type of the value accepted by this converter. Use {@link Object} if you want to accept any value. A very + * common {@link #getSourceType() source-type} is {@link String}. * * @return the source-type. */ Class getSourceType(); /** - * Is the guaranteed return-type of the {@link #convert(Object, Object, GenericType) conversion}. This - * information is used externally to choose the most specific {@link ValueConverter} that is - * {@link Class#isAssignableFrom(Class) appropriate} for the conversion.
- * E.g. a generic converter can have {@link Object} as {@link #getTargetType() target-type} while a specific - * converter may have {@link java.util.Collection} as {@link #getTargetType() target-type}. Now if an object - * (compliant with the {@link #getSourceType() source-type}) needs to be converted to a - * {@link java.util.Collection} or {@link java.util.List}, the specific converter is used while for other - * objects the generic converter is chosen.
+ * Is the guaranteed return-type of the {@link #convert(Object, Object, GenericType) conversion}. This information is + * used externally to choose the most specific {@link ValueConverter} that is {@link Class#isAssignableFrom(Class) + * appropriate} for the conversion.
+ * E.g. a generic converter can have {@link Object} as {@link #getTargetType() target-type} while a specific converter + * may have {@link java.util.Collection} as {@link #getTargetType() target-type}. Now if an object (compliant with the + * {@link #getSourceType() source-type}) needs to be converted to a {@link java.util.Collection} or + * {@link java.util.List}, the specific converter is used while for other objects the generic converter is chosen. + *
* Please note that the {@link #getTargetType() target-type} is often more general than the actual - * {@link #convert(Object, Object, GenericType) returned result}. So a {@link ValueConverter} that converts - * a comma-separated {@link String} to an {@link java.util.ArrayList} will typically declare - * {@link java.util.List} as {@link #getTargetType() target-type}. + * {@link #convert(Object, Object, GenericType) returned result}. So a {@link ValueConverter} that converts a + * comma-separated {@link String} to an {@link java.util.ArrayList} will typically declare {@link java.util.List} as + * {@link #getTargetType() target-type}. * * @return the target-type. */ Class getTargetType(); - /** - * {@inheritDoc} - * - * @see #convert(Object, Object, GenericType) - */ - @Override - T convert(SOURCE value, Object valueSource, Class targetClass) throws ValueException; - /** * This method converts the given {@code pojo} to the {@literal }-type. * * @param is the generic type of {@code targetClass}. * @param value is the value to convert. - * @param valueSource describes the source of the value. This may be the filename where the value was read - * from, an XPath where the value was located in an XML document, etc. It is used in exceptions - * thrown if something goes wrong. This will help to find the problem easier. - * @param targetType is the {@link GenericType} to convert the {@code value} to. It is potentially generic - * and therefore contains more detailed information than a {@link Class}. E.g. the {@code targetType} - * could be java.util.List<Long>. This could help e.g. if the {@code value} is a - * string like {@code "2, 47, 4252525"}. - * @return the converted {@code value} or {@code null} if the conversion is NOT possible. The returned value - * has to be an {@link Class#isInstance(Object) instance} of the given {@code targetType}. + * @param valueSource describes the source of the value. This may be the filename where the value was read from, an + * XPath where the value was located in an XML document, etc. It is used in exceptions thrown if something goes + * wrong. This will help to find the problem easier. + * @param targetType is the {@link GenericType} to convert the {@code value} to. It is potentially generic and + * therefore contains more detailed information than a {@link Class}. E.g. the {@code targetType} could be + * java.util.List<Long>. This could help e.g. if the {@code value} is a string like + * {@code "2, 47, 4252525"}. + * @return the converted {@code value} or {@code null} if the conversion is NOT possible. The returned value has to be + * an {@link Class#isInstance(Object) instance} of the given {@code targetType}. * @throws ValueException if the conversion failed (e.g. the given {@code value} is illegal for the given * {@code targetClass}). */ diff --git a/core/src/test/java/net/sf/mmm/util/resource/base/ClasspathScannerTest.java b/core/src/test/java/net/sf/mmm/util/resource/base/ClasspathScannerTest.java index 17d3cd30e..e3e10075f 100644 --- a/core/src/test/java/net/sf/mmm/util/resource/base/ClasspathScannerTest.java +++ b/core/src/test/java/net/sf/mmm/util/resource/base/ClasspathScannerTest.java @@ -126,6 +126,7 @@ public void testGetByPackage() { /** * @param clazz the {@link Class} to test via {@link ClasspathScanner}. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) // Workaround for bug in Eclipse compiler protected void checkClass(Class clazz) { ClasspathScanner scanner = getClasspathScanner(); @@ -135,8 +136,7 @@ protected void checkClass(Class clazz) { assertThat(packageResource.isData()).isFalse(); assertThat(packageResource.getPath()).isEqualTo(clazz.getPackage().getName().replace('.', '/')); assertThat(packageResource.isAvailable()).isFalse(); - assertThat(packageResource.getChildResources()).contains(scanner.getClasspathResource(clazz.getName().replace('.', '/') + ".class")); - + assertThat((Iterable) packageResource.getChildResources()).contains(scanner.getClasspathResource(clazz.getName().replace('.', '/') + ".class")); } /** Test of {@link ClasspathScanner#getClasspathResourceFiles()}. */ @@ -149,7 +149,8 @@ public void testClasspathScanner() { Iterable files = scanner.getClasspathResourceFiles(); // then assertThat(files).isInstanceOf(List.class); - List fileList = (List) files; + @SuppressWarnings("unchecked") // Workaround for bug in Eclipse compiler + List fileList = (List) files; assertThat(fileList.size()).isBetween(Integer.valueOf(600), Integer.valueOf(1200)); assertThat(fileList).contains(scanner.getClasspathResource(CLASSPATH_HYPHENATION_XML), scanner.getClasspathResource(CLASSPATH_NLS_BUNDLES)); } diff --git a/io/src/test/java/net/sf/mmm/util/io/base/StreamUtilTest.java b/io/src/test/java/net/sf/mmm/util/io/base/StreamUtilTest.java index 08e5f939e..7b7582a5d 100644 --- a/io/src/test/java/net/sf/mmm/util/io/base/StreamUtilTest.java +++ b/io/src/test/java/net/sf/mmm/util/io/base/StreamUtilTest.java @@ -171,9 +171,6 @@ public int read() throws IOException { transferrer.get(); fail("expected " + ExecutionException.class); } catch (ExecutionException e) { - if (error != e.getCause()) { - e.printStackTrace(); - } ExceptionHelper.assertCause(e, error); } assertThat(outStream.size()).isZero();