You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by da...@apache.org on 2017/02/17 16:19:52 UTC

svn commit: r1783421 - /felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConvertFunction.java

Author: davidb
Date: Fri Feb 17 16:19:52 2017
New Revision: 1783421

URL: http://svn.apache.org/viewvc?rev=1783421&view=rev
Log:
Updated Converter API from OSGi

Originating OSGi commit: fdef401c0ba28b988775b1c92e07b8467c773075

Modified:
    felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConvertFunction.java

Modified: felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConvertFunction.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConvertFunction.java?rev=1783421&r1=1783420&r2=1783421&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConvertFunction.java (original)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/ConvertFunction.java Fri Feb 17 16:19:52 2017
@@ -49,4 +49,27 @@ public interface ConvertFunction<F, T> {
 	 */
 	T convert(F obj, Type targetType, Object root, Object[] keyPath)
 			throws Exception;
+
+	/**
+	 * Override the default error handling mechanism. Whenever a converter
+	 * throws a Conversion Exception, this can be overridden with either another
+	 * runtime exception or an actual value.
+	 *
+	 * @param obj The object to be converted. This object will never be
+	 *            {@code null} as the convert function will not be invoked for
+	 *            null values.
+	 * @param targetType The target type.
+	 * @param root The root object, if this obj was embedded in a root object.
+	 *            Otherwise {@code null}.
+	 * @param keyPath If the object is embedded in a root object, the path of
+	 *            keys that reach this object. Otherwise {@code null}.
+	 * @return A value to use in case of an error. This method can return
+	 *         {@code null} to indicate that it cannot handle the error.
+	 * @throws RuntimeException Another Runtime Exception may also be thrown by
+	 *             this handler.
+	 */
+	default T handleError(F obj, Type targetType, Object root,
+			Object[] keyPath) {
+		return null;
+	}
 }