diff --git a/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/AutoMapped.java b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/AutoMapped.java new file mode 100644 index 000000000..dde4b8689 --- /dev/null +++ b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/AutoMapped.java @@ -0,0 +1,46 @@ +package io.vertx.test.codegen.converter; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.Objects; + +@DataObject +public interface AutoMapped { + + static AutoMapped fromJson(JsonObject json) { + int port = json.getInteger("port", -1); + String host = json.getString("host"); + return of(host, port); + } + + static AutoMapped of(String host, int port) { + return new AutoMapped() { + @Override + public int port() { + return port; + } + @Override + public String host() { + return host; + } + @Override + public int hashCode() { + return host.hashCode() + port; + } + @Override + public boolean equals(Object obj) { + AutoMapped that = (AutoMapped) obj; + return Objects.equals(host(), that.host()) && port() == that.port(); + } + }; + } + + int port(); + + String host(); + + default JsonObject toJson() { + return new JsonObject().put("port", port()).put("host", host()); + } +} diff --git a/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/AutoMappedWithVertxGen.java b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/AutoMappedWithVertxGen.java new file mode 100644 index 000000000..6045b26eb --- /dev/null +++ b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/AutoMappedWithVertxGen.java @@ -0,0 +1,49 @@ +package io.vertx.test.codegen.converter; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.codegen.annotations.VertxGen; +import io.vertx.core.json.JsonObject; + +import java.util.Objects; + +@DataObject +@VertxGen +public interface AutoMappedWithVertxGen { + + static AutoMappedWithVertxGen fromJson(JsonObject json) { + int port = json.getInteger("port", -1); + String host = json.getString("host"); + return of(host, port); + } + + static AutoMappedWithVertxGen of(String host, int port) { + return new AutoMappedWithVertxGen() { + @Override + public int port() { + return port; + } + @Override + public String host() { + return host; + } + @Override + public int hashCode() { + return host.hashCode() + port; + } + @Override + public boolean equals(Object obj) { + AutoMappedWithVertxGen that = (AutoMappedWithVertxGen) obj; + return Objects.equals(host(), that.host()) && port() == that.port(); + } + }; + } + + + int port(); + + String host(); + + default JsonObject toJson() { + return new JsonObject().put("port", port()).put("host", host()); + } +} diff --git a/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/DataObjectTest.java b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/DataObjectTest.java index a78656559..8701effb9 100644 --- a/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/DataObjectTest.java +++ b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/DataObjectTest.java @@ -65,6 +65,8 @@ public void testJsonToDataObject() throws Exception { TimeUnit httpMethod = TimeUnit.values()[TestUtils.randomPositiveInt() % TimeUnit.values().length]; ZonedDateTime methodMapped = ZonedDateTime.now(); TestCustomEnum enumMapped = TestCustomEnum.DEV; + AutoMapped autoMapped = AutoMapped.of("vertx.io", 80); + AutoMappedWithVertxGen autoMappedWithVertxGen = AutoMappedWithVertxGen.of("vertx.io", 80); Map map = new HashMap<>(); map.put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(20)); @@ -76,67 +78,73 @@ public void testJsonToDataObject() throws Exception { list.add(TestUtils.randomInt()); JsonObject json = new JsonObject(); - json.put("string", stringValue); - json.put("primitiveBoolean", booleanValue); - json.put("primitiveByte", byteValue); - json.put("primitiveShort", shortValue); - json.put("primitiveInt", intValue); - json.put("primitiveLong", longValue); - json.put("primitiveFloat", floatValue); - json.put("primitiveDouble", doubleValue); - json.put("primitiveChar", Character.toString(charValue)); - json.put("boxedBoolean", boxedBooleanValue); - json.put("boxedByte", boxedByteValue); - json.put("boxedShort", boxedShortValue); - json.put("boxedInt", boxedIntValue); - json.put("boxedLong", boxedLongValue); - json.put("boxedFloat", boxedFloatValue); - json.put("boxedDouble", boxedDoubleValue); - json.put("boxedChar", Character.toString(boxedCharValue)); - json.put("jsonObjectDataObject", jsonObjectDataObject.toJson()); - json.put("stringDataObject", stringDataObject.toJson()); - json.put("buffer", toBase64(buffer)); - json.put("jsonObject", jsonObject); - json.put("jsonArray", jsonArray); - json.put("httpMethod", httpMethod.toString()); - json.put("methodMapped", methodMapped.toString()); - json.put("enumMapped", enumMapped.getShortName()); - json.put("stringList", new JsonArray().add(stringValue)); - json.put("boxedBooleanList", new JsonArray().add(boxedBooleanValue)); - json.put("boxedByteList", new JsonArray().add(boxedByteValue)); - json.put("boxedShortList", new JsonArray().add(boxedShortValue)); - json.put("boxedIntList", new JsonArray().add(boxedIntValue)); - json.put("boxedLongList", new JsonArray().add(boxedLongValue)); - json.put("boxedFloatList", new JsonArray().add(boxedFloatValue)); - json.put("boxedDoubleList", new JsonArray().add(boxedDoubleValue)); - json.put("boxedCharList", new JsonArray().add(Character.toString(boxedCharValue))); - json.put("jsonObjectDataObjectList", new JsonArray().add(jsonObjectDataObject.toJson())); - json.put("stringDataObjectList", new JsonArray().add(stringDataObject.toJson())); - json.put("bufferList", new JsonArray().add(toBase64(buffer))); - json.put("jsonObjectList", new JsonArray().add(jsonObject)); - json.put("jsonArrayList", new JsonArray().add(jsonArray)); - json.put("httpMethodList", new JsonArray().add(httpMethod.toString())); - json.put("methodMappedList", new JsonArray().add(methodMapped.toString())); - json.put("objectList", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2))); - json.put("enumMappedList", new JsonArray().add(enumMapped.getShortName())); - json.put("stringSet", new JsonArray().add(stringValue)); - json.put("boxedBooleanSet", new JsonArray().add(boxedBooleanValue)); - json.put("boxedByteSet", new JsonArray().add(boxedByteValue)); - json.put("boxedShortSet", new JsonArray().add(boxedShortValue)); - json.put("boxedIntSet", new JsonArray().add(boxedIntValue)); - json.put("boxedLongSet", new JsonArray().add(boxedLongValue)); - json.put("boxedFloatSet", new JsonArray().add(boxedFloatValue)); - json.put("boxedDoubleSet", new JsonArray().add(boxedDoubleValue)); - json.put("boxedCharSet", new JsonArray().add(Character.toString(boxedCharValue))); - json.put("jsonObjectDataObjectSet", new JsonArray().add(jsonObjectDataObject.toJson())); - json.put("stringDataObjectSet", new JsonArray().add(stringDataObject.toJson())); - json.put("bufferSet", new JsonArray().add(toBase64(buffer))); - json.put("jsonObjectSet", new JsonArray().add(jsonObject)); - json.put("jsonArraySet", new JsonArray().add(jsonArray)); - json.put("httpMethodSet", new JsonArray().add(httpMethod.toString())); - json.put("methodMappedSet", new JsonArray().add(methodMapped.toString())); - json.put("objectSet", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2))); - json.put("enumMappedSet", new JsonArray().add(enumMapped.getShortName())); + json.put("stringValue", stringValue); + json.put("primitiveBooleanValue", booleanValue); + json.put("primitiveByteValue", byteValue); + json.put("primitiveShortValue", shortValue); + json.put("primitiveIntValue", intValue); + json.put("primitiveLongValue", longValue); + json.put("primitiveFloatValue", floatValue); + json.put("primitiveDoubleValue", doubleValue); + json.put("primitiveCharValue", Character.toString(charValue)); + json.put("boxedBooleanValue", boxedBooleanValue); + json.put("boxedByteValue", boxedByteValue); + json.put("boxedShortValue", boxedShortValue); + json.put("boxedIntValue", boxedIntValue); + json.put("boxedLongValue", boxedLongValue); + json.put("boxedFloatValue", boxedFloatValue); + json.put("boxedDoubleValue", boxedDoubleValue); + json.put("boxedCharValue", Character.toString(boxedCharValue)); + json.put("jsonObjectDataObjectValue", jsonObjectDataObject.toJson()); + json.put("stringDataObjectValue", stringDataObject.toJson()); + json.put("bufferValue", toBase64(buffer)); + json.put("jsonObjectValue", jsonObject); + json.put("jsonArrayValue", jsonArray); + json.put("enumValue", httpMethod.toString()); + json.put("methodMappedValue", methodMapped.toString()); + json.put("customEnumValue", enumMapped.getShortName()); + json.put("autoMappedValue", autoMapped.toJson()); + json.put("autoMappedWithVertxGenValue", autoMappedWithVertxGen.toJson()); + json.put("stringValueList", new JsonArray().add(stringValue)); + json.put("boxedBooleanValueList", new JsonArray().add(boxedBooleanValue)); + json.put("boxedByteValueList", new JsonArray().add(boxedByteValue)); + json.put("boxedShortValueList", new JsonArray().add(boxedShortValue)); + json.put("boxedIntValueList", new JsonArray().add(boxedIntValue)); + json.put("boxedLongValueList", new JsonArray().add(boxedLongValue)); + json.put("boxedFloatValueList", new JsonArray().add(boxedFloatValue)); + json.put("boxedDoubleValueList", new JsonArray().add(boxedDoubleValue)); + json.put("boxedCharValueList", new JsonArray().add(Character.toString(boxedCharValue))); + json.put("jsonObjectDataObjectValueList", new JsonArray().add(jsonObjectDataObject.toJson())); + json.put("stringDataObjectValueList", new JsonArray().add(stringDataObject.toJson())); + json.put("bufferValueList", new JsonArray().add(toBase64(buffer))); + json.put("jsonObjectValueList", new JsonArray().add(jsonObject)); + json.put("jsonArrayValueList", new JsonArray().add(jsonArray)); + json.put("enumValueList", new JsonArray().add(httpMethod.toString())); + json.put("methodMappedValueList", new JsonArray().add(methodMapped.toString())); + json.put("objectValueList", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2))); + json.put("customEnumValueList", new JsonArray().add(enumMapped.getShortName())); + json.put("autoMappedValueList", new JsonArray().add(autoMapped.toJson())); + json.put("autoMappedWithVertxGenValueList", new JsonArray().add(autoMappedWithVertxGen.toJson())); + json.put("stringValueSet", new JsonArray().add(stringValue)); + json.put("boxedBooleanValueSet", new JsonArray().add(boxedBooleanValue)); + json.put("boxedByteValueSet", new JsonArray().add(boxedByteValue)); + json.put("boxedShortValueSet", new JsonArray().add(boxedShortValue)); + json.put("boxedIntValueSet", new JsonArray().add(boxedIntValue)); + json.put("boxedLongValueSet", new JsonArray().add(boxedLongValue)); + json.put("boxedFloatValueSet", new JsonArray().add(boxedFloatValue)); + json.put("boxedDoubleValueSet", new JsonArray().add(boxedDoubleValue)); + json.put("boxedCharValueSet", new JsonArray().add(Character.toString(boxedCharValue))); + json.put("jsonObjectDataObjectValueSet", new JsonArray().add(jsonObjectDataObject.toJson())); + json.put("stringDataObjectValueSet", new JsonArray().add(stringDataObject.toJson())); + json.put("bufferValueSet", new JsonArray().add(toBase64(buffer))); + json.put("jsonObjectValueSet", new JsonArray().add(jsonObject)); + json.put("jsonArrayValueSet", new JsonArray().add(jsonArray)); + json.put("enumValueSet", new JsonArray().add(httpMethod.toString())); + json.put("methodMappedValueSet", new JsonArray().add(methodMapped.toString())); + json.put("objectValueSet", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2))); + json.put("customEnumValueSet", new JsonArray().add(enumMapped.getShortName())); + json.put("autoMappedValueSet", new JsonArray().add(autoMapped.toJson())); + json.put("autoMappedWithVertxGenValueSet", new JsonArray().add(autoMappedWithVertxGen.toJson())); json.put("addedStringValues", new JsonArray().add(stringValue)); json.put("addedBooleanValues", new JsonArray().add(boxedBooleanValue)); json.put("addedByteValues", new JsonArray().add(boxedByteValue)); @@ -154,15 +162,17 @@ public void testJsonToDataObject() throws Exception { json.put("addedBoxedFloatValues", new JsonArray().add(boxedFloatValue)); json.put("addedBoxedDoubleValues", new JsonArray().add(boxedDoubleValue)); json.put("addedBoxedCharValues", new JsonArray().add(Character.toString(boxedCharValue))); - json.put("addedJsonObjectDataObjects", new JsonArray().add(jsonObjectDataObject.toJson())); - json.put("addedStringDataObjects", new JsonArray().add(stringDataObject.toJson())); - json.put("addedBuffers", new JsonArray().add(toBase64(buffer))); - json.put("addedJsonObjects", new JsonArray().add(jsonObject)); - json.put("addedJsonArrays", new JsonArray().add(jsonArray)); - json.put("addedHttpMethods", new JsonArray().add(httpMethod.toString())); - json.put("addedMethodMappeds", new JsonArray().add(methodMapped.toString())); - json.put("addedObjects", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2))); - json.put("addedEnumMappeds", new JsonArray().add(enumMapped.getShortName())); + json.put("addedJsonObjectDataObjectValues", new JsonArray().add(jsonObjectDataObject.toJson())); + json.put("addedStringDataObjectValues", new JsonArray().add(stringDataObject.toJson())); + json.put("addedBufferValues", new JsonArray().add(toBase64(buffer))); + json.put("addedJsonObjectValues", new JsonArray().add(jsonObject)); + json.put("addedJsonArrayValues", new JsonArray().add(jsonArray)); + json.put("addedEnumValues", new JsonArray().add(httpMethod.toString())); + json.put("addedMethodMappedValues", new JsonArray().add(methodMapped.toString())); + json.put("addedObjectValues", new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2))); + json.put("addedCustomEnumValues", new JsonArray().add(enumMapped.getShortName())); + json.put("addedAutoMappedValues", new JsonArray().add(autoMapped.toJson())); + json.put("addedAutoMappedWithVertxGenValues", new JsonArray().add(autoMappedWithVertxGen.toJson())); json.put("stringValueMap", new JsonObject().put(key, stringValue)); json.put("boxedBooleanValueMap", new JsonObject().put(key, boxedBooleanValue)); json.put("boxedByteValueMap", new JsonObject().put(key, boxedByteValue)); @@ -172,15 +182,17 @@ public void testJsonToDataObject() throws Exception { json.put("boxedFloatValueMap", new JsonObject().put(key, boxedFloatValue)); json.put("boxedDoubleValueMap", new JsonObject().put(key, boxedDoubleValue)); json.put("boxedCharValueMap", new JsonObject().put(key, Character.toString(boxedCharValue))); - json.put("jsonObjectDataObjectMap", new JsonObject().put(key, jsonObjectDataObject.toJson())); - json.put("stringDataObjectMap", new JsonObject().put(key, stringDataObject.toJson())); - json.put("bufferMap", new JsonObject().put(key, toBase64(buffer))); - json.put("jsonObjectMap", new JsonObject().put(key, jsonObject)); - json.put("jsonArrayMap", new JsonObject().put(key, jsonArray)); - json.put("httpMethodMap", new JsonObject().put(key, httpMethod.toString())); - json.put("methodMappedMap", new JsonObject().put(key, methodMapped.toString())); - json.put("objectMap", toJson(map)); - json.put("enumMappedMap", new JsonObject().put(key, enumMapped.getShortName())); + json.put("jsonObjectDataObjectValueMap", new JsonObject().put(key, jsonObjectDataObject.toJson())); + json.put("stringDataObjectValueMap", new JsonObject().put(key, stringDataObject.toJson())); + json.put("bufferValueMap", new JsonObject().put(key, toBase64(buffer))); + json.put("jsonObjectValueMap", new JsonObject().put(key, jsonObject)); + json.put("jsonArrayValueMap", new JsonObject().put(key, jsonArray)); + json.put("enumValueMap", new JsonObject().put(key, httpMethod.toString())); + json.put("methodMappedValueMap", new JsonObject().put(key, methodMapped.toString())); + json.put("objectValueMap", toJson(map)); + json.put("customEnumValueMap", new JsonObject().put(key, enumMapped.getShortName())); + json.put("autoMappedValueMap", new JsonObject().put(key, autoMapped.toJson())); + json.put("autoMappedWithVertxGenValueMap", new JsonObject().put(key, autoMapped.toJson())); json.put("keyedStringValues", new JsonObject().put(key, stringValue)); json.put("keyedBoxedBooleanValues", new JsonObject().put(key, boxedBooleanValue)); json.put("keyedBoxedByteValues", new JsonObject().put(key, boxedByteValue)); @@ -198,72 +210,80 @@ public void testJsonToDataObject() throws Exception { json.put("keyedEnumValues", new JsonObject().put(key, httpMethod.name())); json.put("keyedMethodMappedValues", new JsonObject().put(key, methodMapped.toString())); json.put("keyedObjectValues", toJson(map)); - json.put("keyedEnumMappedValues", new JsonObject().put(key, enumMapped.getShortName())); + json.put("keyedCustomEnumValues", new JsonObject().put(key, enumMapped.getShortName())); + json.put("keyedAutoMappedValues", new JsonObject().put(key, autoMapped.toJson())); + json.put("keyedAutoMappedWithVertxGenValues", new JsonObject().put(key, autoMapped.toJson())); TestDataObject obj = new TestDataObject(); TestDataObjectConverter.fromJson(json, obj); - Assert.assertEquals(stringValue, obj.getString()); - Assert.assertEquals(booleanValue, obj.isPrimitiveBoolean()); - Assert.assertEquals(byteValue, obj.getPrimitiveByte()); - Assert.assertEquals(shortValue, obj.getPrimitiveShort()); - Assert.assertEquals(intValue, obj.getPrimitiveInt()); - Assert.assertEquals(longValue, obj.getPrimitiveLong()); - Assert.assertEquals(floatValue, obj.getPrimitiveFloat(), 0); - Assert.assertEquals(doubleValue, obj.getPrimitiveDouble(), 0); - Assert.assertEquals(charValue, obj.getPrimitiveChar()); - Assert.assertEquals(boxedBooleanValue, obj.isBoxedBoolean()); - Assert.assertEquals(boxedByteValue, obj.getBoxedByte()); - Assert.assertEquals(boxedShortValue, obj.getBoxedShort()); - Assert.assertEquals(boxedIntValue, obj.getBoxedInt()); - Assert.assertEquals(boxedLongValue, obj.getBoxedLong()); - Assert.assertEquals(boxedFloatValue, obj.getBoxedFloat(), 0); - Assert.assertEquals(boxedDoubleValue, obj.getBoxedDouble(), 0); - Assert.assertEquals(boxedCharValue, obj.getBoxedChar()); - assertEquals(jsonObjectDataObject, obj.getJsonObjectDataObject()); - assertEquals(stringDataObject, obj.getStringDataObject()); - Assert.assertEquals(buffer, obj.getBuffer()); - Assert.assertEquals(jsonObject, obj.getJsonObject()); - Assert.assertEquals(jsonArray, obj.getJsonArray()); - Assert.assertEquals(httpMethod, obj.getHttpMethod()); - Assert.assertEquals(methodMapped, obj.getMethodMapped()); - Assert.assertEquals(enumMapped, obj.getEnumMapped()); - Assert.assertEquals(Collections.singletonList(stringValue), obj.getStringList()); - Assert.assertEquals(Collections.singletonList(boxedBooleanValue), obj.getBoxedBooleanList()); - Assert.assertEquals(Collections.singletonList(boxedByteValue), obj.getBoxedByteList()); - Assert.assertEquals(Collections.singletonList(boxedShortValue), obj.getBoxedShortList()); - Assert.assertEquals(Collections.singletonList(boxedIntValue), obj.getBoxedIntList()); - Assert.assertEquals(Collections.singletonList(boxedLongValue), obj.getBoxedLongList()); - Assert.assertEquals(Collections.singletonList(boxedFloatValue), obj.getBoxedFloatList()); - Assert.assertEquals(Collections.singletonList(boxedDoubleValue), obj.getBoxedDoubleList()); - Assert.assertEquals(Collections.singletonList(boxedCharValue), obj.getBoxedCharList()); - Assert.assertEquals(Collections.singletonList(jsonObjectDataObject), obj.getJsonObjectDataObjectList()); - Assert.assertEquals(Collections.singletonList(stringDataObject), obj.getStringDataObjectList()); - Assert.assertEquals(Collections.singletonList(buffer), obj.getBufferList()); - Assert.assertEquals(Collections.singletonList(jsonObject), obj.getJsonObjectList()); - Assert.assertEquals(Collections.singletonList(jsonArray), obj.getJsonArrayList()); - Assert.assertEquals(Collections.singletonList(httpMethod), obj.getHttpMethodList()); - Assert.assertEquals(Collections.singletonList(methodMapped), obj.getMethodMappedList()); - Assert.assertEquals(list, obj.getObjectList()); - Assert.assertEquals(Collections.singletonList(enumMapped), obj.getEnumMappedList()); - Assert.assertEquals(Collections.singleton(stringValue), obj.getStringSet()); - Assert.assertEquals(Collections.singleton(boxedBooleanValue), obj.getBoxedBooleanSet()); - Assert.assertEquals(Collections.singleton(boxedByteValue), obj.getBoxedByteSet()); - Assert.assertEquals(Collections.singleton(boxedShortValue), obj.getBoxedShortSet()); - Assert.assertEquals(Collections.singleton(boxedIntValue), obj.getBoxedIntSet()); - Assert.assertEquals(Collections.singleton(boxedLongValue), obj.getBoxedLongSet()); - Assert.assertEquals(Collections.singleton(boxedFloatValue), obj.getBoxedFloatSet()); - Assert.assertEquals(Collections.singleton(boxedDoubleValue), obj.getBoxedDoubleSet()); - Assert.assertEquals(Collections.singleton(boxedCharValue), obj.getBoxedCharSet()); - Assert.assertEquals(Collections.singleton(jsonObjectDataObject), obj.getJsonObjectDataObjectSet()); - Assert.assertEquals(Collections.singleton(stringDataObject), obj.getStringDataObjectSet()); - Assert.assertEquals(Collections.singleton(buffer), obj.getBufferSet()); - Assert.assertEquals(Collections.singleton(jsonObject), obj.getJsonObjectSet()); - Assert.assertEquals(Collections.singleton(jsonArray), obj.getJsonArraySet()); - Assert.assertEquals(Collections.singleton(httpMethod), obj.getHttpMethodSet()); - Assert.assertEquals(Collections.singleton(methodMapped), obj.getMethodMappedSet()); - Assert.assertEquals(new LinkedHashSet<>(list), obj.getObjectSet()); - Assert.assertEquals(Collections.singleton(enumMapped), obj.getEnumMappedSet()); + Assert.assertEquals(stringValue, obj.getStringValue()); + Assert.assertEquals(booleanValue, obj.isPrimitiveBooleanValue()); + Assert.assertEquals(byteValue, obj.getPrimitiveByteValue()); + Assert.assertEquals(shortValue, obj.getPrimitiveShortValue()); + Assert.assertEquals(intValue, obj.getPrimitiveIntValue()); + Assert.assertEquals(longValue, obj.getPrimitiveLongValue()); + Assert.assertEquals(floatValue, obj.getPrimitiveFloatValue(), 0); + Assert.assertEquals(doubleValue, obj.getPrimitiveDoubleValue(), 0); + Assert.assertEquals(charValue, obj.getPrimitiveCharValue()); + Assert.assertEquals(boxedBooleanValue, obj.isBoxedBooleanValue()); + Assert.assertEquals(boxedByteValue, obj.getBoxedByteValue()); + Assert.assertEquals(boxedShortValue, obj.getBoxedShortValue()); + Assert.assertEquals(boxedIntValue, obj.getBoxedIntValue()); + Assert.assertEquals(boxedLongValue, obj.getBoxedLongValue()); + Assert.assertEquals(boxedFloatValue, obj.getBoxedFloatValue(), 0); + Assert.assertEquals(boxedDoubleValue, obj.getBoxedDoubleValue(), 0); + Assert.assertEquals(boxedCharValue, obj.getBoxedCharValue()); + assertEquals(jsonObjectDataObject, obj.getJsonObjectDataObjectValue()); + assertEquals(stringDataObject, obj.getStringDataObjectValue()); + Assert.assertEquals(buffer, obj.getBufferValue()); + Assert.assertEquals(jsonObject, obj.getJsonObjectValue()); + Assert.assertEquals(jsonArray, obj.getJsonArrayValue()); + Assert.assertEquals(httpMethod, obj.getEnumValue()); + Assert.assertEquals(methodMapped, obj.getMethodMappedValue()); + Assert.assertEquals(enumMapped, obj.getCustomEnumValue()); + Assert.assertEquals(autoMapped.toJson(), obj.getAutoMappedValue().toJson()); + Assert.assertEquals(autoMappedWithVertxGen.toJson(), obj.getAutoMappedWithVertxGenValue().toJson()); + Assert.assertEquals(Collections.singletonList(stringValue), obj.getStringValueList()); + Assert.assertEquals(Collections.singletonList(boxedBooleanValue), obj.getBoxedBooleanValueList()); + Assert.assertEquals(Collections.singletonList(boxedByteValue), obj.getBoxedByteValueList()); + Assert.assertEquals(Collections.singletonList(boxedShortValue), obj.getBoxedShortValueList()); + Assert.assertEquals(Collections.singletonList(boxedIntValue), obj.getBoxedIntValueList()); + Assert.assertEquals(Collections.singletonList(boxedLongValue), obj.getBoxedLongValueList()); + Assert.assertEquals(Collections.singletonList(boxedFloatValue), obj.getBoxedFloatValueList()); + Assert.assertEquals(Collections.singletonList(boxedDoubleValue), obj.getBoxedDoubleValueList()); + Assert.assertEquals(Collections.singletonList(boxedCharValue), obj.getBoxedCharValueList()); + Assert.assertEquals(Collections.singletonList(jsonObjectDataObject), obj.getJsonObjectDataObjectValueList()); + Assert.assertEquals(Collections.singletonList(stringDataObject), obj.getStringDataObjectValueList()); + Assert.assertEquals(Collections.singletonList(buffer), obj.getBufferValueList()); + Assert.assertEquals(Collections.singletonList(jsonObject), obj.getJsonObjectValueList()); + Assert.assertEquals(Collections.singletonList(jsonArray), obj.getJsonArrayValueList()); + Assert.assertEquals(Collections.singletonList(httpMethod), obj.getEnumValueList()); + Assert.assertEquals(Collections.singletonList(methodMapped), obj.getMethodMappedValueList()); + Assert.assertEquals(list, obj.getObjectValueList()); + Assert.assertEquals(Collections.singletonList(enumMapped), obj.getCustomEnumValueList()); + Assert.assertEquals(Collections.singletonList(autoMapped), obj.getAutoMappedValueList()); + Assert.assertEquals(Collections.singletonList(autoMappedWithVertxGen), obj.getAutoMappedWithVertxGenValueList()); + Assert.assertEquals(Collections.singleton(stringValue), obj.getStringValueSet()); + Assert.assertEquals(Collections.singleton(boxedBooleanValue), obj.getBoxedBooleanValueSet()); + Assert.assertEquals(Collections.singleton(boxedByteValue), obj.getBoxedByteValueSet()); + Assert.assertEquals(Collections.singleton(boxedShortValue), obj.getBoxedShortValueSet()); + Assert.assertEquals(Collections.singleton(boxedIntValue), obj.getBoxedIntValueSet()); + Assert.assertEquals(Collections.singleton(boxedLongValue), obj.getBoxedLongValueSet()); + Assert.assertEquals(Collections.singleton(boxedFloatValue), obj.getBoxedFloatValueSet()); + Assert.assertEquals(Collections.singleton(boxedDoubleValue), obj.getBoxedDoubleValueSet()); + Assert.assertEquals(Collections.singleton(boxedCharValue), obj.getBoxedCharValueSet()); + Assert.assertEquals(Collections.singleton(jsonObjectDataObject), obj.getJsonObjectDataObjectValueSet()); + Assert.assertEquals(Collections.singleton(stringDataObject), obj.getStringDataObjectValueSet()); + Assert.assertEquals(Collections.singleton(buffer), obj.getBufferValueSet()); + Assert.assertEquals(Collections.singleton(jsonObject), obj.getJsonObjectValueSet()); + Assert.assertEquals(Collections.singleton(jsonArray), obj.getJsonArrayValueSet()); + Assert.assertEquals(Collections.singleton(httpMethod), obj.getEnumValueSet()); + Assert.assertEquals(Collections.singleton(methodMapped), obj.getMethodMappedValueSet()); + Assert.assertEquals(new LinkedHashSet<>(list), obj.getObjectValueSet()); + Assert.assertEquals(Collections.singleton(enumMapped), obj.getCustomEnumValueSet()); + Assert.assertEquals(Collections.singleton(autoMapped), obj.getAutoMappedValueSet()); + Assert.assertEquals(Collections.singleton(autoMappedWithVertxGen), obj.getAutoMappedWithVertxGenValueSet()); Assert.assertEquals(Collections.singletonList(stringValue), obj.getAddedStringValues()); Assert.assertEquals(Collections.singletonList(boxedBooleanValue), obj.getAddedBoxedBooleanValues()); Assert.assertEquals(Collections.singletonList(boxedByteValue), obj.getAddedBoxedByteValues()); @@ -273,15 +293,17 @@ public void testJsonToDataObject() throws Exception { Assert.assertEquals(Collections.singletonList(boxedFloatValue), obj.getAddedBoxedFloatValues()); Assert.assertEquals(Collections.singletonList(boxedDoubleValue), obj.getAddedBoxedDoubleValues()); Assert.assertEquals(Collections.singletonList(boxedCharValue), obj.getAddedBoxedCharValues()); - Assert.assertEquals(Collections.singletonList(jsonObjectDataObject), obj.getAddedJsonObjectDataObjects()); - Assert.assertEquals(Collections.singletonList(stringDataObject), obj.getAddedStringDataObjects()); - Assert.assertEquals(Collections.singletonList(buffer), obj.getAddedBuffers()); - Assert.assertEquals(Collections.singletonList(jsonObject), obj.getAddedJsonObjects()); - Assert.assertEquals(Collections.singletonList(jsonArray), obj.getAddedJsonArrays()); - Assert.assertEquals(Collections.singletonList(httpMethod), obj.getAddedHttpMethods()); - Assert.assertEquals(Collections.singletonList(methodMapped), obj.getAddedMethodMappeds()); - Assert.assertEquals(list, obj.getAddedObjects()); - Assert.assertEquals(Collections.singletonList(enumMapped), obj.getAddedEnumMappeds()); + Assert.assertEquals(Collections.singletonList(jsonObjectDataObject), obj.getAddedJsonObjectDataObjectValues()); + Assert.assertEquals(Collections.singletonList(stringDataObject), obj.getAddedStringDataObjectValues()); + Assert.assertEquals(Collections.singletonList(buffer), obj.getAddedBufferValues()); + Assert.assertEquals(Collections.singletonList(jsonObject), obj.getAddedJsonObjectValues()); + Assert.assertEquals(Collections.singletonList(jsonArray), obj.getAddedJsonArrayValues()); + Assert.assertEquals(Collections.singletonList(httpMethod), obj.getAddedEnumValues()); + Assert.assertEquals(Collections.singletonList(methodMapped), obj.getAddedMethodMappedValues()); + Assert.assertEquals(list, obj.getAddedObjectValues()); + Assert.assertEquals(Collections.singletonList(enumMapped), obj.getAddedCustomEnumValues()); + Assert.assertEquals(Collections.singletonList(autoMapped), obj.getAddedAutoMappedValues()); + Assert.assertEquals(Collections.singletonList(autoMappedWithVertxGen), obj.getAddedAutoMappedWithVertxGenValues()); Assert.assertEquals(Collections.singletonMap(key, stringValue), obj.getStringValueMap()); Assert.assertEquals(Collections.singletonMap(key, boxedBooleanValue), obj.getBoxedBooleanValueMap()); Assert.assertEquals(Collections.singletonMap(key, boxedByteValue), obj.getBoxedByteValueMap()); @@ -291,15 +313,17 @@ public void testJsonToDataObject() throws Exception { Assert.assertEquals(Collections.singletonMap(key, boxedFloatValue), obj.getBoxedFloatValueMap()); Assert.assertEquals(Collections.singletonMap(key, boxedDoubleValue), obj.getBoxedDoubleValueMap()); Assert.assertEquals(Collections.singletonMap(key, boxedCharValue), obj.getBoxedCharValueMap()); - Assert.assertEquals(Collections.singletonMap(key, jsonObjectDataObject), obj.getJsonObjectDataObjectMap()); - Assert.assertEquals(Collections.singletonMap(key, stringDataObject), obj.getStringDataObjectMap()); - Assert.assertEquals(Collections.singletonMap(key, buffer), obj.getBufferMap()); - Assert.assertEquals(Collections.singletonMap(key, jsonObject), obj.getJsonObjectMap()); - Assert.assertEquals(Collections.singletonMap(key, jsonArray), obj.getJsonArrayMap()); - Assert.assertEquals(Collections.singletonMap(key, httpMethod), obj.getHttpMethodMap()); - Assert.assertEquals(Collections.singletonMap(key, methodMapped), obj.getMethodMappedMap()); - Assert.assertEquals(map, obj.getObjectMap()); - Assert.assertEquals(Collections.singletonMap(key, enumMapped), obj.getEnumMappedMap()); + Assert.assertEquals(Collections.singletonMap(key, jsonObjectDataObject), obj.getJsonObjectDataObjectValueMap()); + Assert.assertEquals(Collections.singletonMap(key, stringDataObject), obj.getStringDataObjectValueMap()); + Assert.assertEquals(Collections.singletonMap(key, buffer), obj.getBufferValueMap()); + Assert.assertEquals(Collections.singletonMap(key, jsonObject), obj.getJsonObjectValueMap()); + Assert.assertEquals(Collections.singletonMap(key, jsonArray), obj.getJsonArrayValueMap()); + Assert.assertEquals(Collections.singletonMap(key, httpMethod), obj.getEnumValueMap()); + Assert.assertEquals(Collections.singletonMap(key, methodMapped), obj.getMethodMappedValueMap()); + Assert.assertEquals(map, obj.getObjectValueMap()); + Assert.assertEquals(Collections.singletonMap(key, enumMapped), obj.getCustomEnumValueMap()); + Assert.assertEquals(Collections.singletonMap(key, autoMapped), obj.getAutoMappedValueMap()); + Assert.assertEquals(Collections.singletonMap(key, autoMappedWithVertxGen), obj.getAutoMappedWithVertxGenValueMap()); Assert.assertEquals(Collections.singletonMap(key, stringValue), obj.getKeyedStringValues()); Assert.assertEquals(Collections.singletonMap(key, boxedBooleanValue), obj.getKeyedBoxedBooleanValues()); Assert.assertEquals(Collections.singletonMap(key, boxedByteValue), obj.getKeyedBoxedByteValues()); @@ -316,8 +340,10 @@ public void testJsonToDataObject() throws Exception { Assert.assertEquals(Collections.singletonMap(key, jsonArray), obj.getKeyedJsonArrayValues()); Assert.assertEquals(Collections.singletonMap(key, httpMethod), obj.getKeyedEnumValues()); Assert.assertEquals(Collections.singletonMap(key, methodMapped), obj.getKeyedMethodMappedValues()); - Assert.assertEquals(map, obj.getObjectMap()); - Assert.assertEquals(Collections.singletonMap(key, enumMapped), obj.getKeyedEnumMappedValues()); + Assert.assertEquals(map, obj.getObjectValueMap()); + Assert.assertEquals(Collections.singletonMap(key, enumMapped), obj.getKeyedCustomEnumValues()); + Assert.assertEquals(Collections.singletonMap(key, autoMapped), obj.getKeyedAutoMappedValues()); + Assert.assertEquals(Collections.singletonMap(key, autoMappedWithVertxGen), obj.getKeyedAutoMappedWithVertxGenValues()); // Sometimes json can use java collections so test it runs fine in this case // json = new JsonObject(); @@ -339,66 +365,66 @@ public void testEmptyJsonToDataObject() { TestDataObject obj = new TestDataObject(); TestDataObjectConverter.fromJson(json, obj); - Assert.assertEquals(null, obj.getString()); - Assert.assertEquals(false, obj.isPrimitiveBoolean()); - Assert.assertEquals(0, obj.getPrimitiveByte()); - Assert.assertEquals(0, obj.getPrimitiveShort()); - Assert.assertEquals(0, obj.getPrimitiveInt()); - Assert.assertEquals(0l, obj.getPrimitiveLong()); - Assert.assertEquals(0f, obj.getPrimitiveFloat(), 0); - Assert.assertEquals(0d, obj.getPrimitiveDouble(), 0); - Assert.assertEquals((char)0, obj.getPrimitiveChar()); - Assert.assertEquals(null, obj.isBoxedBoolean()); - Assert.assertEquals(null, obj.getBoxedByte()); - Assert.assertEquals(null, obj.getBoxedShort()); - Assert.assertEquals(null, obj.getBoxedInt()); - Assert.assertEquals(null, obj.getBoxedLong()); - Assert.assertEquals(null, obj.getBoxedFloat()); - Assert.assertEquals(null, obj.getBoxedDouble()); - Assert.assertEquals(null, obj.getBoxedChar()); - assertEquals(null, obj.getJsonObjectDataObject()); - assertEquals(null, obj.getStringDataObject()); - Assert.assertEquals(null, obj.getBuffer()); - Assert.assertEquals(null, obj.getJsonObject()); - Assert.assertEquals(null, obj.getJsonArray()); - Assert.assertEquals(null, obj.getMethodMapped()); - Assert.assertEquals(null, obj.getStringList()); - Assert.assertEquals(null, obj.getEnumMapped()); - Assert.assertEquals(null, obj.getBoxedBooleanList()); - Assert.assertEquals(null, obj.getBoxedByteList()); - Assert.assertEquals(null, obj.getBoxedShortList()); - Assert.assertEquals(null, obj.getBoxedIntList()); - Assert.assertEquals(null, obj.getBoxedLongList()); - Assert.assertEquals(null, obj.getBoxedFloatList()); - Assert.assertEquals(null, obj.getBoxedDoubleList()); - Assert.assertEquals(null, obj.getBoxedCharList()); - Assert.assertEquals(null, obj.getJsonObjectDataObjectList()); - Assert.assertEquals(null, obj.getStringDataObjectList()); - Assert.assertEquals(null, obj.getBufferList()); - Assert.assertEquals(null, obj.getJsonObjectList()); - Assert.assertEquals(null, obj.getJsonArrayList()); - Assert.assertEquals(null, obj.getHttpMethodList()); - Assert.assertEquals(null, obj.getMethodMappedList()); - Assert.assertEquals(null, obj.getObjectList()); - Assert.assertEquals(null, obj.getEnumMappedList()); - Assert.assertEquals(null, obj.getStringSet()); - Assert.assertEquals(null, obj.getBoxedBooleanSet()); - Assert.assertEquals(null, obj.getBoxedByteSet()); - Assert.assertEquals(null, obj.getBoxedShortSet()); - Assert.assertEquals(null, obj.getBoxedIntSet()); - Assert.assertEquals(null, obj.getBoxedLongSet()); - Assert.assertEquals(null, obj.getBoxedFloatSet()); - Assert.assertEquals(null, obj.getBoxedDoubleSet()); - Assert.assertEquals(null, obj.getBoxedCharSet()); - Assert.assertEquals(null, obj.getJsonObjectDataObjectSet()); - Assert.assertEquals(null, obj.getStringDataObjectSet()); - Assert.assertEquals(null, obj.getBufferSet()); - Assert.assertEquals(null, obj.getJsonObjectSet()); - Assert.assertEquals(null, obj.getJsonArraySet()); - Assert.assertEquals(null, obj.getHttpMethodSet()); - Assert.assertEquals(null, obj.getMethodMappedSet()); - Assert.assertEquals(null, obj.getObjectSet()); - Assert.assertEquals(null, obj.getEnumMappedSet()); + Assert.assertEquals(null, obj.getStringValue()); + Assert.assertEquals(false, obj.isPrimitiveBooleanValue()); + Assert.assertEquals(0, obj.getPrimitiveByteValue()); + Assert.assertEquals(0, obj.getPrimitiveShortValue()); + Assert.assertEquals(0, obj.getPrimitiveIntValue()); + Assert.assertEquals(0l, obj.getPrimitiveLongValue()); + Assert.assertEquals(0f, obj.getPrimitiveFloatValue(), 0); + Assert.assertEquals(0d, obj.getPrimitiveDoubleValue(), 0); + Assert.assertEquals((char)0, obj.getPrimitiveCharValue()); + Assert.assertEquals(null, obj.isBoxedBooleanValue()); + Assert.assertEquals(null, obj.getBoxedByteValue()); + Assert.assertEquals(null, obj.getBoxedShortValue()); + Assert.assertEquals(null, obj.getBoxedIntValue()); + Assert.assertEquals(null, obj.getBoxedLongValue()); + Assert.assertEquals(null, obj.getBoxedFloatValue()); + Assert.assertEquals(null, obj.getBoxedDoubleValue()); + Assert.assertEquals(null, obj.getBoxedCharValue()); + assertEquals(null, obj.getJsonObjectDataObjectValue()); + assertEquals(null, obj.getStringDataObjectValue()); + Assert.assertEquals(null, obj.getBufferValue()); + Assert.assertEquals(null, obj.getJsonObjectValue()); + Assert.assertEquals(null, obj.getJsonArrayValue()); + Assert.assertEquals(null, obj.getMethodMappedValue()); + Assert.assertEquals(null, obj.getStringValueList()); + Assert.assertEquals(null, obj.getCustomEnumValue()); + Assert.assertEquals(null, obj.getBoxedBooleanValueList()); + Assert.assertEquals(null, obj.getBoxedByteValueList()); + Assert.assertEquals(null, obj.getBoxedShortValueList()); + Assert.assertEquals(null, obj.getBoxedIntValueList()); + Assert.assertEquals(null, obj.getBoxedLongValueList()); + Assert.assertEquals(null, obj.getBoxedFloatValueList()); + Assert.assertEquals(null, obj.getBoxedDoubleValueList()); + Assert.assertEquals(null, obj.getBoxedCharValueList()); + Assert.assertEquals(null, obj.getJsonObjectDataObjectValueList()); + Assert.assertEquals(null, obj.getStringDataObjectValueList()); + Assert.assertEquals(null, obj.getBufferValueList()); + Assert.assertEquals(null, obj.getJsonObjectValueList()); + Assert.assertEquals(null, obj.getJsonArrayValueList()); + Assert.assertEquals(null, obj.getEnumValueList()); + Assert.assertEquals(null, obj.getMethodMappedValueList()); + Assert.assertEquals(null, obj.getObjectValueList()); + Assert.assertEquals(null, obj.getCustomEnumValueList()); + Assert.assertEquals(null, obj.getStringValueSet()); + Assert.assertEquals(null, obj.getBoxedBooleanValueSet()); + Assert.assertEquals(null, obj.getBoxedByteValueSet()); + Assert.assertEquals(null, obj.getBoxedShortValueSet()); + Assert.assertEquals(null, obj.getBoxedIntValueSet()); + Assert.assertEquals(null, obj.getBoxedLongValueSet()); + Assert.assertEquals(null, obj.getBoxedFloatValueSet()); + Assert.assertEquals(null, obj.getBoxedDoubleValueSet()); + Assert.assertEquals(null, obj.getBoxedCharValueSet()); + Assert.assertEquals(null, obj.getJsonObjectDataObjectValueSet()); + Assert.assertEquals(null, obj.getStringDataObjectValueSet()); + Assert.assertEquals(null, obj.getBufferValueSet()); + Assert.assertEquals(null, obj.getJsonObjectValueSet()); + Assert.assertEquals(null, obj.getJsonArrayValueSet()); + Assert.assertEquals(null, obj.getEnumValueSet()); + Assert.assertEquals(null, obj.getMethodMappedValueSet()); + Assert.assertEquals(null, obj.getObjectValueSet()); + Assert.assertEquals(null, obj.getCustomEnumValueSet()); Assert.assertEquals(Collections.emptyList(), obj.getAddedStringValues()); Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedBooleanValues()); Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedByteValues()); @@ -408,15 +434,15 @@ public void testEmptyJsonToDataObject() { Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedFloatValues()); Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedDoubleValues()); Assert.assertEquals(Collections.emptyList(), obj.getAddedBoxedCharValues()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonObjectDataObjects()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedStringDataObjects()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedBuffers()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonObjects()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonArrays()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedHttpMethods()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedMethodMappeds()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedObjects()); - Assert.assertEquals(Collections.emptyList(), obj.getAddedEnumMappeds()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonObjectDataObjectValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedStringDataObjectValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedBufferValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonObjectValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedJsonArrayValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedEnumValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedMethodMappedValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedObjectValues()); + Assert.assertEquals(Collections.emptyList(), obj.getAddedCustomEnumValues()); Assert.assertEquals(null, obj.getStringValueMap()); Assert.assertEquals(null, obj.getBoxedBooleanValueMap()); Assert.assertEquals(null, obj.getBoxedByteValueMap()); @@ -426,15 +452,15 @@ public void testEmptyJsonToDataObject() { Assert.assertEquals(null, obj.getBoxedFloatValueMap()); Assert.assertEquals(null, obj.getBoxedDoubleValueMap()); Assert.assertEquals(null, obj.getBoxedCharValueMap()); - Assert.assertEquals(null, obj.getJsonObjectDataObjectMap()); - Assert.assertEquals(null, obj.getStringDataObjectMap()); - Assert.assertEquals(null, obj.getBufferMap()); - Assert.assertEquals(null, obj.getJsonObjectMap()); - Assert.assertEquals(null, obj.getJsonArrayMap()); - Assert.assertEquals(null, obj.getHttpMethodMap()); - Assert.assertEquals(null, obj.getMethodMappedMap()); - Assert.assertEquals(null, obj.getObjectMap()); - Assert.assertEquals(null, obj.getEnumMappedMap()); + Assert.assertEquals(null, obj.getJsonObjectDataObjectValueMap()); + Assert.assertEquals(null, obj.getStringDataObjectValueMap()); + Assert.assertEquals(null, obj.getBufferValueMap()); + Assert.assertEquals(null, obj.getJsonObjectValueMap()); + Assert.assertEquals(null, obj.getJsonArrayValueMap()); + Assert.assertEquals(null, obj.getEnumValueMap()); + Assert.assertEquals(null, obj.getMethodMappedValueMap()); + Assert.assertEquals(null, obj.getObjectValueMap()); + Assert.assertEquals(null, obj.getCustomEnumValueMap()); } @Test @@ -466,6 +492,8 @@ public void testDataObjectToJson() throws Exception { ZonedDateTime dateTime = ZonedDateTime.now(); Locale uri = new Locale("en"); TestCustomEnum testCustomEnum = TestCustomEnum.DEV; + AutoMapped autoMapped = AutoMapped.of("vertx.io", 80); + AutoMappedWithVertxGen autoMappedWithVertxGen = AutoMappedWithVertxGen.of("vertx.io", 80); Map map = new HashMap<>(); map.put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(20)); @@ -477,68 +505,74 @@ public void testDataObjectToJson() throws Exception { list.add(TestUtils.randomInt()); TestDataObject obj = new TestDataObject(); - obj.setString(stringValue); - obj.setPrimitiveBoolean(booleanValue); - obj.setPrimitiveByte(byteValue); - obj.setPrimitiveShort(shortValue); - obj.setPrimitiveInt(intValue); - obj.setPrimitiveLong(longValue); - obj.setPrimitiveFloat(floatValue); - obj.setPrimitiveDouble(doubleValue); - obj.setPrimitiveChar(charValue); - obj.setBoxedBoolean(boxedBooleanValue); - obj.setBoxedByte(boxedByteValue); - obj.setBoxedShort(boxedShortValue); - obj.setBoxedInt(boxedIntValue); - obj.setBoxedLong(boxedLongValue); - obj.setBoxedFloat(boxedFloatValue); - obj.setBoxedDouble(boxedDoubleValue); - obj.setBoxedChar(boxedCharValue); - obj.setJsonObjectDataObject(jsonObjectDataObject); - obj.setStringDataObject(stringDataObject); - obj.setBuffer(buffer); - obj.setJsonObject(jsonObject); - obj.setJsonArray(jsonArray); - obj.setHttpMethod(httpMethod); - obj.setMethodMapped(dateTime); - obj.setEnumMapped(testCustomEnum); - obj.setStringList(Collections.singletonList(stringValue)); - obj.setBoxedBooleanList(Collections.singletonList(boxedBooleanValue)); - obj.setBoxedByteList(Collections.singletonList(boxedByteValue)); - obj.setBoxedShortList(Collections.singletonList(boxedShortValue)); - obj.setBoxedIntList(Collections.singletonList(boxedIntValue)); - obj.setBoxedLongList(Collections.singletonList(boxedLongValue)); - obj.setBoxedFloatList(Collections.singletonList(boxedFloatValue)); - obj.setBoxedDoubleList(Collections.singletonList(boxedDoubleValue)); - obj.setBoxedCharList(Collections.singletonList(boxedCharValue)); - obj.setJsonObjectDataObjectList(Collections.singletonList(jsonObjectDataObject)); - obj.setStringDataObjectList(Collections.singletonList(stringDataObject)); - obj.setBufferList(Collections.singletonList(buffer)); - obj.setJsonObjectList(Collections.singletonList(jsonObject)); - obj.setJsonArrayList(Collections.singletonList(jsonArray)); - obj.setHttpMethodList(Collections.singletonList(httpMethod)); - obj.setMethodMappedList(Collections.singletonList(dateTime)); - obj.setObjectList(list); - obj.setEnumMappedList(Collections.singletonList(testCustomEnum)); + obj.setStringValue(stringValue); + obj.setPrimitiveBooleanValue(booleanValue); + obj.setPrimitiveByteValue(byteValue); + obj.setPrimitiveShortValue(shortValue); + obj.setPrimitiveIntValue(intValue); + obj.setPrimitiveLongValue(longValue); + obj.setPrimitiveFloatValue(floatValue); + obj.setPrimitiveDoubleValue(doubleValue); + obj.setPrimitiveCharValue(charValue); + obj.setBoxedBooleanValue(boxedBooleanValue); + obj.setBoxedByteValue(boxedByteValue); + obj.setBoxedShortValue(boxedShortValue); + obj.setBoxedIntValue(boxedIntValue); + obj.setBoxedLongValue(boxedLongValue); + obj.setBoxedFloatValue(boxedFloatValue); + obj.setBoxedDoubleValue(boxedDoubleValue); + obj.setBoxedCharValue(boxedCharValue); + obj.setJsonObjectDataObjectValue(jsonObjectDataObject); + obj.setStringDataObjectValue(stringDataObject); + obj.setBufferValue(buffer); + obj.setJsonObjectValue(jsonObject); + obj.setJsonArrayValue(jsonArray); + obj.setEnumValue(httpMethod); + obj.setMethodMappedValue(dateTime); + obj.setCustomEnumValue(testCustomEnum); + obj.setAutoMappedValue(autoMapped); + obj.setAutoMappedWithVertxGenValue(autoMappedWithVertxGen); + obj.setStringValueList(Collections.singletonList(stringValue)); + obj.setBoxedBooleanValueList(Collections.singletonList(boxedBooleanValue)); + obj.setBoxedByteValueList(Collections.singletonList(boxedByteValue)); + obj.setBoxedShortValueList(Collections.singletonList(boxedShortValue)); + obj.setBoxedIntValueList(Collections.singletonList(boxedIntValue)); + obj.setBoxedLongValueList(Collections.singletonList(boxedLongValue)); + obj.setBoxedFloatValueList(Collections.singletonList(boxedFloatValue)); + obj.setBoxedDoubleValueList(Collections.singletonList(boxedDoubleValue)); + obj.setBoxedCharValueList(Collections.singletonList(boxedCharValue)); + obj.setJsonObjectDataObjectValueList(Collections.singletonList(jsonObjectDataObject)); + obj.setStringDataObjectValueList(Collections.singletonList(stringDataObject)); + obj.setBufferValueList(Collections.singletonList(buffer)); + obj.setJsonObjectValueList(Collections.singletonList(jsonObject)); + obj.setJsonArrayValueList(Collections.singletonList(jsonArray)); + obj.setEnumValueList(Collections.singletonList(httpMethod)); + obj.setMethodMappedValueList(Collections.singletonList(dateTime)); + obj.setObjectValueList(list); + obj.setCustomEnumValueList(Collections.singletonList(testCustomEnum)); + obj.setAutoMappedValueList(Collections.singletonList(autoMapped)); + obj.setAutoMappedWithVertxGenValueList(Collections.singletonList(autoMappedWithVertxGen)); obj.setStringValueMap(Collections.singletonMap(key, stringValue)); - obj.setStringSet(Collections.singleton(stringValue)); - obj.setBoxedBooleanSet(Collections.singleton(boxedBooleanValue)); - obj.setBoxedByteSet(Collections.singleton(boxedByteValue)); - obj.setBoxedShortSet(Collections.singleton(boxedShortValue)); - obj.setBoxedIntSet(Collections.singleton(boxedIntValue)); - obj.setBoxedLongSet(Collections.singleton(boxedLongValue)); - obj.setBoxedFloatSet(Collections.singleton(boxedFloatValue)); - obj.setBoxedDoubleSet(Collections.singleton(boxedDoubleValue)); - obj.setBoxedCharSet(Collections.singleton(boxedCharValue)); - obj.setJsonObjectDataObjectSet(Collections.singleton(jsonObjectDataObject)); - obj.setStringDataObjectSet(Collections.singleton(stringDataObject)); - obj.setBufferSet(Collections.singleton(buffer)); - obj.setJsonObjectSet(Collections.singleton(jsonObject)); - obj.setJsonArraySet(Collections.singleton(jsonArray)); - obj.setHttpMethodSet(Collections.singleton(httpMethod)); - obj.setMethodMappedSet(Collections.singleton(dateTime)); - obj.setObjectSet(new LinkedHashSet<>(list)); - obj.setEnumMappedSet(Collections.singleton(testCustomEnum)); + obj.setStringValueSet(Collections.singleton(stringValue)); + obj.setBoxedBooleanValueSet(Collections.singleton(boxedBooleanValue)); + obj.setBoxedByteValueSet(Collections.singleton(boxedByteValue)); + obj.setBoxedShortValueSet(Collections.singleton(boxedShortValue)); + obj.setBoxedIntValueSet(Collections.singleton(boxedIntValue)); + obj.setBoxedLongValueSet(Collections.singleton(boxedLongValue)); + obj.setBoxedFloatValueSet(Collections.singleton(boxedFloatValue)); + obj.setBoxedDoubleValueSet(Collections.singleton(boxedDoubleValue)); + obj.setBoxedCharValueSet(Collections.singleton(boxedCharValue)); + obj.setJsonObjectDataObjectValueSet(Collections.singleton(jsonObjectDataObject)); + obj.setStringDataObjectValueSet(Collections.singleton(stringDataObject)); + obj.setBufferValueSet(Collections.singleton(buffer)); + obj.setJsonObjectValueSet(Collections.singleton(jsonObject)); + obj.setJsonArrayValueSet(Collections.singleton(jsonArray)); + obj.setEnumValueSet(Collections.singleton(httpMethod)); + obj.setMethodMappedValueSet(Collections.singleton(dateTime)); + obj.setObjectValueSet(new LinkedHashSet<>(list)); + obj.setCustomEnumValueSet(Collections.singleton(testCustomEnum)); + obj.setAutoMappedValueSet(Collections.singleton(autoMapped)); + obj.setAutoMappedWithVertxGenValueSet(Collections.singleton(autoMappedWithVertxGen)); obj.setBoxedBooleanValueMap(Collections.singletonMap(key, boxedBooleanValue)); obj.setBoxedByteValueMap(Collections.singletonMap(key, boxedByteValue)); obj.setBoxedShortValueMap(Collections.singletonMap(key, boxedShortValue)); @@ -547,15 +581,17 @@ public void testDataObjectToJson() throws Exception { obj.setBoxedFloatValueMap(Collections.singletonMap(key, boxedFloatValue)); obj.setBoxedDoubleValueMap(Collections.singletonMap(key, boxedDoubleValue)); obj.setBoxedCharValueMap(Collections.singletonMap(key, boxedCharValue)); - obj.setJsonObjectDataObjectMap(Collections.singletonMap(key, jsonObjectDataObject)); - obj.setStringDataObjectMap(Collections.singletonMap(key, stringDataObject)); - obj.setBufferMap(Collections.singletonMap(key, buffer)); - obj.setJsonObjectMap(Collections.singletonMap(key, jsonObject)); - obj.setJsonArrayMap(Collections.singletonMap(key, jsonArray)); - obj.setHttpMethodMap(Collections.singletonMap(key, httpMethod)); - obj.setMethodMappedMap(Collections.singletonMap(key, dateTime)); - obj.setObjectMap(map); - obj.setEnumMappedMap(Collections.singletonMap(key, testCustomEnum)); + obj.setJsonObjectDataObjectValueMap(Collections.singletonMap(key, jsonObjectDataObject)); + obj.setStringDataObjectValueMap(Collections.singletonMap(key, stringDataObject)); + obj.setBufferValueMap(Collections.singletonMap(key, buffer)); + obj.setJsonObjectValueMap(Collections.singletonMap(key, jsonObject)); + obj.setJsonArrayValueMap(Collections.singletonMap(key, jsonArray)); + obj.setEnumValueMap(Collections.singletonMap(key, httpMethod)); + obj.setMethodMappedValueMap(Collections.singletonMap(key, dateTime)); + obj.setObjectValueMap(map); + obj.setCustomEnumValueMap(Collections.singletonMap(key, testCustomEnum)); + obj.setAutoMappedValueMap(Collections.singletonMap(key, autoMapped)); + obj.setAutoMappedWithVertxGenValueMap(Collections.singletonMap(key, autoMappedWithVertxGen)); obj.addKeyedStringValue(key, stringValue); obj.addKeyedBoxedBooleanValue(key, boxedBooleanValue); obj.addKeyedBoxedByteValue(key, boxedByteValue); @@ -573,76 +609,84 @@ public void testDataObjectToJson() throws Exception { obj.addKeyedEnumValue(key, httpMethod); obj.addKeyedMethodMappedValue(key, dateTime); map.forEach(obj::addKeyedObjectValue); - obj.addKeyedEnumMappedValue(key, testCustomEnum); + obj.addKeyedCustomEnumValue(key, testCustomEnum); + obj.addKeyedAutoMappedValue(key, autoMapped); + obj.addKeyedAutoMappedWithVertxGenValue(key, autoMappedWithVertxGen); Map json = new HashMap<>(); TestDataObjectConverter.toJson(obj, json); - assertEquals(stringValue, json.get("string")); - assertEquals(booleanValue, json.get("primitiveBoolean")); - assertEquals(byteValue, (byte)json.get("primitiveByte")); - assertEquals(shortValue, (short)json.get("primitiveShort")); - assertEquals(intValue, (int)json.get("primitiveInt")); - assertEquals(longValue, (long)json.get("primitiveLong")); - assertEquals(floatValue, (float)json.get("primitiveFloat"), 0.001); - assertEquals(doubleValue, (double)json.get("primitiveDouble"), 0.001); - assertEquals(Character.toString(charValue), json.get("primitiveChar")); - assertEquals(boxedBooleanValue, json.get("boxedBoolean")); - assertEquals((byte)boxedByteValue, (byte)json.get("boxedByte")); - assertEquals((short)boxedShortValue, (short)json.get("boxedShort")); - assertEquals(boxedIntValue, json.get("boxedInt")); - assertEquals(boxedLongValue, json.get("boxedLong")); - assertEquals(boxedFloatValue, (float)json.get("boxedFloat"), 0.001); - assertEquals(boxedDoubleValue, (double) json.get("boxedDouble"), 0.001); - assertEquals(Character.toString(boxedCharValue), json.get("boxedChar")); - assertEquals(jsonObjectDataObject.toJson(), json.get("jsonObjectDataObject")); - assertEquals(stringDataObject.toJson(), json.get("stringDataObject")); - assertEquals(buffer, Buffer.buffer(JsonUtil.BASE64_DECODER.decode((String)json.get("buffer")))); - assertEquals(jsonObject, json.get("jsonObject")); - assertEquals(jsonArray, json.get("jsonArray")); - assertEquals(httpMethod.name(), json.get("httpMethod")); - assertEquals(dateTime.toString(), json.get("methodMapped")); - assertEquals(testCustomEnum.getShortName(), json.get("enumMapped")); - assertEquals(new JsonArray().add(stringValue), json.get("stringList")); - assertEquals(new JsonArray().add(boxedBooleanValue), json.get("boxedBooleanList")); - assertEquals(new JsonArray().add(boxedByteValue), json.get("boxedByteList")); - assertEquals(new JsonArray().add(boxedShortValue), json.get("boxedShortList")); - assertEquals(new JsonArray().add(boxedIntValue), json.get("boxedIntList")); - assertEquals(new JsonArray().add(boxedLongValue), json.get("boxedLongList")); - assertEquals(1, ((JsonArray)json.get("boxedFloatList")).size()); - assertEquals(boxedFloatValue, (float)((JsonArray)json.get("boxedFloatList")).getValue(0), 0.001); - assertEquals(1, ((JsonArray)json.get("boxedDoubleList")).size()); - assertEquals(boxedDoubleValue, (double)((JsonArray)json.get("boxedDoubleList")).getValue(0), 0.001); - assertEquals(new JsonArray().add(Character.toString(boxedCharValue)), json.get("boxedCharList")); - assertEquals(new JsonArray().add(jsonObjectDataObject.toJson()), json.get("jsonObjectDataObjectList")); - assertEquals(new JsonArray().add(stringDataObject.toJson()), json.get("stringDataObjectList")); - assertEquals(JsonUtil.BASE64_ENCODER.encodeToString(buffer.getBytes()), ((JsonArray)json.get("bufferList")).getValue(0)); - assertEquals(new JsonArray().add(jsonObject), json.get("jsonObjectList")); - assertEquals(new JsonArray().add(jsonArray), json.get("jsonArrayList")); - assertEquals(new JsonArray().add(httpMethod.name()), json.get("httpMethodList")); - assertEquals(new JsonArray().add(dateTime.toString()), json.get("methodMappedList")); - assertEquals(new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)), json.get("objectList")); - assertEquals(new JsonArray().add(testCustomEnum.getShortName()), json.get("enumMappedList")); - assertEquals(new JsonArray().add(stringValue), json.get("stringSet")); - assertEquals(new JsonArray().add(boxedBooleanValue), json.get("boxedBooleanSet")); - assertEquals(new JsonArray().add(boxedByteValue), json.get("boxedByteSet")); - assertEquals(new JsonArray().add(boxedShortValue), json.get("boxedShortSet")); - assertEquals(new JsonArray().add(boxedIntValue), json.get("boxedIntSet")); - assertEquals(new JsonArray().add(boxedLongValue), json.get("boxedLongSet")); - assertEquals(1, ((JsonArray)json.get("boxedFloatSet")).size()); - assertEquals(boxedFloatValue, (float)((JsonArray)json.get("boxedFloatSet")).getValue(0), 0.001); - assertEquals(1, ((JsonArray)json.get("boxedDoubleSet")).size()); - assertEquals(boxedDoubleValue, (double)((JsonArray)json.get("boxedDoubleSet")).getValue(0), 0.001); - assertEquals(new JsonArray().add(Character.toString(boxedCharValue)), json.get("boxedCharSet")); - assertEquals(new JsonArray().add(jsonObjectDataObject.toJson()), json.get("jsonObjectDataObjectSet")); - assertEquals(new JsonArray().add(stringDataObject.toJson()), json.get("stringDataObjectSet")); - assertEquals(JsonUtil.BASE64_ENCODER.encodeToString(buffer.getBytes()), ((JsonArray)json.get("bufferSet")).getValue(0)); - assertEquals(new JsonArray().add(jsonObject), json.get("jsonObjectSet")); - assertEquals(new JsonArray().add(jsonArray), json.get("jsonArraySet")); - assertEquals(new JsonArray().add(httpMethod.name()), json.get("httpMethodSet")); - assertEquals(new JsonArray().add(dateTime.toString()), json.get("methodMappedSet")); - assertEquals(new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)), json.get("objectSet")); - assertEquals(new JsonArray().add(testCustomEnum.getShortName()), json.get("enumMappedSet")); + assertEquals(stringValue, json.get("stringValue")); + assertEquals(booleanValue, json.get("primitiveBooleanValue")); + assertEquals(byteValue, (byte)json.get("primitiveByteValue")); + assertEquals(shortValue, (short)json.get("primitiveShortValue")); + assertEquals(intValue, (int)json.get("primitiveIntValue")); + assertEquals(longValue, (long)json.get("primitiveLongValue")); + assertEquals(floatValue, (float)json.get("primitiveFloatValue"), 0.001); + assertEquals(doubleValue, (double)json.get("primitiveDoubleValue"), 0.001); + assertEquals(Character.toString(charValue), json.get("primitiveCharValue")); + assertEquals(boxedBooleanValue, json.get("boxedBooleanValue")); + assertEquals((byte)boxedByteValue, (byte)json.get("boxedByteValue")); + assertEquals((short)boxedShortValue, (short)json.get("boxedShortValue")); + assertEquals(boxedIntValue, json.get("boxedIntValue")); + assertEquals(boxedLongValue, json.get("boxedLongValue")); + assertEquals(boxedFloatValue, (float)json.get("boxedFloatValue"), 0.001); + assertEquals(boxedDoubleValue, (double) json.get("boxedDoubleValue"), 0.001); + assertEquals(Character.toString(boxedCharValue), json.get("boxedCharValue")); + assertEquals(jsonObjectDataObject.toJson(), json.get("jsonObjectDataObjectValue")); + assertEquals(stringDataObject.toJson(), json.get("stringDataObjectValue")); + assertEquals(buffer, Buffer.buffer(JsonUtil.BASE64_DECODER.decode((String)json.get("bufferValue")))); + assertEquals(jsonObject, json.get("jsonObjectValue")); + assertEquals(jsonArray, json.get("jsonArrayValue")); + assertEquals(httpMethod.name(), json.get("enumValue")); + assertEquals(dateTime.toString(), json.get("methodMappedValue")); + assertEquals(testCustomEnum.getShortName(), json.get("customEnumValue")); + assertEquals(autoMapped.toJson(), json.get("autoMappedValue")); + assertEquals(autoMappedWithVertxGen.toJson(), json.get("autoMappedWithVertxGenValue")); + assertEquals(new JsonArray().add(stringValue), json.get("stringValueList")); + assertEquals(new JsonArray().add(boxedBooleanValue), json.get("boxedBooleanValueList")); + assertEquals(new JsonArray().add(boxedByteValue), json.get("boxedByteValueList")); + assertEquals(new JsonArray().add(boxedShortValue), json.get("boxedShortValueList")); + assertEquals(new JsonArray().add(boxedIntValue), json.get("boxedIntValueList")); + assertEquals(new JsonArray().add(boxedLongValue), json.get("boxedLongValueList")); + assertEquals(1, ((JsonArray)json.get("boxedFloatValueList")).size()); + assertEquals(boxedFloatValue, (float)((JsonArray)json.get("boxedFloatValueList")).getValue(0), 0.001); + assertEquals(1, ((JsonArray)json.get("boxedDoubleValueList")).size()); + assertEquals(boxedDoubleValue, (double)((JsonArray)json.get("boxedDoubleValueList")).getValue(0), 0.001); + assertEquals(new JsonArray().add(Character.toString(boxedCharValue)), json.get("boxedCharValueList")); + assertEquals(new JsonArray().add(jsonObjectDataObject.toJson()), json.get("jsonObjectDataObjectValueList")); + assertEquals(new JsonArray().add(stringDataObject.toJson()), json.get("stringDataObjectValueList")); + assertEquals(JsonUtil.BASE64_ENCODER.encodeToString(buffer.getBytes()), ((JsonArray)json.get("bufferValueList")).getValue(0)); + assertEquals(new JsonArray().add(jsonObject), json.get("jsonObjectValueList")); + assertEquals(new JsonArray().add(jsonArray), json.get("jsonArrayValueList")); + assertEquals(new JsonArray().add(httpMethod.name()), json.get("enumValueList")); + assertEquals(new JsonArray().add(dateTime.toString()), json.get("methodMappedValueList")); + assertEquals(new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)), json.get("objectValueList")); + assertEquals(new JsonArray().add(testCustomEnum.getShortName()), json.get("customEnumValueList")); + assertEquals(new JsonArray().add(autoMapped.toJson()), json.get("autoMappedValueList")); + assertEquals(new JsonArray().add(autoMappedWithVertxGen.toJson()), json.get("autoMappedWithVertxGenValueList")); + assertEquals(new JsonArray().add(stringValue), json.get("stringValueSet")); + assertEquals(new JsonArray().add(boxedBooleanValue), json.get("boxedBooleanValueSet")); + assertEquals(new JsonArray().add(boxedByteValue), json.get("boxedByteValueSet")); + assertEquals(new JsonArray().add(boxedShortValue), json.get("boxedShortValueSet")); + assertEquals(new JsonArray().add(boxedIntValue), json.get("boxedIntValueSet")); + assertEquals(new JsonArray().add(boxedLongValue), json.get("boxedLongValueSet")); + assertEquals(1, ((JsonArray)json.get("boxedFloatValueSet")).size()); + assertEquals(boxedFloatValue, (float)((JsonArray)json.get("boxedFloatValueSet")).getValue(0), 0.001); + assertEquals(1, ((JsonArray)json.get("boxedDoubleValueSet")).size()); + assertEquals(boxedDoubleValue, (double)((JsonArray)json.get("boxedDoubleValueSet")).getValue(0), 0.001); + assertEquals(new JsonArray().add(Character.toString(boxedCharValue)), json.get("boxedCharValueSet")); + assertEquals(new JsonArray().add(jsonObjectDataObject.toJson()), json.get("jsonObjectDataObjectValueSet")); + assertEquals(new JsonArray().add(stringDataObject.toJson()), json.get("stringDataObjectValueSet")); + assertEquals(JsonUtil.BASE64_ENCODER.encodeToString(buffer.getBytes()), ((JsonArray)json.get("bufferValueSet")).getValue(0)); + assertEquals(new JsonArray().add(jsonObject), json.get("jsonObjectValueSet")); + assertEquals(new JsonArray().add(jsonArray), json.get("jsonArrayValueSet")); + assertEquals(new JsonArray().add(httpMethod.name()), json.get("enumValueSet")); + assertEquals(new JsonArray().add(dateTime.toString()), json.get("methodMappedValueSet")); + assertEquals(new JsonArray().add(list.get(0)).add(list.get(1)).add(list.get(2)), json.get("objectValueSet")); + assertEquals(new JsonArray().add(testCustomEnum.getShortName()), json.get("customEnumValueSet")); + assertEquals(new JsonArray().add(autoMapped.toJson()), json.get("autoMappedValueSet")); + assertEquals(new JsonArray().add(autoMappedWithVertxGen.toJson()), json.get("autoMappedWithVertxGenValueSet")); assertEquals(new JsonObject().put(key, stringValue), json.get("stringValueMap")); assertEquals(new JsonObject().put(key, boxedBooleanValue), json.get("boxedBooleanValueMap")); assertEquals(new JsonObject().put(key, boxedByteValue), json.get("boxedByteValueMap")); @@ -654,15 +698,17 @@ public void testDataObjectToJson() throws Exception { assertEquals(1, ((JsonObject)json.get("boxedDoubleValueMap")).size()); assertEquals(boxedDoubleValue, (double)((JsonObject)json.get("boxedDoubleValueMap")).getValue(key), 0.001); assertEquals(new JsonObject().put(key, Character.toString(boxedCharValue)), json.get("boxedCharValueMap")); - assertEquals(new JsonObject().put(key, jsonObjectDataObject.toJson()), json.get("jsonObjectDataObjectMap")); - assertEquals(new JsonObject().put(key, stringDataObject.toJson()), json.get("stringDataObjectMap")); - assertEquals(JsonUtil.BASE64_ENCODER.encodeToString(buffer.getBytes()), ((JsonObject)json.get("bufferMap")).getValue(key)); - assertEquals(new JsonObject().put(key, jsonObject), json.get("jsonObjectMap")); - assertEquals(new JsonObject().put(key, jsonArray), json.get("jsonArrayMap")); - assertEquals(new JsonObject().put(key, httpMethod.name()), json.get("httpMethodMap")); - assertEquals(new JsonObject().put(key, dateTime.toString()), json.get("methodMappedMap")); - assertEquals(toJson(map), json.get("objectMap")); - assertEquals(new JsonObject().put(key, testCustomEnum.getShortName()), json.get("enumMappedMap")); + assertEquals(new JsonObject().put(key, jsonObjectDataObject.toJson()), json.get("jsonObjectDataObjectValueMap")); + assertEquals(new JsonObject().put(key, stringDataObject.toJson()), json.get("stringDataObjectValueMap")); + assertEquals(JsonUtil.BASE64_ENCODER.encodeToString(buffer.getBytes()), ((JsonObject)json.get("bufferValueMap")).getValue(key)); + assertEquals(new JsonObject().put(key, jsonObject), json.get("jsonObjectValueMap")); + assertEquals(new JsonObject().put(key, jsonArray), json.get("jsonArrayValueMap")); + assertEquals(new JsonObject().put(key, httpMethod.name()), json.get("enumValueMap")); + assertEquals(new JsonObject().put(key, dateTime.toString()), json.get("methodMappedValueMap")); + assertEquals(toJson(map), json.get("objectValueMap")); + assertEquals(new JsonObject().put(key, testCustomEnum.getShortName()), json.get("customEnumValueMap")); + assertEquals(new JsonObject().put(key, autoMapped.toJson()), json.get("autoMappedValueMap")); + assertEquals(new JsonObject().put(key, autoMappedWithVertxGen.toJson()), json.get("autoMappedWithVertxGenValueMap")); assertEquals(new JsonObject().put(key, stringValue), json.get("keyedStringValues")); assertEquals(new JsonObject().put(key, boxedBooleanValue), json.get("keyedBoxedBooleanValues")); assertEquals(new JsonObject().put(key, boxedByteValue), json.get("keyedBoxedByteValues")); @@ -682,7 +728,9 @@ public void testDataObjectToJson() throws Exception { assertEquals(new JsonObject().put(key, httpMethod.name()), json.get("keyedEnumValues")); assertEquals(new JsonObject().put(key, dateTime.toString()), json.get("keyedMethodMappedValues")); assertEquals(toJson(map), json.get("keyedObjectValues")); - assertEquals(new JsonObject().put(key, testCustomEnum.getShortName()), json.get("keyedEnumMappedValues")); + assertEquals(new JsonObject().put(key, testCustomEnum.getShortName()), json.get("keyedCustomEnumValues")); + assertEquals(new JsonObject().put(key, autoMapped.toJson()), json.get("keyedAutoMappedValues")); + assertEquals(new JsonObject().put(key, autoMappedWithVertxGen.toJson()), json.get("keyedAutoMappedWithVertxGenValues")); } @Test @@ -693,67 +741,73 @@ public void testEmptyDataObjectToJson() { Map json = new HashMap<>(); TestDataObjectConverter.toJson(obj, json); - assertEquals(null, json.get("string")); - assertEquals(false, json.get("primitiveBoolean")); - assertEquals(0, (byte)json.get("primitiveByte")); - assertEquals(0, (short)json.get("primitiveShort")); - assertEquals(0, (int)json.get("primitiveInt")); - assertEquals(0L, (long) json.get("primitiveLong")); - assertEquals(0f, (float) json.get("primitiveFloat"), 0); - assertEquals(0d, (double) json.get("primitiveDouble"), 0); - assertEquals(Character.toString((char)0), json.get("primitiveChar")); - assertEquals(null, json.get("boxedBoolean")); - assertEquals(null, json.get("boxedByte")); - assertEquals(null, json.get("boxedShort")); - assertEquals(null, json.get("boxedInt")); - assertEquals(null, json.get("boxedLong")); - assertEquals(null, json.get("boxedFloat")); - assertEquals(null, json.get("boxedDouble")); - assertEquals(null, json.get("boxedChar")); - assertEquals(null, json.get("jsonObjectDataObject")); - assertEquals(null, json.get("stringDataObject")); - assertEquals(null, json.get("buffer")); - assertEquals(null, json.get("jsonObject")); - assertEquals(null, json.get("jsonArray")); - assertEquals(null, json.get("httpMethod")); - assertEquals(null, json.get("methodMapped")); - assertEquals(null, json.get("enumMapped")); - assertEquals(null, json.get("stringList")); - assertEquals(null, json.get("boxedBooleanList")); - assertEquals(null, json.get("boxedByteList")); - assertEquals(null, json.get("boxedShortList")); - assertEquals(null, json.get("boxedIntList")); - assertEquals(null, json.get("boxedLongList")); - assertEquals(null, json.get("boxedFloatList")); - assertEquals(null, json.get("boxedDoubleList")); - assertEquals(null, json.get("boxedCharList")); - assertEquals(null, json.get("jsonObjectDataObjectList")); - assertEquals(null, json.get("stringDataObjectList")); - assertEquals(null, json.get("bufferList")); - assertEquals(null, json.get("jsonObjectList")); - assertEquals(null, json.get("jsonArrayList")); - assertEquals(null, json.get("httpMethodList")); - assertEquals(null, json.get("methodMappedList")); - assertEquals(null, json.get("objectList")); - assertEquals(null, json.get("enumMappedList")); - assertEquals(null, json.get("stringSet")); - assertEquals(null, json.get("boxedBooleanSet")); - assertEquals(null, json.get("boxedByteSet")); - assertEquals(null, json.get("boxedShortSet")); - assertEquals(null, json.get("boxedIntSet")); - assertEquals(null, json.get("boxedLongSet")); - assertEquals(null, json.get("boxedFloatSet")); - assertEquals(null, json.get("boxedDoubleSet")); - assertEquals(null, json.get("boxedCharSet")); - assertEquals(null, json.get("jsonObjectDataObjectSet")); - assertEquals(null, json.get("stringDataObjectSet")); - assertEquals(null, json.get("bufferSet")); - assertEquals(null, json.get("jsonObjectSet")); - assertEquals(null, json.get("jsonArraySet")); - assertEquals(null, json.get("httpMethodSet")); - assertEquals(null, json.get("methodMappedSet")); - assertEquals(null, json.get("objectSet")); - assertEquals(null, json.get("enumMappedSet")); + assertEquals(null, json.get("stringValue")); + assertEquals(false, json.get("primitiveBooleanValue")); + assertEquals(0, (byte)json.get("primitiveByteValue")); + assertEquals(0, (short)json.get("primitiveShortValue")); + assertEquals(0, (int)json.get("primitiveIntValue")); + assertEquals(0L, (long) json.get("primitiveLongValue")); + assertEquals(0f, (float) json.get("primitiveFloatValue"), 0); + assertEquals(0d, (double) json.get("primitiveDoubleValue"), 0); + assertEquals(Character.toString((char)0), json.get("primitiveCharValue")); + assertEquals(null, json.get("boxedBooleanValue")); + assertEquals(null, json.get("boxedByteValue")); + assertEquals(null, json.get("boxedShortValue")); + assertEquals(null, json.get("boxedIntValue")); + assertEquals(null, json.get("boxedLongValue")); + assertEquals(null, json.get("boxedFloatValue")); + assertEquals(null, json.get("boxedDoubleValue")); + assertEquals(null, json.get("boxedCharValue")); + assertEquals(null, json.get("jsonObjectDataObjectValue")); + assertEquals(null, json.get("stringDataObjectValue")); + assertEquals(null, json.get("bufferValue")); + assertEquals(null, json.get("jsonObjectValue")); + assertEquals(null, json.get("jsonArrayValue")); + assertEquals(null, json.get("enumValue")); + assertEquals(null, json.get("methodMappedValue")); + assertEquals(null, json.get("customEnumValue")); + assertEquals(null, json.get("autoMappedValue")); + assertEquals(null, json.get("autoMappedWithVertxGenValue")); + assertEquals(null, json.get("stringValueList")); + assertEquals(null, json.get("boxedBooleanValueList")); + assertEquals(null, json.get("boxedByteValueList")); + assertEquals(null, json.get("boxedShortValueList")); + assertEquals(null, json.get("boxedIntValueList")); + assertEquals(null, json.get("boxedLongValueList")); + assertEquals(null, json.get("boxedFloatValueList")); + assertEquals(null, json.get("boxedDoubleValueList")); + assertEquals(null, json.get("boxedCharValueList")); + assertEquals(null, json.get("jsonObjectDataObjectValueList")); + assertEquals(null, json.get("stringDataObjectValueList")); + assertEquals(null, json.get("bufferValueList")); + assertEquals(null, json.get("jsonObjectValueList")); + assertEquals(null, json.get("jsonArrayValueList")); + assertEquals(null, json.get("enumValueList")); + assertEquals(null, json.get("methodMappedValueList")); + assertEquals(null, json.get("objectValueList")); + assertEquals(null, json.get("customEnumValueList")); + assertEquals(null, json.get("autoMappedValueList")); + assertEquals(null, json.get("autoMappedWithVertxGenValueList")); + assertEquals(null, json.get("stringValueSet")); + assertEquals(null, json.get("boxedBooleanValueSet")); + assertEquals(null, json.get("boxedByteValueSet")); + assertEquals(null, json.get("boxedShortValueSet")); + assertEquals(null, json.get("boxedIntValueSet")); + assertEquals(null, json.get("boxedLongValueSet")); + assertEquals(null, json.get("boxedFloatValueSet")); + assertEquals(null, json.get("boxedDoubleValueSet")); + assertEquals(null, json.get("boxedCharValueSet")); + assertEquals(null, json.get("jsonObjectDataObjectValueSet")); + assertEquals(null, json.get("stringDataObjectValueSet")); + assertEquals(null, json.get("bufferValueSet")); + assertEquals(null, json.get("jsonObjectValueSet")); + assertEquals(null, json.get("jsonArrayValueSet")); + assertEquals(null, json.get("enumValueSet")); + assertEquals(null, json.get("methodMappedValueSet")); + assertEquals(null, json.get("objectValueSet")); + assertEquals(null, json.get("customEnumValueSet")); + assertEquals(null, json.get("autoMappedValueSet")); + assertEquals(null, json.get("autoMappedWithVertxGenValueSet")); assertEquals(new JsonArray(), json.get("addedStringValues")); assertEquals(new JsonArray(), json.get("addedBoxedBooleanValues")); assertEquals(new JsonArray(), json.get("addedBoxedByteValues")); @@ -763,14 +817,16 @@ public void testEmptyDataObjectToJson() { assertEquals(new JsonArray(), json.get("addedBoxedFloatValues")); assertEquals(new JsonArray(), json.get("addedBoxedDoubleValues")); assertEquals(new JsonArray(), json.get("addedBoxedCharValues")); - assertEquals(new JsonArray(), json.get("addedStringDataObjects")); - assertEquals(new JsonArray(), json.get("addedBuffers")); - assertEquals(new JsonArray(), json.get("addedJsonObjects")); - assertEquals(new JsonArray(), json.get("addedJsonArrays")); - assertEquals(new JsonArray(), json.get("addedHttpMethods")); - assertEquals(new JsonArray(), json.get("addedMethodMappeds")); - assertEquals(new JsonArray(), json.get("addedObjects")); - assertEquals(new JsonArray(), json.get("addedEnumMappeds")); + assertEquals(new JsonArray(), json.get("addedStringDataObjectValues")); + assertEquals(new JsonArray(), json.get("addedBufferValues")); + assertEquals(new JsonArray(), json.get("addedJsonObjectValues")); + assertEquals(new JsonArray(), json.get("addedJsonArrayValues")); + assertEquals(new JsonArray(), json.get("addedEnumValues")); + assertEquals(new JsonArray(), json.get("addedMethodMappedValues")); + assertEquals(new JsonArray(), json.get("addedObjectValues")); + assertEquals(new JsonArray(), json.get("addedCustomEnumValues")); + assertEquals(new JsonArray(), json.get("addedAutoMappedValues")); + assertEquals(new JsonArray(), json.get("addedAutoMappedWithVertxGenValues")); assertEquals(null, json.get("stringValueMap")); assertEquals(null, json.get("boxedBooleanValueMap")); assertEquals(null, json.get("boxedByteValueMap")); @@ -780,14 +836,16 @@ public void testEmptyDataObjectToJson() { assertEquals(null, json.get("boxedFloatValueMap")); assertEquals(null, json.get("boxedDoubleValueMap")); assertEquals(null, json.get("boxedCharValueMap")); - assertEquals(null, json.get("stringDataObjectMap")); - assertEquals(null, json.get("bufferMap")); - assertEquals(null, json.get("jsonObjectMap")); - assertEquals(null, json.get("jsonArrayMap")); - assertEquals(null, json.get("httpMethodMap")); - assertEquals(null, json.get("methodMappedMap")); - assertEquals(null, json.get("objectMap")); - assertEquals(null, json.get("enumMappedMap")); + assertEquals(null, json.get("stringDataObjectValueMap")); + assertEquals(null, json.get("bufferValueMap")); + assertEquals(null, json.get("jsonObjectValueMap")); + assertEquals(null, json.get("jsonArrayValueMap")); + assertEquals(null, json.get("enumValueMap")); + assertEquals(null, json.get("methodMappedValueMap")); + assertEquals(null, json.get("objectValueMap")); + assertEquals(null, json.get("customEnumValueMap")); + assertEquals(null, json.get("autoMappedValueMap")); + assertEquals(null, json.get("autoMappedWithVertxGenValueMap")); } @Test diff --git a/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/TestDataObject.java b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/TestDataObject.java index 19b6c3efd..bfe94f014 100644 --- a/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/TestDataObject.java +++ b/vertx-codegen-json/src/test/java/io/vertx/test/codegen/converter/TestDataObject.java @@ -43,73 +43,81 @@ public static TestCustomEnum deserializeCustomEnum(String value) { return (value != null) ? TestCustomEnum.of(value) : null; } - private String string; - private boolean primitiveBoolean; - private byte primitiveByte; - private short primitiveShort; - private int primitiveInt; - private long primitiveLong; - private float primitiveFloat; - private double primitiveDouble; - private char primitiveChar; - private Boolean boxedBoolean; - private Byte boxedByte; - private Short boxedShort; - private Integer boxedInt; - private Long boxedLong; - private Float boxedFloat; - private Double boxedDouble; - private Character boxedChar; - private NestedJsonObjectDataObject jsonObjectDataObject; - private NestedStringDataObject stringDataObject; - private Buffer buffer; - private JsonObject jsonObject; - private JsonArray jsonArray; - private TimeUnit httpMethod; - private ZonedDateTime methodMapped; - private NoConverterDataObject notConvertibleDataObject; private ByteBuffer unmapped; - private TestCustomEnum enumMapped; - - private List stringList; - private List boxedBooleanList; - private List boxedByteList; - private List boxedShortList; - private List boxedIntList; - private List boxedLongList; - private List boxedFloatList; - private List boxedDoubleList; - private List boxedCharList; - private List jsonObjectDataObjectList; - private List stringDataObjectList; - private List bufferList; - private List jsonObjectList; - private List jsonArrayList; - private List httpMethodList; - private List methodMappedList; - private List objectList; - private List notConvertibleDataObjectList; - private List enumMappedList; - - private Set stringSet; - private Set boxedBooleanSet; - private Set boxedByteSet; - private Set boxedShortSet; - private Set boxedIntSet; - private Set boxedLongSet; - private Set boxedFloatSet; - private Set boxedDoubleSet; - private Set boxedCharSet; - private Set jsonObjectDataObjectSet; - private Set stringDataObjectSet; - private Set bufferSet; - private Set jsonObjectSet; - private Set jsonArraySet; - private Set httpMethodSet; - private Set methodMappedSet; - private Set objectSet; - private Set notConvertibleDataObjectSet; - private Set enumMappedSet; + + private String stringValue; + private boolean primitiveBooleanValue; + private byte primitiveByteValue; + private short primitiveShortValue; + private int primitiveIntValue; + private long primitiveLongValue; + private float primitiveFloatValue; + private double primitiveDoubleValue; + private char primitiveCharValue; + private Boolean boxedBooleanValue; + private Byte boxedByteValue; + private Short boxedShortValue; + private Integer boxedIntValue; + private Long boxedLongValue; + private Float boxedFloatValue; + private Double boxedDoubleValue; + private Character boxedCharValue; + private NestedJsonObjectDataObject jsonObjectDataObjectValue; + private NestedStringDataObject stringDataObjectValue; + private Buffer bufferValue; + private JsonObject jsonObjectValue; + private JsonArray jsonArrayValue; + private TimeUnit enumValue; + private ZonedDateTime methodMappedValue; + private Object objectValue; + private NoConverterDataObject noConverterDataObjectValue; + private TestCustomEnum customEnumValue; + private AutoMapped autoMappedValue; + private AutoMappedWithVertxGen autoMappedWithVertxGenValue; + + private List stringValueList; + private List boxedBooleanValueList; + private List boxedByteValueList; + private List boxedShortValueList; + private List boxedIntValueList; + private List boxedLongValueList; + private List boxedFloatValueList; + private List boxedDoubleValueList; + private List boxedCharValueList; + private List jsonObjectDataObjectValueList; + private List stringDataObjectValueList; + private List bufferValueList; + private List jsonObjectValueList; + private List jsonArrayValueList; + private List enumValueList; + private List methodMappedValueList; + private List objectValueList; + private List noConverterDataObjectValueList; + private List customEnumValueList; + private List autoMappedValueList; + private List autoMappedWithVertxGenValueList; + + private Set stringValueSet; + private Set boxedBooleanValueSet; + private Set boxedByteValueSet; + private Set boxedShortValueSet; + private Set boxedIntValueSet; + private Set boxedLongValueSet; + private Set boxedFloatValueSet; + private Set boxedDoubleValueSet; + private Set boxedCharValueSet; + private Set jsonObjectDataObjectValueSet; + private Set stringDataObjectValueSet; + private Set bufferValueSet; + private Set jsonObjectValueSet; + private Set jsonArrayValueSet; + private Set enumValueSet; + private Set methodMappedValueSet; + private Set objectValueSet; + private Set noConverterDataObjectValueSet; + private Set customEnumValueSet; + private Set autoMappedValueSet; + private Set autoMappedWithVertxGenValueSet; private List addedStringValues = new ArrayList<>(); private List addedBoxedBooleanValues = new ArrayList<>(); @@ -120,15 +128,18 @@ public static TestCustomEnum deserializeCustomEnum(String value) { private List addedBoxedFloatValues = new ArrayList<>(); private List addedBoxedDoubleValues = new ArrayList<>(); private List addedBoxedCharValues = new ArrayList<>(); - private List addedJsonObjectDataObjects = new ArrayList<>(); - private List addedStringDataObjects = new ArrayList<>(); - private List addedBuffers = new ArrayList<>(); - private List addedJsonObjects = new ArrayList<>(); - private List addedJsonArrays = new ArrayList<>(); - private List addedHttpMethods = new ArrayList<>(); - private List addedMethodMappeds = new ArrayList<>(); - private List addedObjects = new ArrayList<>(); - private List addedEnumMappeds = new ArrayList<>(); + private List addedJsonObjectDataObjectValues = new ArrayList<>(); + private List addedStringDataObjectValues = new ArrayList<>(); + private List addedBufferValues = new ArrayList<>(); + private List addedJsonObjectValues = new ArrayList<>(); + private List addedJsonArrayValues = new ArrayList<>(); + private List addedEnumValues = new ArrayList<>(); + private List addedMethodMappedValues = new ArrayList<>(); + private List addedObjectValues = new ArrayList<>(); + private List addedNoConverterDataObjectValue = new ArrayList<>(); + private List addedCustomEnumValues = new ArrayList<>(); + private List addedAutoMappedValues = new ArrayList<>(); + private List addedAutoMappedWithVertxGenValues = new ArrayList<>(); private Map stringValueMap; private Map boxedBooleanValueMap; @@ -139,16 +150,18 @@ public static TestCustomEnum deserializeCustomEnum(String value) { private Map boxedFloatValueMap; private Map boxedDoubleValueMap; private Map boxedCharValueMap; - private Map jsonObjectDataObjectMap; - private Map stringDataObjectMap; - private Map bufferMap; - private Map jsonObjectMap; - private Map jsonArrayMap; - private Map httpMethodMap; - private Map methodMappedMap; - private Map objectMap; - private Map notConvertibleDataObjectMap; - private Map enumMappedMap; + private Map jsonObjectDataObjectValueMap; + private Map stringDataObjectValueMap; + private Map bufferValueMap; + private Map jsonObjectValueMap; + private Map jsonArrayValueMap; + private Map enumValueMap; + private Map methodMappedValueMap; + private Map objectValueMap; + private Map noConverterDataObjectValueMap; + private Map customEnumValueMap; + private Map autoMappedValueMap; + private Map autoMappedWithVertxGenValueMap; private Map keyedStringValues = new HashMap<>(); private Map keyedBoxedBooleanValues = new HashMap<>(); @@ -167,7 +180,9 @@ public static TestCustomEnum deserializeCustomEnum(String value) { private Map keyedEnumValues = new HashMap<>(); private Map keyedMethodMappedValues = new HashMap<>(); private Map keyedObjectValues = new HashMap<>(); - private Map keyedEnumMappedValues = new HashMap<>(); + private Map keyedCustomEnumValues = new HashMap<>(); + private Map keyedAutoMappedValues = new HashMap<>(); + private Map keyedAutoMappedWithVertxGenValues = new HashMap<>(); public TestDataObject() { } @@ -178,228 +193,237 @@ public TestDataObject(TestDataObject copy) { public TestDataObject(JsonObject json) { } - public String getString() { - return string; + public String getStringValue() { + return stringValue; } - public TestDataObject setString(String value) { - this.string = value; + public TestDataObject setStringValue(String value) { + this.stringValue = value; return this; } - public boolean isPrimitiveBoolean() { - return primitiveBoolean; + public boolean isPrimitiveBooleanValue() { + return primitiveBooleanValue; } - public TestDataObject setPrimitiveBoolean(boolean value) { - this.primitiveBoolean = value; + public TestDataObject setPrimitiveBooleanValue(boolean value) { + this.primitiveBooleanValue = value; return this; } - public byte getPrimitiveByte() { - return primitiveByte; + public byte getPrimitiveByteValue() { + return primitiveByteValue; } - public TestDataObject setPrimitiveByte(byte primitiveByte) { - this.primitiveByte = primitiveByte; + public TestDataObject setPrimitiveByteValue(byte primitiveByteValue) { + this.primitiveByteValue = primitiveByteValue; return this; } - public short getPrimitiveShort() { - return primitiveShort; + public short getPrimitiveShortValue() { + return primitiveShortValue; } - public TestDataObject setPrimitiveShort(short primitiveShort) { - this.primitiveShort = primitiveShort; + public TestDataObject setPrimitiveShortValue(short primitiveShortValue) { + this.primitiveShortValue = primitiveShortValue; return this; } - public int getPrimitiveInt() { - return primitiveInt; + public int getPrimitiveIntValue() { + return primitiveIntValue; } - public TestDataObject setPrimitiveInt(int primitiveInt) { - this.primitiveInt = primitiveInt; + public TestDataObject setPrimitiveIntValue(int primitiveIntValue) { + this.primitiveIntValue = primitiveIntValue; return this; } - public long getPrimitiveLong() { - return primitiveLong; + public long getPrimitiveLongValue() { + return primitiveLongValue; } - public TestDataObject setPrimitiveLong(long primitiveLong) { - this.primitiveLong = primitiveLong; + public TestDataObject setPrimitiveLongValue(long primitiveLongValue) { + this.primitiveLongValue = primitiveLongValue; return this; } - public float getPrimitiveFloat() { - return primitiveFloat; + public float getPrimitiveFloatValue() { + return primitiveFloatValue; } - public TestDataObject setPrimitiveFloat(float primitiveFloat) { - this.primitiveFloat = primitiveFloat; + public TestDataObject setPrimitiveFloatValue(float primitiveFloatValue) { + this.primitiveFloatValue = primitiveFloatValue; return this; } - public double getPrimitiveDouble() { - return primitiveDouble; + public double getPrimitiveDoubleValue() { + return primitiveDoubleValue; } - public TestDataObject setPrimitiveDouble(double primitiveDouble) { - this.primitiveDouble = primitiveDouble; + public TestDataObject setPrimitiveDoubleValue(double primitiveDoubleValue) { + this.primitiveDoubleValue = primitiveDoubleValue; return this; } - public char getPrimitiveChar() { - return primitiveChar; + public char getPrimitiveCharValue() { + return primitiveCharValue; } - public TestDataObject setPrimitiveChar(char primitiveChar) { - this.primitiveChar = primitiveChar; + public TestDataObject setPrimitiveCharValue(char primitiveCharValue) { + this.primitiveCharValue = primitiveCharValue; return this; } - public Boolean isBoxedBoolean() { - return boxedBoolean; + public Boolean isBoxedBooleanValue() { + return boxedBooleanValue; } - public TestDataObject setBoxedBoolean(Boolean value) { - this.boxedBoolean = value; + public TestDataObject setBoxedBooleanValue(Boolean value) { + this.boxedBooleanValue = value; return this; } - public Byte getBoxedByte() { - return boxedByte; + public Byte getBoxedByteValue() { + return boxedByteValue; } - public TestDataObject setBoxedByte(Byte boxedByte) { - this.boxedByte = boxedByte; + public TestDataObject setBoxedByteValue(Byte boxedByteValue) { + this.boxedByteValue = boxedByteValue; return this; } - public Short getBoxedShort() { - return boxedShort; + public Short getBoxedShortValue() { + return boxedShortValue; } - public TestDataObject setBoxedShort(Short boxedShort) { - this.boxedShort = boxedShort; + public TestDataObject setBoxedShortValue(Short boxedShortValue) { + this.boxedShortValue = boxedShortValue; return this; } - public Integer getBoxedInt() { - return boxedInt; + public Integer getBoxedIntValue() { + return boxedIntValue; } - public TestDataObject setBoxedInt(Integer boxedInt) { - this.boxedInt = boxedInt; + public TestDataObject setBoxedIntValue(Integer boxedIntValue) { + this.boxedIntValue = boxedIntValue; return this; } - public Long getBoxedLong() { - return boxedLong; + public Long getBoxedLongValue() { + return boxedLongValue; } - public TestDataObject setBoxedLong(Long boxedLong) { - this.boxedLong = boxedLong; + public TestDataObject setBoxedLongValue(Long boxedLongValue) { + this.boxedLongValue = boxedLongValue; return this; } - public Float getBoxedFloat() { - return boxedFloat; + public Float getBoxedFloatValue() { + return boxedFloatValue; } - public TestDataObject setBoxedFloat(Float boxedFloat) { - this.boxedFloat = boxedFloat; + public TestDataObject setBoxedFloatValue(Float boxedFloatValue) { + this.boxedFloatValue = boxedFloatValue; return this; } - public Double getBoxedDouble() { - return boxedDouble; + public Double getBoxedDoubleValue() { + return boxedDoubleValue; } - public TestDataObject setBoxedDouble(Double boxedDouble) { - this.boxedDouble = boxedDouble; + public TestDataObject setBoxedDoubleValue(Double boxedDoubleValue) { + this.boxedDoubleValue = boxedDoubleValue; return this; } - public Character getBoxedChar() { - return boxedChar; + public Character getBoxedCharValue() { + return boxedCharValue; } - public TestDataObject setBoxedChar(Character boxedChar) { - this.boxedChar = boxedChar; + public TestDataObject setBoxedCharValue(Character boxedCharValue) { + this.boxedCharValue = boxedCharValue; return this; } - public NestedJsonObjectDataObject getJsonObjectDataObject() { - return jsonObjectDataObject; + public NestedJsonObjectDataObject getJsonObjectDataObjectValue() { + return jsonObjectDataObjectValue; } - public TestDataObject setJsonObjectDataObject(NestedJsonObjectDataObject jsonObjectDataObject) { - this.jsonObjectDataObject = jsonObjectDataObject; + public TestDataObject setJsonObjectDataObjectValue(NestedJsonObjectDataObject jsonObjectDataObjectValue) { + this.jsonObjectDataObjectValue = jsonObjectDataObjectValue; return this; } - public NestedStringDataObject getStringDataObject() { - return stringDataObject; + public NestedStringDataObject getStringDataObjectValue() { + return stringDataObjectValue; } - public TestDataObject setStringDataObject(NestedStringDataObject stringDataObject) { - this.stringDataObject = stringDataObject; + public TestDataObject setStringDataObjectValue(NestedStringDataObject stringDataObjectValue) { + this.stringDataObjectValue = stringDataObjectValue; return this; } - public Buffer getBuffer() { - return buffer; + public Buffer getBufferValue() { + return bufferValue; } - public TestDataObject setBuffer(Buffer buffer) { - this.buffer = buffer; + public TestDataObject setBufferValue(Buffer bufferValue) { + this.bufferValue = bufferValue; return this; } - public JsonObject getJsonObject() { - return jsonObject; + public JsonObject getJsonObjectValue() { + return jsonObjectValue; } - public TestDataObject setJsonObject(JsonObject jsonObject) { - this.jsonObject = jsonObject; + public TestDataObject setJsonObjectValue(JsonObject jsonObjectValue) { + this.jsonObjectValue = jsonObjectValue; return this; } - public JsonArray getJsonArray() { - return jsonArray; + public JsonArray getJsonArrayValue() { + return jsonArrayValue; } - public TestDataObject setJsonArray(JsonArray jsonArray) { - this.jsonArray = jsonArray; + public TestDataObject setJsonArrayValue(JsonArray jsonArrayValue) { + this.jsonArrayValue = jsonArrayValue; return this; } - public TimeUnit getHttpMethod() { - return httpMethod; + public TimeUnit getEnumValue() { + return enumValue; } - public TestDataObject setHttpMethod(TimeUnit httpMethod) { - this.httpMethod = httpMethod; + public TestDataObject setEnumValue(TimeUnit enumValue) { + this.enumValue = enumValue; return this; } - public ZonedDateTime getMethodMapped() { - return methodMapped; + public ZonedDateTime getMethodMappedValue() { + return methodMappedValue; } - public TestDataObject setMethodMapped(ZonedDateTime methodMapped) { - this.methodMapped = methodMapped; + public TestDataObject setMethodMappedValue(ZonedDateTime methodMappedValue) { + this.methodMappedValue = methodMappedValue; return this; } - public NoConverterDataObject getNotConvertibleDataObject() { - return notConvertibleDataObject; + public Object getObjectValue() { + return objectValue; } - public TestDataObject setNotConvertibleDataObject(NoConverterDataObject notConvertibleDataObject) { - this.notConvertibleDataObject = notConvertibleDataObject; + public TestDataObject setObjectValue(Object objectValue) { + this.objectValue = objectValue; + return this; + } + + public NoConverterDataObject getNoConverterDataObjectValue() { + return noConverterDataObjectValue; + } + + public TestDataObject setNoConverterDataObjectValue(NoConverterDataObject noConverterDataObjectValue) { + this.noConverterDataObjectValue = noConverterDataObjectValue; return this; } @@ -412,336 +436,390 @@ public TestDataObject setUnmapped(ByteBuffer unmapped) { return this; } - public TestCustomEnum getEnumMapped() { - return enumMapped; + public TestCustomEnum getCustomEnumValue() { + return customEnumValue; + } + + public TestDataObject setCustomEnumValue(TestCustomEnum customEnumValue) { + this.customEnumValue = customEnumValue; + return this; + } + + public AutoMapped getAutoMappedValue() { + return autoMappedValue; + } + + public TestDataObject setAutoMappedValue(AutoMapped autoMappedValue) { + this.autoMappedValue = autoMappedValue; + return this; + } + + public AutoMappedWithVertxGen getAutoMappedWithVertxGenValue() { + return autoMappedWithVertxGenValue; + } + + public TestDataObject setAutoMappedWithVertxGenValue(AutoMappedWithVertxGen autoMappedWithVertxGenValue) { + this.autoMappedWithVertxGenValue = autoMappedWithVertxGenValue; + return this; + } + + public List getStringValueList() { + return stringValueList; + } + + public TestDataObject setStringValueList(List stringValueList) { + this.stringValueList = stringValueList; + return this; + } + + public List getBoxedBooleanValueList() { + return boxedBooleanValueList; + } + + public TestDataObject setBoxedBooleanValueList(List boxedBooleanValueList) { + this.boxedBooleanValueList = boxedBooleanValueList; + return this; + } + + public List getBoxedByteValueList() { + return boxedByteValueList; + } + + public TestDataObject setBoxedByteValueList(List boxedByteValueList) { + this.boxedByteValueList = boxedByteValueList; + return this; + } + + public List getBoxedShortValueList() { + return boxedShortValueList; } - public TestDataObject setEnumMapped(TestCustomEnum enumMapped) { - this.enumMapped = enumMapped; + public TestDataObject setBoxedShortValueList(List boxedShortValueList) { + this.boxedShortValueList = boxedShortValueList; return this; } - public List getStringList() { - return stringList; + public List getBoxedIntValueList() { + return boxedIntValueList; } - public TestDataObject setStringList(List stringList) { - this.stringList = stringList; + public TestDataObject setBoxedIntValueList(List boxedIntValueList) { + this.boxedIntValueList = boxedIntValueList; return this; } - public List getBoxedBooleanList() { - return boxedBooleanList; + public List getBoxedLongValueList() { + return boxedLongValueList; } - public TestDataObject setBoxedBooleanList(List boxedBooleanList) { - this.boxedBooleanList = boxedBooleanList; + public TestDataObject setBoxedLongValueList(List boxedLongValueList) { + this.boxedLongValueList = boxedLongValueList; return this; } - public List getBoxedByteList() { - return boxedByteList; + public List getBoxedFloatValueList() { + return boxedFloatValueList; } - public TestDataObject setBoxedByteList(List boxedByteList) { - this.boxedByteList = boxedByteList; + public TestDataObject setBoxedFloatValueList(List boxedFloatValueList) { + this.boxedFloatValueList = boxedFloatValueList; return this; } - public List getBoxedShortList() { - return boxedShortList; + public List getBoxedDoubleValueList() { + return boxedDoubleValueList; } - public TestDataObject setBoxedShortList(List boxedShortList) { - this.boxedShortList = boxedShortList; + public TestDataObject setBoxedDoubleValueList(List boxedDoubleValueList) { + this.boxedDoubleValueList = boxedDoubleValueList; return this; } - public List getBoxedIntList() { - return boxedIntList; + public List getBoxedCharValueList() { + return boxedCharValueList; } - public TestDataObject setBoxedIntList(List boxedIntList) { - this.boxedIntList = boxedIntList; + public TestDataObject setBoxedCharValueList(List boxedCharValueList) { + this.boxedCharValueList = boxedCharValueList; return this; } - public List getBoxedLongList() { - return boxedLongList; + public List getJsonObjectDataObjectValueList() { + return jsonObjectDataObjectValueList; } - public TestDataObject setBoxedLongList(List boxedLongList) { - this.boxedLongList = boxedLongList; + public TestDataObject setJsonObjectDataObjectValueList(List jsonObjectDataObjectValueList) { + this.jsonObjectDataObjectValueList = jsonObjectDataObjectValueList; return this; } - public List getBoxedFloatList() { - return boxedFloatList; + public List getStringDataObjectValueList() { + return stringDataObjectValueList; } - public TestDataObject setBoxedFloatList(List boxedFloatList) { - this.boxedFloatList = boxedFloatList; + public TestDataObject setStringDataObjectValueList(List stringDataObjectValueList) { + this.stringDataObjectValueList = stringDataObjectValueList; return this; } - public List getBoxedDoubleList() { - return boxedDoubleList; + public List getBufferValueList() { + return bufferValueList; } - public TestDataObject setBoxedDoubleList(List boxedDoubleList) { - this.boxedDoubleList = boxedDoubleList; + public TestDataObject setBufferValueList(List bufferValueList) { + this.bufferValueList = bufferValueList; return this; } - public List getBoxedCharList() { - return boxedCharList; + public List getJsonObjectValueList() { + return jsonObjectValueList; } - public TestDataObject setBoxedCharList(List boxedCharList) { - this.boxedCharList = boxedCharList; + public TestDataObject setJsonObjectValueList(List jsonObjectValueList) { + this.jsonObjectValueList = jsonObjectValueList; return this; } - public List getJsonObjectDataObjectList() { - return jsonObjectDataObjectList; + public List getJsonArrayValueList() { + return jsonArrayValueList; } - public TestDataObject setJsonObjectDataObjectList(List jsonObjectDataObjectList) { - this.jsonObjectDataObjectList = jsonObjectDataObjectList; + public TestDataObject setJsonArrayValueList(List jsonArrayValueList) { + this.jsonArrayValueList = jsonArrayValueList; return this; } - public List getStringDataObjectList() { - return stringDataObjectList; + public List getEnumValueList() { + return enumValueList; } - public TestDataObject setStringDataObjectList(List stringDataObjectList) { - this.stringDataObjectList = stringDataObjectList; + public TestDataObject setEnumValueList(List enumValueList) { + this.enumValueList = enumValueList; return this; } - public List getBufferList() { - return bufferList; + public List getMethodMappedValueList() { + return methodMappedValueList; } - public TestDataObject setBufferList(List bufferList) { - this.bufferList = bufferList; + public TestDataObject setMethodMappedValueList(List methodMappedValueList) { + this.methodMappedValueList = methodMappedValueList; return this; } - public List getJsonObjectList() { - return jsonObjectList; + public List getObjectValueList() { + return objectValueList; } - public TestDataObject setJsonObjectList(List jsonObjectList) { - this.jsonObjectList = jsonObjectList; + public TestDataObject setObjectValueList(List objectValueList) { + this.objectValueList = objectValueList; return this; } - public List getJsonArrayList() { - return jsonArrayList; + public List getCustomEnumValueList() { + return customEnumValueList; } - public TestDataObject setJsonArrayList(List jsonArrayList) { - this.jsonArrayList = jsonArrayList; + public TestDataObject setCustomEnumValueList(List customEnumValueList) { + this.customEnumValueList = customEnumValueList; return this; } - public List getHttpMethodList() { - return httpMethodList; + public List getAutoMappedValueList() { + return autoMappedValueList; } - public TestDataObject setHttpMethodList(List httpMethodList) { - this.httpMethodList = httpMethodList; + public TestDataObject setAutoMappedValueList(List autoMappedValueList) { + this.autoMappedValueList = autoMappedValueList; return this; } - public List getMethodMappedList() { - return methodMappedList; + public List getAutoMappedWithVertxGenValueList() { + return autoMappedWithVertxGenValueList; } - public TestDataObject setMethodMappedList(List methodMappedList) { - this.methodMappedList = methodMappedList; + public TestDataObject setAutoMappedWithVertxGenValueList(List autoMappedValueList) { + this.autoMappedWithVertxGenValueList = autoMappedValueList; return this; } - public List getObjectList() { - return objectList; + public Set getStringValueSet() { + return stringValueSet; } - public TestDataObject setObjectList(List objectList) { - this.objectList = objectList; + public TestDataObject setStringValueSet(Set stringValueSet) { + this.stringValueSet = stringValueSet; return this; } - public List getEnumMappedList() { - return enumMappedList; + public Set getBoxedBooleanValueSet() { + return boxedBooleanValueSet; } - public TestDataObject setEnumMappedList(List enumMappedList) { - this.enumMappedList = enumMappedList; + public TestDataObject setBoxedBooleanValueSet(Set boxedBooleanValueSet) { + this.boxedBooleanValueSet = boxedBooleanValueSet; return this; } - public Set getStringSet() { - return stringSet; + public Set getBoxedByteValueSet() { + return boxedByteValueSet; } - public TestDataObject setStringSet(Set stringSet) { - this.stringSet = stringSet; + public TestDataObject setBoxedByteValueSet(Set boxedByteValueSet) { + this.boxedByteValueSet = boxedByteValueSet; return this; } - public Set getBoxedBooleanSet() { - return boxedBooleanSet; + public Set getBoxedShortValueSet() { + return boxedShortValueSet; } - public TestDataObject setBoxedBooleanSet(Set boxedBooleanSet) { - this.boxedBooleanSet = boxedBooleanSet; + public TestDataObject setBoxedShortValueSet(Set boxedShortValueSet) { + this.boxedShortValueSet = boxedShortValueSet; return this; } - public Set getBoxedByteSet() { - return boxedByteSet; + public Set getBoxedIntValueSet() { + return boxedIntValueSet; } - public TestDataObject setBoxedByteSet(Set boxedByteSet) { - this.boxedByteSet = boxedByteSet; + public TestDataObject setBoxedIntValueSet(Set boxedIntValueSet) { + this.boxedIntValueSet = boxedIntValueSet; return this; } - public Set getBoxedShortSet() { - return boxedShortSet; + public Set getBoxedLongValueSet() { + return boxedLongValueSet; } - public TestDataObject setBoxedShortSet(Set boxedShortSet) { - this.boxedShortSet = boxedShortSet; + public TestDataObject setBoxedLongValueSet(Set boxedLongValueSet) { + this.boxedLongValueSet = boxedLongValueSet; return this; } - public Set getBoxedIntSet() { - return boxedIntSet; + public Set getBoxedFloatValueSet() { + return boxedFloatValueSet; } - public TestDataObject setBoxedIntSet(Set boxedIntSet) { - this.boxedIntSet = boxedIntSet; + public TestDataObject setBoxedFloatValueSet(Set boxedFloatValueSet) { + this.boxedFloatValueSet = boxedFloatValueSet; return this; } - public Set getBoxedLongSet() { - return boxedLongSet; + public Set getBoxedDoubleValueSet() { + return boxedDoubleValueSet; } - public TestDataObject setBoxedLongSet(Set boxedLongSet) { - this.boxedLongSet = boxedLongSet; + public TestDataObject setBoxedDoubleValueSet(Set boxedDoubleValueSet) { + this.boxedDoubleValueSet = boxedDoubleValueSet; return this; } - public Set getBoxedFloatSet() { - return boxedFloatSet; + public Set getBoxedCharValueSet() { + return boxedCharValueSet; } - public TestDataObject setBoxedFloatSet(Set boxedFloatSet) { - this.boxedFloatSet = boxedFloatSet; + public TestDataObject setBoxedCharValueSet(Set boxedCharValueSet) { + this.boxedCharValueSet = boxedCharValueSet; return this; } - public Set getBoxedDoubleSet() { - return boxedDoubleSet; + public Set getJsonObjectDataObjectValueSet() { + return jsonObjectDataObjectValueSet; } - public TestDataObject setBoxedDoubleSet(Set boxedDoubleSet) { - this.boxedDoubleSet = boxedDoubleSet; + public TestDataObject setJsonObjectDataObjectValueSet(Set jsonObjectDataObjectValueSet) { + this.jsonObjectDataObjectValueSet = jsonObjectDataObjectValueSet; return this; } - public Set getBoxedCharSet() { - return boxedCharSet; + public Set getStringDataObjectValueSet() { + return stringDataObjectValueSet; } - public TestDataObject setBoxedCharSet(Set boxedCharSet) { - this.boxedCharSet = boxedCharSet; + public TestDataObject setStringDataObjectValueSet(Set stringDataObjectValueSet) { + this.stringDataObjectValueSet = stringDataObjectValueSet; return this; } - public Set getJsonObjectDataObjectSet() { - return jsonObjectDataObjectSet; + public Set getBufferValueSet() { + return bufferValueSet; } - public TestDataObject setJsonObjectDataObjectSet(Set jsonObjectDataObjectSet) { - this.jsonObjectDataObjectSet = jsonObjectDataObjectSet; + public TestDataObject setBufferValueSet(Set bufferValueSet) { + this.bufferValueSet = bufferValueSet; return this; } - public Set getStringDataObjectSet() { - return stringDataObjectSet; + public Set getJsonObjectValueSet() { + return jsonObjectValueSet; } - public TestDataObject setStringDataObjectSet(Set stringDataObjectSet) { - this.stringDataObjectSet = stringDataObjectSet; + public TestDataObject setJsonObjectValueSet(Set jsonObjectValueSet) { + this.jsonObjectValueSet = jsonObjectValueSet; return this; } - public Set getBufferSet() { - return bufferSet; + public Set getJsonArrayValueSet() { + return jsonArrayValueSet; } - public TestDataObject setBufferSet(Set bufferSet) { - this.bufferSet = bufferSet; + public TestDataObject setJsonArrayValueSet(Set jsonArrayValueSet) { + this.jsonArrayValueSet = jsonArrayValueSet; return this; } - public Set getJsonObjectSet() { - return jsonObjectSet; + public Set getEnumValueSet() { + return enumValueSet; } - public TestDataObject setJsonObjectSet(Set jsonObjectSet) { - this.jsonObjectSet = jsonObjectSet; + public TestDataObject setEnumValueSet(Set enumValueSet) { + this.enumValueSet = enumValueSet; return this; } - public Set getJsonArraySet() { - return jsonArraySet; + public Set getMethodMappedValueSet() { + return methodMappedValueSet; } - public TestDataObject setJsonArraySet(Set jsonArraySet) { - this.jsonArraySet = jsonArraySet; + public TestDataObject setMethodMappedValueSet(Set methodMappedValueSet) { + this.methodMappedValueSet = methodMappedValueSet; return this; } - public Set getHttpMethodSet() { - return httpMethodSet; + public Set getObjectValueSet() { + return objectValueSet; } - public TestDataObject setHttpMethodSet(Set httpMethodSet) { - this.httpMethodSet = httpMethodSet; + public TestDataObject setObjectValueSet(Set objectValueSet) { + this.objectValueSet = objectValueSet; return this; } - public Set getMethodMappedSet() { - return methodMappedSet; + public Set getCustomEnumValueSet() { + return customEnumValueSet; } - public TestDataObject setMethodMappedSet(Set methodMappedSet) { - this.methodMappedSet = methodMappedSet; + public TestDataObject setCustomEnumValueSet(Set customEnumValueSet) { + this.customEnumValueSet = customEnumValueSet; return this; } - public Set getObjectSet() { - return objectSet; + public Set getAutoMappedValueSet() { + return autoMappedValueSet; } - public TestDataObject setObjectSet(Set objectSet) { - this.objectSet = objectSet; + public TestDataObject setAutoMappedValueSet(Set autoMappedValueSet) { + this.autoMappedValueSet = autoMappedValueSet; return this; } - public Set getEnumMappedSet() { - return enumMappedSet; + public Set getAutoMappedWithVertxGenValueSet() { + return autoMappedWithVertxGenValueSet; } - public TestDataObject setEnumMappedSet(Set enumMappedSet) { - this.enumMappedSet = enumMappedSet; + public TestDataObject setAutoMappedWithVertxGenValueSet(Set autoMappedValueList) { + this.autoMappedWithVertxGenValueSet = autoMappedValueList; return this; } @@ -826,84 +904,102 @@ public TestDataObject addAddedBoxedCharValue(Character addedBoxedCharValue) { return this; } - public List getAddedJsonObjectDataObjects() { - return addedJsonObjectDataObjects; + public List getAddedJsonObjectDataObjectValues() { + return addedJsonObjectDataObjectValues; } - public TestDataObject addAddedJsonObjectDataObject(NestedJsonObjectDataObject addedAggregatedDataObject) { - this.addedJsonObjectDataObjects.add(addedAggregatedDataObject); + public TestDataObject addAddedJsonObjectDataObjectValue(NestedJsonObjectDataObject addedAggregatedDataObject) { + this.addedJsonObjectDataObjectValues.add(addedAggregatedDataObject); return this; } - public List getAddedStringDataObjects() { - return addedStringDataObjects; + public List getAddedStringDataObjectValues() { + return addedStringDataObjectValues; } - public TestDataObject addAddedStringDataObject(NestedStringDataObject addedAggregatedDataObject) { - this.addedStringDataObjects.add(addedAggregatedDataObject); + public TestDataObject addAddedStringDataObjectValue(NestedStringDataObject addedAggregatedDataObject) { + this.addedStringDataObjectValues.add(addedAggregatedDataObject); return this; } - public List getAddedBuffers() { - return addedBuffers; + public List getAddedBufferValues() { + return addedBufferValues; } - public TestDataObject addAddedBuffer(Buffer addedBuffer) { - this.addedBuffers.add(addedBuffer); + public TestDataObject addAddedBufferValue(Buffer addedBuffer) { + this.addedBufferValues.add(addedBuffer); return this; } - public List getAddedJsonObjects() { - return addedJsonObjects; + public List getAddedJsonObjectValues() { + return addedJsonObjectValues; } - public TestDataObject addAddedJsonObject(JsonObject addedJsonObject) { - this.addedJsonObjects.add(addedJsonObject); + public TestDataObject addAddedJsonObjectValue(JsonObject addedJsonObject) { + this.addedJsonObjectValues.add(addedJsonObject); return this; } - public List getAddedJsonArrays() { - return addedJsonArrays; + public List getAddedJsonArrayValues() { + return addedJsonArrayValues; } - public TestDataObject addAddedJsonArray(JsonArray addedJsonArray) { - this.addedJsonArrays.add(addedJsonArray); + public TestDataObject addAddedJsonArrayValue(JsonArray addedJsonArray) { + this.addedJsonArrayValues.add(addedJsonArray); return this; } - public List getAddedHttpMethods() { - return addedHttpMethods; + public List getAddedEnumValues() { + return addedEnumValues; } - public TestDataObject addAddedHttpMethod(TimeUnit addedHttpMethod) { - this.addedHttpMethods.add(addedHttpMethod); + public TestDataObject addAddedEnumValue(TimeUnit addedHttpMethod) { + this.addedEnumValues.add(addedHttpMethod); return this; } - public List getAddedMethodMappeds() { - return addedMethodMappeds; + public List getAddedMethodMappedValues() { + return addedMethodMappedValues; } - public TestDataObject addAddedMethodMapped(ZonedDateTime addedDateTime) { - this.addedMethodMappeds.add(addedDateTime); + public TestDataObject addAddedMethodMappedValue(ZonedDateTime addedDateTime) { + this.addedMethodMappedValues.add(addedDateTime); return this; } - public List getAddedObjects() { - return addedObjects; + public List getAddedObjectValues() { + return addedObjectValues; } - public TestDataObject addAddedObject(Object addedObject) { - this.addedObjects.add(addedObject); + public TestDataObject addAddedObjectValue(Object addedObject) { + this.addedObjectValues.add(addedObject); return this; } - public List getAddedEnumMappeds() { - return addedEnumMappeds; + public List getAddedCustomEnumValues() { + return addedCustomEnumValues; } - public TestDataObject addAddedEnumMapped(TestCustomEnum addedEnumMappeds) { - this.addedEnumMappeds.add(addedEnumMappeds); + public TestDataObject addAddedCustomEnumValue(TestCustomEnum addedEnumMappeds) { + this.addedCustomEnumValues.add(addedEnumMappeds); + return this; + } + + public List getAddedAutoMappedValues() { + return addedAutoMappedValues; + } + + public TestDataObject addAddedAutoMappedValue(AutoMapped autoMappedValue) { + this.addedAutoMappedValues.add(autoMappedValue); + return this; + } + + public List getAddedAutoMappedWithVertxGenValues() { + return addedAutoMappedWithVertxGenValues; + } + + public TestDataObject addAddedAutoMappedWithVertxGenValue(AutoMappedWithVertxGen autoMappedValue) { + this.addedAutoMappedWithVertxGenValues.add(autoMappedValue); return this; } @@ -988,84 +1084,102 @@ public TestDataObject setBoxedCharValueMap(Map boxedCharValue return this; } - public Map getJsonObjectDataObjectMap() { - return jsonObjectDataObjectMap; + public Map getJsonObjectDataObjectValueMap() { + return jsonObjectDataObjectValueMap; } - public TestDataObject setJsonObjectDataObjectMap(Map nestedJsonObjectDataObjectMap) { - this.jsonObjectDataObjectMap = nestedJsonObjectDataObjectMap; + public TestDataObject setJsonObjectDataObjectValueMap(Map nestedJsonObjectDataObjectMap) { + this.jsonObjectDataObjectValueMap = nestedJsonObjectDataObjectMap; return this; } - public Map getStringDataObjectMap() { - return stringDataObjectMap; + public Map getStringDataObjectValueMap() { + return stringDataObjectValueMap; } - public TestDataObject setStringDataObjectMap(Map nestedJsonObjectDataObjectMap) { - this.stringDataObjectMap = nestedJsonObjectDataObjectMap; + public TestDataObject setStringDataObjectValueMap(Map nestedJsonObjectDataObjectMap) { + this.stringDataObjectValueMap = nestedJsonObjectDataObjectMap; return this; } - public Map getBufferMap() { - return bufferMap; + public Map getBufferValueMap() { + return bufferValueMap; } - public TestDataObject setBufferMap(Map bufferMap) { - this.bufferMap = bufferMap; + public TestDataObject setBufferValueMap(Map bufferValueMap) { + this.bufferValueMap = bufferValueMap; return this; } - public Map getJsonObjectMap() { - return jsonObjectMap; + public Map getJsonObjectValueMap() { + return jsonObjectValueMap; } - public TestDataObject setJsonObjectMap(Map jsonObjectMap) { - this.jsonObjectMap = jsonObjectMap; + public TestDataObject setJsonObjectValueMap(Map jsonObjectValueMap) { + this.jsonObjectValueMap = jsonObjectValueMap; return this; } - public Map getJsonArrayMap() { - return jsonArrayMap; + public Map getJsonArrayValueMap() { + return jsonArrayValueMap; } - public TestDataObject setJsonArrayMap(Map jsonArrayMap) { - this.jsonArrayMap = jsonArrayMap; + public TestDataObject setJsonArrayValueMap(Map jsonArrayValueMap) { + this.jsonArrayValueMap = jsonArrayValueMap; return this; } - public Map getHttpMethodMap() { - return httpMethodMap; + public Map getEnumValueMap() { + return enumValueMap; } - public TestDataObject setHttpMethodMap(Map httpMethodMap) { - this.httpMethodMap = httpMethodMap; + public TestDataObject setEnumValueMap(Map enumValueMap) { + this.enumValueMap = enumValueMap; return this; } - public Map getMethodMappedMap() { - return methodMappedMap; + public Map getMethodMappedValueMap() { + return methodMappedValueMap; } - public TestDataObject setMethodMappedMap(Map methodMappedMap) { - this.methodMappedMap = methodMappedMap; + public TestDataObject setMethodMappedValueMap(Map methodMappedValueMap) { + this.methodMappedValueMap = methodMappedValueMap; return this; } - public Map getObjectMap() { - return objectMap; + public Map getObjectValueMap() { + return objectValueMap; } - public TestDataObject setObjectMap(Map objectMap) { - this.objectMap = objectMap; + public TestDataObject setObjectValueMap(Map objectValueMap) { + this.objectValueMap = objectValueMap; return this; } - public Map getEnumMappedMap() { - return enumMappedMap; + public Map getCustomEnumValueMap() { + return customEnumValueMap; } - public TestDataObject setEnumMappedMap(Map enumMappedMap) { - this.enumMappedMap = enumMappedMap; + public TestDataObject setCustomEnumValueMap(Map customEnumValueMap) { + this.customEnumValueMap = customEnumValueMap; + return this; + } + + public Map getAutoMappedValueMap() { + return autoMappedValueMap; + } + + public TestDataObject setAutoMappedValueMap(Map autoMappedValueMap) { + this.autoMappedValueMap = autoMappedValueMap; + return this; + } + + public Map getAutoMappedWithVertxGenValueMap() { + return autoMappedWithVertxGenValueMap; + } + + public TestDataObject setAutoMappedWithVertxGenValueMap(Map autoMappedWithVertxGenValueMap) { + this.autoMappedWithVertxGenValueMap = autoMappedWithVertxGenValueMap; return this; } @@ -1222,39 +1336,57 @@ public TestDataObject addKeyedObjectValue(String key, Object value) { return this; } - public Map getKeyedEnumMappedValues() { - return keyedEnumMappedValues; + public Map getKeyedCustomEnumValues() { + return keyedCustomEnumValues; + } + + public TestDataObject addKeyedCustomEnumValue(String key, TestCustomEnum value) { + this.keyedCustomEnumValues.put(key, value); + return this; + } + + public Map getKeyedAutoMappedValues() { + return keyedAutoMappedValues; + } + + public TestDataObject addKeyedAutoMappedValue(String key, AutoMapped value) { + this.keyedAutoMappedValues.put(key, value); + return this; + } + + public Map getKeyedAutoMappedWithVertxGenValues() { + return keyedAutoMappedWithVertxGenValues; } - public TestDataObject addKeyedEnumMappedValue(String key, TestCustomEnum value) { - this.keyedEnumMappedValues.put(key, value); + public TestDataObject addKeyedAutoMappedWithVertxGenValue(String key, AutoMappedWithVertxGen value) { + this.keyedAutoMappedWithVertxGenValues.put(key, value); return this; } - public List getNotConvertibleDataObjectList() { - return notConvertibleDataObjectList; + public List getNoConverterDataObjectValueList() { + return noConverterDataObjectValueList; } - public TestDataObject setNotConvertibleDataObjectList(List notConvertibleDataObjectList) { - this.notConvertibleDataObjectList = notConvertibleDataObjectList; + public TestDataObject setNoConverterDataObjectValueList(List noConverterDataObjectValueList) { + this.noConverterDataObjectValueList = noConverterDataObjectValueList; return this; } - public Set getNotConvertibleDataObjectSet() { - return notConvertibleDataObjectSet; + public Set getNoConverterDataObjectValueSet() { + return noConverterDataObjectValueSet; } - public TestDataObject setNotConvertibleDataObjectSet(Set notConvertibleDataObjectSet) { - this.notConvertibleDataObjectSet = notConvertibleDataObjectSet; + public TestDataObject setNoConverterDataObjectValueSet(Set noConverterDataObjectValueSet) { + this.noConverterDataObjectValueSet = noConverterDataObjectValueSet; return this; } - public Map getNotConvertibleDataObjectMap() { - return notConvertibleDataObjectMap; + public Map getNoConverterDataObjectValueMap() { + return noConverterDataObjectValueMap; } - public TestDataObject setNotConvertibleDataObjectMap(Map notConvertibleDataObjectMap) { - this.notConvertibleDataObjectMap = notConvertibleDataObjectMap; + public TestDataObject setNoConverterDataObjectValueMap(Map noConverterDataObjectValueMap) { + this.noConverterDataObjectValueMap = noConverterDataObjectValueMap; return this; } } diff --git a/vertx-codegen-processor/src/main/asciidoc/index.adoc b/vertx-codegen-processor/src/main/asciidoc/index.adoc index f94f750e5..4a699ad07 100644 --- a/vertx-codegen-processor/src/main/asciidoc/index.adoc +++ b/vertx-codegen-processor/src/main/asciidoc/index.adoc @@ -165,6 +165,40 @@ com.example.MyEnumWithCustomFactory.deserializer=com.example.MyEnumWithCustomFac A `@DataObject` annotated type is a Java class with the only purpose to be a container for data. +A data object can be created from JSON with a constructor or a factory method: + +.with a constructor +[source,java] +---- +public class MyDataObject { + public MyDataObject(JsonObject json) { + // ... + } +} +---- + +.with a factory +[source,java] +---- +public class MyDataObject { + public static MyDataObject fromJson(JsonObject json) { + // ... + } +} +---- + +A data object can be converted to JSON with a `toJson()` method: + +.with a factory +[source,java] +---- +public class MyDataObject { + public JsonObject toJson() { + // ... + } +} +---- + A converter instance is automatically generated when the class is annotated with `@DataObject(generateConverter = true)` Data object annotated classes can also inherit from other data objects annotated types. @@ -229,8 +263,7 @@ encouraged. ==== Json -> Data Object conversion When a data object has an associated deserializer, it can be instantiated from a json value and is said _deserializable_. -For POJO to json object mapping, although there are no strict rules of mapping between the data object properties and -the json structure, it is a good thing to follow a common mapping for users using json data objects (like in JavaScript shim). +For POJO to json object mapping, although there are no strict rules of mapping between the data object properties and the json structure, it is a good thing to follow a common mapping for users using json data objects (like in JavaScript shim). In particular json object properties should be named after properties according to JavaBean conversion rules: @@ -248,8 +281,7 @@ In all case, property names are _normalized_, i.e: ==== Data object -> json conversion When a data object has an associated serializer, it can be converted to the json format and is said _serializable_. -Vert.x API types have restriction in the declared method return types, a jsonifiable data object can be used in -Vert.x API method return types or handlers because it can be converted to a json format, otherwise it is not permitted. +Vert.x API types have restriction in the declared method return types, a jsonifiable data object can be used in Vert.x API method return types or handlers because it can be converted to a json format, otherwise it is not permitted. ===== Data object converter diff --git a/vertx-codegen-processor/src/main/java/io/vertx/codegen/Helper.java b/vertx-codegen-processor/src/main/java/io/vertx/codegen/Helper.java index c4f047c63..35e772399 100644 --- a/vertx-codegen-processor/src/main/java/io/vertx/codegen/Helper.java +++ b/vertx-codegen-processor/src/main/java/io/vertx/codegen/Helper.java @@ -18,6 +18,8 @@ import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.type.ClassKind; +import io.vertx.codegen.type.MapperInfo; +import io.vertx.codegen.type.TypeMirrorFactory; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; @@ -38,6 +40,9 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static io.vertx.codegen.type.TypeMirrorFactory.JSON_OBJECT; +import static io.vertx.codegen.type.TypeMirrorFactory.STRING; + /** * @author Tim Fox */ @@ -676,8 +681,8 @@ public static Method getReflectMethod(ClassLoader loader, ExecutableElement mode return method; } - public static ClassKind getAnnotatedDataObjectAnnotatedSerializationType(Elements elementUtils, TypeElement dataObjectElt) { - return elementUtils.getAllMembers(dataObjectElt) + public static MapperInfo getAnnotatedDataObjectAnnotatedSerializationType(Elements elementUtils, TypeElement dataObjectElt) { + Optional opt = elementUtils.getAllMembers(dataObjectElt) .stream() .flatMap(Helper.FILTER_METHOD) .filter(exeElt -> exeElt.getParameters().isEmpty() && exeElt.getSimpleName().toString().equals("toJson")) @@ -691,8 +696,22 @@ public static ClassKind getAnnotatedDataObjectAnnotatedSerializationType(Element } return Stream.empty(); }) - .findFirst() - .orElse(null); + .findFirst(); + if (opt.isPresent()) { + ClassKind classKind = opt.get(); + MapperInfo serializer = new MapperInfo(); + serializer.setQualifiedName(dataObjectElt.getQualifiedName().toString()); + serializer.setKind(MapperKind.SELF); + if (classKind == ClassKind.JSON_OBJECT) { + serializer.setTargetType(JSON_OBJECT); + serializer.setSelectors(Collections.singletonList("toJson")); + } else { + serializer.setTargetType(STRING); + serializer.setSelectors(Collections.singletonList("toJson")); + } + return serializer; + } + return null; } public static boolean isConcreteClass(TypeElement element) { @@ -706,7 +725,7 @@ public static boolean isAbstractClassOrInterface(TypeElement element) { private static final Set dataObjectTypes = new HashSet<>(Arrays.asList("io.vertx.core.json.JsonObject", "java.lang.String")); - public static ClassKind getAnnotatedDataObjectDeserialisationType(Elements elementUtils, Types typeUtils, TypeElement dataObjectElt) { + public static MapperInfo getAnnotatedDataObjectDeserialisationType(Elements elementUtils, Types typeUtils, TypeElement dataObjectElt) { if (isConcreteClass(dataObjectElt)) { Set types = elementUtils .getAllMembers(dataObjectElt) @@ -721,11 +740,47 @@ public static ClassKind getAnnotatedDataObjectDeserialisationType(Elements eleme .collect(Collectors.toSet()); // Order matter if (types.contains("io.vertx.core.json.JsonObject")) { - return ClassKind.JSON_OBJECT; + MapperInfo mi = new MapperInfo(); + mi.setQualifiedName(dataObjectElt.getQualifiedName().toString()); + mi.setTargetType(JSON_OBJECT); + mi.setKind(MapperKind.SELF); + return mi; } else if (types.contains("java.lang.String")) { - return ClassKind.STRING; + MapperInfo mi = new MapperInfo(); + mi.setQualifiedName(dataObjectElt.getQualifiedName().toString()); + mi.setTargetType(STRING); + mi.setKind(MapperKind.SELF); + return mi; } } + Optional opt = elementUtils.getAllMembers(dataObjectElt).stream() + .map(e -> { + if (e.getKind() == ElementKind.METHOD) { + ExecutableElement execElt = (ExecutableElement) e; + if (e.getSimpleName().toString().equals("fromJson")) { + if (execElt.getParameters().size() == 1) { + String argType = execElt.getParameters().get(0).asType().toString(); + if (argType.equals("java.lang.String") || argType.equals("io.vertx.core.json.JsonObject")) { + Set modifiers = execElt.getModifiers(); + if (modifiers.contains(Modifier.PUBLIC) && modifiers.contains(Modifier.STATIC)) { + if (typeUtils.isSameType(execElt.getReturnType(), dataObjectElt.asType())) { + return argType; + } + } + } + } + } + } + return ""; + }).filter(s -> s.length() > 0).findFirst(); + if (opt.isPresent()) { + MapperInfo mi = new MapperInfo(); + mi.setQualifiedName(dataObjectElt.getQualifiedName().toString()); + mi.setTargetType(opt.get().equals("java.lang.String") ? STRING : JSON_OBJECT); + mi.setKind(MapperKind.STATIC_METHOD); + mi.setSelectors(Collections.singletonList("fromJson")); + return mi; + } return null; } diff --git a/vertx-codegen-processor/src/main/java/io/vertx/codegen/type/TypeMirrorFactory.java b/vertx-codegen-processor/src/main/java/io/vertx/codegen/type/TypeMirrorFactory.java index a3ea116cb..1640ae0e9 100644 --- a/vertx-codegen-processor/src/main/java/io/vertx/codegen/type/TypeMirrorFactory.java +++ b/vertx-codegen-processor/src/main/java/io/vertx/codegen/type/TypeMirrorFactory.java @@ -22,9 +22,9 @@ */ public class TypeMirrorFactory { - private static final ModuleInfo VERTX_CORE_MOD = new ModuleInfo("io.vertx.core", "vertx", "io.vertx", false, false); - private static final ClassTypeInfo JSON_OBJECT = new ClassTypeInfo(ClassKind.JSON_OBJECT, "io.vertx.core.json.JsonObject", VERTX_CORE_MOD, false, Collections.emptyList(), null); - private static final ClassTypeInfo STRING = new ClassTypeInfo(ClassKind.STRING, "java.lang.String", null, false, Collections.emptyList(), null); + public static final ModuleInfo VERTX_CORE_MOD = new ModuleInfo("io.vertx.core", "vertx", "io.vertx", false, false); + public static final ClassTypeInfo JSON_OBJECT = new ClassTypeInfo(ClassKind.JSON_OBJECT, "io.vertx.core.json.JsonObject", VERTX_CORE_MOD, false, Collections.emptyList(), null); + public static final ClassTypeInfo STRING = new ClassTypeInfo(ClassKind.STRING, "java.lang.String", null, false, Collections.emptyList(), null); final Elements elementUtils; final Types typeUtils; @@ -138,35 +138,18 @@ public TypeInfo create(TypeUse use, DeclaredType type, boolean checkTypeArgs) { } else { MapperInfo serializer = serializers.get(fqcn); MapperInfo deserializer = deserializers.get(fqcn); - DataObjectInfo dataObject = null; - if (elt.getAnnotation(DataObject.class) != null) { - ClassKind serializable = Helper.getAnnotatedDataObjectAnnotatedSerializationType(elementUtils, elt); - ClassKind deserializable = Helper.getAnnotatedDataObjectDeserialisationType(elementUtils, typeUtils, elt); - if (serializer == null && serializable != null) { - serializer = new MapperInfo(); - serializer.setQualifiedName(fqcn); - serializer.setKind(MapperKind.SELF); - if (serializable == ClassKind.JSON_OBJECT) { - serializer.setTargetType(JSON_OBJECT); - serializer.setSelectors(Collections.singletonList("toJson")); - } else { - serializer.setTargetType(STRING); - serializer.setSelectors(Collections.singletonList("toJson")); - } + boolean annotated = elt.getAnnotation(DataObject.class) != null; + if (annotated) { + if (serializer == null) { + serializer = Helper.getAnnotatedDataObjectAnnotatedSerializationType(elementUtils, elt); } - if (deserializer == null && deserializable != null) { - deserializer = new MapperInfo(); - deserializer.setQualifiedName(fqcn); - deserializer.setKind(MapperKind.SELF); - if (deserializable == ClassKind.JSON_OBJECT) { - deserializer.setTargetType(JSON_OBJECT); - } else { - deserializer.setTargetType(STRING); - } + if (deserializer == null) { + deserializer = Helper.getAnnotatedDataObjectDeserialisationType(elementUtils, typeUtils, elt); } - dataObject = new DataObjectInfo(true, serializer, deserializer); - } else if (serializer != null || deserializer != null) { - dataObject = new DataObjectInfo(false, serializer, deserializer); + } + DataObjectInfo dataObject = null; + if (annotated || serializer != null || deserializer != null) { + dataObject = new DataObjectInfo(annotated, serializer, deserializer); } List typeParams = createTypeParams(type); diff --git a/vertx-codegen-processor/src/stubs/java/io/vertx/core/json/JsonObject.java b/vertx-codegen-processor/src/stubs/java/io/vertx/core/json/JsonObject.java index 5aba82f47..e95818720 100644 --- a/vertx-codegen-processor/src/stubs/java/io/vertx/core/json/JsonObject.java +++ b/vertx-codegen-processor/src/stubs/java/io/vertx/core/json/JsonObject.java @@ -26,8 +26,16 @@ public Iterator> iterator() { return map.entrySet().iterator(); } - public Object getValue(String name) { - return map.get(name); + public T getValue(String name) { + return (T) map.get(name); + } + + private T getValue(String name, T def) { + Object val = map.get(name); + if (val == null) { + return def; + } + return (T) val; } public void remove(String name) { @@ -61,13 +69,13 @@ public Map getMap() { } public JsonObject getJsonObject(String name) { throw new UnsupportedOperationException(); } - public String getString(String name) { throw new UnsupportedOperationException(); } + public String getString(String name) { return getValue(name); } public String getString(String name, String def) { throw new UnsupportedOperationException(); } public Instant getInstant(String name) { throw new UnsupportedOperationException(); } public Instant getInstant(String name, Instant def) { throw new UnsupportedOperationException(); } public Integer getInteger(String fieldName) { throw new UnsupportedOperationException(); } public Boolean getBoolean(String fieldName, Boolean def) { throw new UnsupportedOperationException(); } - public Integer getInteger(String fieldName, Integer def) { throw new UnsupportedOperationException(); } + public Integer getInteger(String fieldName, Integer def) { return getValue(fieldName, def); } public Long getLong(String fieldName, Long def) { throw new UnsupportedOperationException(); } public Float getFloat(String fieldName, Float def) { throw new UnsupportedOperationException(); } public Double getDouble(String fieldName, Double def) { throw new UnsupportedOperationException(); } diff --git a/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/DataObjectTest.java b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/DataObjectTest.java index ec1795829..224657cf4 100644 --- a/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/DataObjectTest.java +++ b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/DataObjectTest.java @@ -16,10 +16,7 @@ import io.vertx.test.codegen.testapi.InvalidInterfaceDataObject; import io.vertx.test.codegen.testdataobject.*; import io.vertx.test.codegen.testdataobject.imported.Imported; -import io.vertx.test.codegen.testdataobject.jsonmapper.DataObjectWithPojoWithMapper; -import io.vertx.test.codegen.testdataobject.jsonmapper.MyEnumWithCustomFactory; -import io.vertx.test.codegen.testdataobject.jsonmapper.MyPojo; -import io.vertx.test.codegen.testdataobject.jsonmapper.DataObjectWithMappedEnum; +import io.vertx.test.codegen.testdataobject.jsonmapper.*; import org.junit.Test; @@ -925,6 +922,27 @@ public void testDataObjectWithJsonMapper() throws Exception { assertTrue(myPojoProperty.getType().getDataObject().isSerializable()); } + @Test + public void testDataObjectWithAutoMapped() throws Exception { + DataObjectModel model = new GeneratorHelper() + .generateDataObject(DataObjectWithAutoMapper.class); + assertNotNull(model); + assertTrue(model.isClass()); + assertTrue(model.getGenerateConverter()); + assertTrue(model.isPublicConverter()); + + PropertyInfo prop = model.getPropertyMap().get("value1"); + assertEquals(ClassKind.OTHER, prop.getType().getKind()); + assertNotNull(prop.getType().getDataObject()); + assertTrue(prop.getType().getDataObject().isDeserializable()); + assertTrue(prop.getType().getDataObject().isSerializable()); + prop = model.getPropertyMap().get("value2"); + assertEquals(ClassKind.API, prop.getType().getKind()); + assertNotNull(prop.getType().getDataObject()); + assertTrue(prop.getType().getDataObject().isDeserializable()); + assertTrue(prop.getType().getDataObject().isSerializable()); + } + @Test public void testCustomEnumWithJsonMapper() throws Exception { DataObjectModel model = new GeneratorHelper() diff --git a/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/AutoMapped.java b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/AutoMapped.java new file mode 100644 index 000000000..4dac213f9 --- /dev/null +++ b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/AutoMapped.java @@ -0,0 +1,44 @@ +package io.vertx.test.codegen.testdataobject.jsonmapper; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject +public interface AutoMapped { + + static AutoMapped fromJson(JsonObject json) { + int port = json.getInteger("port", -1); + String host = json.getString("host"); + return new AutoMapped() { + @Override + public int port() { + return port; + } + @Override + public String host() { + return host; + } + }; + } + + static AutoMapped of(String host, int port) { + return new AutoMapped() { + @Override + public int port() { + return port; + } + @Override + public String host() { + return host; + } + }; + } + + int port(); + + String host(); + + default JsonObject toJson() { + return new JsonObject().put("port", port()).put("host", host()); + } +} diff --git a/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/AutoMappedWithVertxGen.java b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/AutoMappedWithVertxGen.java new file mode 100644 index 000000000..7f32177a7 --- /dev/null +++ b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/AutoMappedWithVertxGen.java @@ -0,0 +1,46 @@ +package io.vertx.test.codegen.testdataobject.jsonmapper; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.codegen.annotations.VertxGen; +import io.vertx.core.json.JsonObject; + +@DataObject +@VertxGen +public interface AutoMappedWithVertxGen { + + static AutoMappedWithVertxGen fromJson(JsonObject json) { + int port = json.getInteger("port", -1); + String host = json.getString("host"); + return new AutoMappedWithVertxGen() { + @Override + public int port() { + return port; + } + @Override + public String host() { + return host; + } + }; + } + + static AutoMapped of(String host, int port) { + return new AutoMapped() { + @Override + public int port() { + return port; + } + @Override + public String host() { + return host; + } + }; + } + + int port(); + + String host(); + + default JsonObject toJson() { + return new JsonObject().put("port", port()).put("host", host()); + } +} diff --git a/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/DataObjectWithAutoMapper.java b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/DataObjectWithAutoMapper.java new file mode 100644 index 000000000..557e05aa5 --- /dev/null +++ b/vertx-codegen-processor/src/test/java/io/vertx/test/codegen/testdataobject/jsonmapper/DataObjectWithAutoMapper.java @@ -0,0 +1,36 @@ +package io.vertx.test.codegen.testdataobject.jsonmapper; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true, publicConverter = true) +public class DataObjectWithAutoMapper { + + AutoMapped value1; + AutoMappedWithVertxGen value2; + + public DataObjectWithAutoMapper(JsonObject obj) { + + } + + public JsonObject toJson() { + return null; + } + + public AutoMapped getValue1() { + return value1; + } + + public DataObjectWithAutoMapper setValue1(AutoMapped value1) { + this.value1 = value1; + return this; + } + + public AutoMappedWithVertxGen getValue2() { + return value2; + } + + public void setValue2(AutoMappedWithVertxGen value2) { + this.value2 = value2; + } +}