JsonGenerator.Converter remove unneeded method The `Object convert(Object, String)` method handles the case where a key name is provided and the docs clearly specify that it may be null in cases where no key name exists.
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ca6beb8c Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ca6beb8c Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ca6beb8c Branch: refs/heads/parrot Commit: ca6beb8c4540c9211834a453f398b6b609ee606d Parents: 491c0af Author: John Wagenleitner <[email protected]> Authored: Tue Nov 8 17:11:59 2016 -0800 Committer: John Wagenleitner <[email protected]> Committed: Tue Nov 8 17:11:59 2016 -0800 ---------------------------------------------------------------------- .../src/main/java/groovy/json/DefaultJsonGenerator.java | 12 ++---------- .../src/main/java/groovy/json/JsonGenerator.java | 8 -------- .../groovy/groovy/json/CustomJsonGeneratorTest.groovy | 5 ----- .../groovy/groovy/json/DefaultJsonGeneratorTest.groovy | 4 ++-- 4 files changed, 4 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/ca6beb8c/subprojects/groovy-json/src/main/java/groovy/json/DefaultJsonGenerator.java ---------------------------------------------------------------------- diff --git a/subprojects/groovy-json/src/main/java/groovy/json/DefaultJsonGenerator.java b/subprojects/groovy-json/src/main/java/groovy/json/DefaultJsonGenerator.java index 884486d..a3e54f8 100644 --- a/subprojects/groovy-json/src/main/java/groovy/json/DefaultJsonGenerator.java +++ b/subprojects/groovy-json/src/main/java/groovy/json/DefaultJsonGenerator.java @@ -487,6 +487,7 @@ public class DefaultJsonGenerator implements JsonGenerator { * @return true if this converter can successfully convert values of * the given type */ + @Override public boolean handles(Class<?> type) { return this.type.isAssignableFrom(type); } @@ -495,19 +496,10 @@ public class DefaultJsonGenerator implements JsonGenerator { * Converts a given value. * * @param value the object to convert - * @return the converted object - */ - public Object convert(Object value) { - return convert(value, null); - } - - /** - * Converts a given value. - * - * @param value the object to convert * @param key the key name for the value, may be {@code null} * @return the converted object */ + @Override public Object convert(Object value, String key) { return (paramCount == 1) ? closure.call(value) : http://git-wip-us.apache.org/repos/asf/groovy/blob/ca6beb8c/subprojects/groovy-json/src/main/java/groovy/json/JsonGenerator.java ---------------------------------------------------------------------- diff --git a/subprojects/groovy-json/src/main/java/groovy/json/JsonGenerator.java b/subprojects/groovy-json/src/main/java/groovy/json/JsonGenerator.java index aa81f45..cea8b4b 100644 --- a/subprojects/groovy-json/src/main/java/groovy/json/JsonGenerator.java +++ b/subprojects/groovy-json/src/main/java/groovy/json/JsonGenerator.java @@ -87,14 +87,6 @@ public interface JsonGenerator { * Converts a given object. * * @param value the object to convert - * @return the converted object - */ - Object convert(Object value); - - /** - * Converts a given object. - * - * @param value the object to convert * @param key the key name for the value, may be {@code null} * @return the converted object */ http://git-wip-us.apache.org/repos/asf/groovy/blob/ca6beb8c/subprojects/groovy-json/src/test/groovy/groovy/json/CustomJsonGeneratorTest.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-json/src/test/groovy/groovy/json/CustomJsonGeneratorTest.groovy b/subprojects/groovy-json/src/test/groovy/groovy/json/CustomJsonGeneratorTest.groovy index 08b5178..ad21ee9 100644 --- a/subprojects/groovy-json/src/test/groovy/groovy/json/CustomJsonGeneratorTest.groovy +++ b/subprojects/groovy-json/src/test/groovy/groovy/json/CustomJsonGeneratorTest.groovy @@ -76,11 +76,6 @@ class CustomJsonGeneratorTest extends GroovyTestCase { } @Override - Object convert(Object value) { - return convert(value, null) - } - - @Override Object convert(Object value, String key) { return ((CustomFoo)value).c.call() } http://git-wip-us.apache.org/repos/asf/groovy/blob/ca6beb8c/subprojects/groovy-json/src/test/groovy/groovy/json/DefaultJsonGeneratorTest.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-json/src/test/groovy/groovy/json/DefaultJsonGeneratorTest.groovy b/subprojects/groovy-json/src/test/groovy/groovy/json/DefaultJsonGeneratorTest.groovy index 4c4f7c9..c1c17e2 100644 --- a/subprojects/groovy-json/src/test/groovy/groovy/json/DefaultJsonGeneratorTest.groovy +++ b/subprojects/groovy-json/src/test/groovy/groovy/json/DefaultJsonGeneratorTest.groovy @@ -129,8 +129,8 @@ class DefaultJsonGeneratorTest extends GroovyTestCase { options.addConverter(java.sql.Date, {}) assert [email protected]() == 4 - assert options.@converters[2].convert(null) == 'c2' - assert [email protected] { it.convert(null) == 'c1' } + assert options.@converters[2].convert(null, null) == 'c2' + assert [email protected] { it.convert(null, null) == 'c1' } } void testConvertersBadInput() {
