From d3e4ca2a788b8be2ff140f8ac410675ebcdadf0e Mon Sep 17 00:00:00 2001 From: Seva Safris Date: Tue, 26 Sep 2023 17:11:45 +0700 Subject: [PATCH] Apply auto-formatting --- binding/src/main/java/org/jsonx/AnyArray.java | 2 +- binding/src/main/java/org/jsonx/AnyCodec.java | 15 +- .../src/main/java/org/jsonx/AnyElement.java | 3 + .../src/main/java/org/jsonx/AnyObject.java | 2 +- .../src/main/java/org/jsonx/AnyProperty.java | 2 + .../src/main/java/org/jsonx/ArrayElement.java | 5 + .../main/java/org/jsonx/ArrayProperty.java | 4 + .../src/main/java/org/jsonx/ArrayType.java | 2 + .../main/java/org/jsonx/ArrayValidator.java | 3 +- .../main/java/org/jsonx/BooleanElement.java | 5 + .../main/java/org/jsonx/BooleanProperty.java | 3 + .../src/main/java/org/jsonx/BooleanType.java | 2 + .../src/main/java/org/jsonx/JxDecoder.java | 138 +++++----- .../src/main/java/org/jsonx/JxEncoder.java | 16 +- .../main/java/org/jsonx/NumberElement.java | 7 + .../main/java/org/jsonx/NumberProperty.java | 5 + .../src/main/java/org/jsonx/NumberType.java | 3 + .../main/java/org/jsonx/ObjectElement.java | 4 + .../main/java/org/jsonx/ObjectProperty.java | 2 + .../main/java/org/jsonx/PrimitiveCodec.java | 4 +- binding/src/main/java/org/jsonx/Range.java | 4 +- .../main/java/org/jsonx/StringElement.java | 6 + .../main/java/org/jsonx/StringProperty.java | 4 + .../src/main/java/org/jsonx/StringType.java | 2 + binding/src/main/java/org/jsonx/t.java | 10 +- .../test/java/org/jsonx/ArrayCodecTest.java | 22 +- binding/src/test/java/org/jsonx/Invalid.java | 36 +-- .../src/test/java/org/jsonx/JsdUtilTest.java | 24 +- .../src/test/java/org/jsonx/LibraryTest.java | 22 +- .../test/java/org/jsonx/ParseArrayTest.java | 4 +- .../src/test/java/org/jsonx/TestArray.java | 86 +++--- binding/src/test/java/org/jsonx/TestUtil.java | 4 +- .../test/java/org/jsonx/library/Address.java | 13 +- .../src/test/java/org/jsonx/library/Book.java | 10 +- .../test/java/org/jsonx/library/Employee.java | 2 +- .../java/org/jsonx/library/Individual.java | 6 +- .../test/java/org/jsonx/library/Library.java | 32 +-- .../java/org/jsonx/library/OnlineArticle.java | 2 +- .../java/org/jsonx/library/Publication.java | 14 +- .../java/org/jsonx/library/Publishing.java | 4 +- .../main/java/org/jsonx/AnnotationType.java | 10 +- .../src/main/java/org/jsonx/AnyModel.java | 18 +- .../src/main/java/org/jsonx/AttributeMap.java | 2 +- .../src/main/java/org/jsonx/BooleanModel.java | 18 +- .../src/main/java/org/jsonx/ClassSpec.java | 2 +- generator/src/main/java/org/jsonx/Member.java | 16 +- .../src/main/java/org/jsonx/NumberModel.java | 18 +- .../src/main/java/org/jsonx/ObjectModel.java | 8 +- .../src/main/java/org/jsonx/Reference.java | 6 +- .../src/main/java/org/jsonx/Referrer.java | 3 +- .../src/main/java/org/jsonx/Registry.java | 4 +- .../main/java/org/jsonx/SchemaElement.java | 15 +- .../src/main/java/org/jsonx/Settings.java | 20 +- generator/src/main/java/org/jsonx/Spec.java | 2 +- .../src/main/java/org/jsonx/StringModel.java | 24 +- generator/src/main/java/org/jsonx/schema.java | 244 +++++++++--------- .../src/test/java/org/jsonx/SchemaTest.java | 42 +-- .../main/java/org/jsonx/JxObjectProvider.java | 3 +- .../java/org/jsonx/JxObjectProviderTest.java | 6 +- .../src/main/java/org/jsonx/ConvertMojo.java | 4 +- .../src/main/java/org/jsonx/GenerateMojo.java | 12 +- .../src/main/java/org/jsonx/JxMojo.java | 2 +- .../src/main/java/org/jsonx/ValidateMojo.java | 6 +- .../src/test/java/org/jsonx/AnyTrial.java | 2 +- .../src/test/java/org/jsonx/ArrayTrial.java | 4 +- .../src/test/java/org/jsonx/BooleanTrial.java | 2 +- .../src/test/java/org/jsonx/ClassTrial.java | 4 +- .../src/test/java/org/jsonx/NumberTrial.java | 2 +- .../src/test/java/org/jsonx/ObjectTrial.java | 2 +- .../src/test/java/org/jsonx/RuntimeTest.java | 2 +- .../java/org/jsonx/SchemaGeneratorTest.java | 4 +- .../src/test/java/org/jsonx/StringTrial.java | 2 +- .../src/main/java/org/jsonx/JxConverter.java | 16 +- 73 files changed, 587 insertions(+), 472 deletions(-) diff --git a/binding/src/main/java/org/jsonx/AnyArray.java b/binding/src/main/java/org/jsonx/AnyArray.java index 8c4cc8e7..f747b362 100644 --- a/binding/src/main/java/org/jsonx/AnyArray.java +++ b/binding/src/main/java/org/jsonx/AnyArray.java @@ -19,7 +19,7 @@ /** * An {@link ArrayType} that represents any JSON array. */ -@AnyElement(id=0, minOccurs=0) +@AnyElement(id = 0, minOccurs = 0) @ArrayType(elementIds = 0) public @interface AnyArray { } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/AnyCodec.java b/binding/src/main/java/org/jsonx/AnyCodec.java index 77a8bb36..64300415 100644 --- a/binding/src/main/java/org/jsonx/AnyCodec.java +++ b/binding/src/main/java/org/jsonx/AnyCodec.java @@ -45,7 +45,8 @@ else if (annotationType == AnyProperty.class) final int len = types.length; if (firstChar == '[') { t type = len > 0 ? types[0] : AnyType.arrays; - int i = 0; do { + int i = 0; + do { final Class arrays = type.arrays(); if (AnyType.isEnabled(arrays)) { final int index = reader.getIndex(); @@ -68,7 +69,8 @@ else if (annotationType == AnyProperty.class) } else if (firstChar == '{') { t type = len > 0 ? types[0] : AnyType.objects; - int i = 0; do { + int i = 0; + do { final Class objects = type.objects(); if (AnyType.isEnabled(objects)) { final Object value = ObjectCodec.decodeArray(objects, token, reader, validate, onPropertyDecode); @@ -88,7 +90,8 @@ else if (firstChar == '{') { } else { t type = len > 0 ? types[0] : AnyType.fromToken(token); - int i = 0; do { + int i = 0; + do { final BooleanType booleans; final NumberType numbers; final StringType strings; @@ -124,7 +127,8 @@ static Error encodeArray(final AnyElement annotation, final Object object, final Error error = Error.NULL; final int len = types.length; t type = len > 0 ? types[0] : AnyType.fromObject(object); - int i = 0; do { + int i = 0; + do { final StringType strings; final NumberType numbers; final BooleanType booleans; @@ -177,7 +181,8 @@ static Object encodeObject(final Annotation annotation, final Method getMethod, StringBuilder builder = null; final int len = types.length; t type = len > 0 ? types[0] : AnyType.fromObject(object); - int i = 0; do { + int i = 0; + do { final StringType strings; final NumberType numbers; final BooleanType booleans; diff --git a/binding/src/main/java/org/jsonx/AnyElement.java b/binding/src/main/java/org/jsonx/AnyElement.java index 5f20dc65..f2be002e 100644 --- a/binding/src/main/java/org/jsonx/AnyElement.java +++ b/binding/src/main/java/org/jsonx/AnyElement.java @@ -27,8 +27,11 @@ @Repeatable(AnyElements.class) public @interface AnyElement { int id(); + boolean nullable() default true; + int minOccurs() default 1; + int maxOccurs() default Integer.MAX_VALUE; t[] types() default {}; diff --git a/binding/src/main/java/org/jsonx/AnyObject.java b/binding/src/main/java/org/jsonx/AnyObject.java index 7aebc13e..a617f34e 100644 --- a/binding/src/main/java/org/jsonx/AnyObject.java +++ b/binding/src/main/java/org/jsonx/AnyObject.java @@ -25,7 +25,7 @@ public class AnyObject implements JxObject { private LinkedHashMap properties; - @AnyProperty(name=".*") + @AnyProperty(name = ".*") public LinkedHashMap getProperties() { return properties; } diff --git a/binding/src/main/java/org/jsonx/AnyProperty.java b/binding/src/main/java/org/jsonx/AnyProperty.java index 0e208291..8ebe963e 100644 --- a/binding/src/main/java/org/jsonx/AnyProperty.java +++ b/binding/src/main/java/org/jsonx/AnyProperty.java @@ -25,7 +25,9 @@ @Retention(RetentionPolicy.RUNTIME) public @interface AnyProperty { String name(); + boolean nullable() default true; + Use use() default Use.REQUIRED; t[] types() default {}; diff --git a/binding/src/main/java/org/jsonx/ArrayElement.java b/binding/src/main/java/org/jsonx/ArrayElement.java index 4f06a459..e291a02e 100644 --- a/binding/src/main/java/org/jsonx/ArrayElement.java +++ b/binding/src/main/java/org/jsonx/ArrayElement.java @@ -28,12 +28,17 @@ @Repeatable(ArrayElements.class) public @interface ArrayElement { int id(); + boolean nullable() default true; + int minOccurs() default 1; + int maxOccurs() default Integer.MAX_VALUE; int minIterate() default 1; + int maxIterate() default 1; + int[] elementIds() default {}; Class type() default ArrayType.class; diff --git a/binding/src/main/java/org/jsonx/ArrayProperty.java b/binding/src/main/java/org/jsonx/ArrayProperty.java index 07609bf2..42b54f9f 100644 --- a/binding/src/main/java/org/jsonx/ArrayProperty.java +++ b/binding/src/main/java/org/jsonx/ArrayProperty.java @@ -26,11 +26,15 @@ @Retention(RetentionPolicy.RUNTIME) public @interface ArrayProperty { String name(); + boolean nullable() default true; + Use use() default Use.REQUIRED; int minIterate() default 1; + int maxIterate() default 1; + int[] elementIds() default {}; Class type() default ArrayType.class; diff --git a/binding/src/main/java/org/jsonx/ArrayType.java b/binding/src/main/java/org/jsonx/ArrayType.java index 6be040ec..726d3fdf 100644 --- a/binding/src/main/java/org/jsonx/ArrayType.java +++ b/binding/src/main/java/org/jsonx/ArrayType.java @@ -25,6 +25,8 @@ @Retention(RetentionPolicy.RUNTIME) public @interface ArrayType { int minIterate() default 1; + int maxIterate() default 1; + int[] elementIds(); } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/ArrayValidator.java b/binding/src/main/java/org/jsonx/ArrayValidator.java index b01cb525..a005a11f 100644 --- a/binding/src/main/java/org/jsonx/ArrayValidator.java +++ b/binding/src/main/java/org/jsonx/ArrayValidator.java @@ -229,7 +229,8 @@ else if (annotation instanceof AnyElement) { error = iterator.validate(annotation, index, relations, idToElement, codecType, validate, onPropertyDecode); } - // System.err.println("m[" + index + "], a[" + a + "], o(" + minOccurs + ", " + maxOccurs + ")[" + occurrence + "], i(" + minIterate + ", " + maxIterate + ")[" + iteration + "]"); + // System.err.println("m[" + index + "], a[" + a + "], o(" + minOccurs + ", " + maxOccurs + ")[" + occurrence + "], i(" + minIterate + // + ", " + maxIterate + ")[" + iteration + "]"); try { // int before; diff --git a/binding/src/main/java/org/jsonx/BooleanElement.java b/binding/src/main/java/org/jsonx/BooleanElement.java index 5d1749f8..75b69c31 100644 --- a/binding/src/main/java/org/jsonx/BooleanElement.java +++ b/binding/src/main/java/org/jsonx/BooleanElement.java @@ -27,11 +27,16 @@ @Retention(RetentionPolicy.RUNTIME) public @interface BooleanElement { int id(); + boolean nullable() default true; + int minOccurs() default 1; + int maxOccurs() default Integer.MAX_VALUE; Class type() default Boolean.class; + String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/BooleanProperty.java b/binding/src/main/java/org/jsonx/BooleanProperty.java index e69b94c5..e0b5d60f 100644 --- a/binding/src/main/java/org/jsonx/BooleanProperty.java +++ b/binding/src/main/java/org/jsonx/BooleanProperty.java @@ -25,9 +25,12 @@ @Retention(RetentionPolicy.RUNTIME) public @interface BooleanProperty { String name(); + boolean nullable() default true; + Use use() default Use.REQUIRED; String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/BooleanType.java b/binding/src/main/java/org/jsonx/BooleanType.java index 158a3b0b..4a54d096 100644 --- a/binding/src/main/java/org/jsonx/BooleanType.java +++ b/binding/src/main/java/org/jsonx/BooleanType.java @@ -25,6 +25,8 @@ @Retention(RetentionPolicy.RUNTIME) public @interface BooleanType { Class type() default Boolean.class; + String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/JxDecoder.java b/binding/src/main/java/org/jsonx/JxDecoder.java index 62d8e40a..f93e68ca 100644 --- a/binding/src/main/java/org/jsonx/JxDecoder.java +++ b/binding/src/main/java/org/jsonx/JxDecoder.java @@ -39,8 +39,7 @@ public static final class Builder { private boolean validate; /** - * Sets the "validation" option for the {@link JxDecoder}, specifying whether validation is to occur while decoding JSON - * documents. + * Sets the "validation" option for the {@link JxDecoder}, specifying whether validation is to occur while decoding JSON documents. * * @param validation The "validation" option for the {@link JxDecoder}, specifying whether validation is to occur while decoding * JSON documents. @@ -54,8 +53,8 @@ public Builder withValidation(final boolean validation) { private Function messageFunction; /** - * Sets a {@link Function Function<DecodeException,String>} that is to be used by the {@link DecodeException} class for - * the construction of each new instance's detail {@linkplain DecodeException#getMessage() message}. + * Sets a {@link Function Function<DecodeException,String>} that is to be used by the {@link DecodeException} class for the + * construction of each new instance's detail {@linkplain DecodeException#getMessage() message}. * * @param messageFunction The {@link Function Function<DecodeException,String>} that is to be used by the * {@link DecodeException} class for the construction of each new instance's detail @@ -143,8 +142,8 @@ private Object parseObject(final JsonReader reader, final TriPredicate The type parameter for the return object of {@link JxObject} class. * @param reader The {@link JsonReader} containing the JSON object. @@ -162,7 +161,7 @@ private Object parseObject(final JsonReader reader, final TriPredicateT parseObject(final JsonReader reader, final TriPredicate onPropertyDecode, final Class type) throws DecodeException, IOException, JsonParseException { + public final T parseObject(final JsonReader reader, final TriPredicate onPropertyDecode, final Class type) throws DecodeException, IOException, JsonParseException { final Object result = parseObject(reader, onPropertyDecode, type, null); if (result instanceof DecodeException) throw (DecodeException)result; @@ -173,8 +172,8 @@ public final T parseObject(final JsonReader reader, final Tr /** * Parses a JSON object from the provided string supplying the JSON document as per the specification of the provided * {@link JxObject} class defining the schema of the document. This method attempts to parse the supplied JSON document as per the - * specification of the provided {@link JxObject} class, and returns the parsed JSON object, or throws a {@link DecodeException} - * if the provided {@link JxObject} class could parse the supplied document. + * specification of the provided {@link JxObject} class, and returns the parsed JSON object, or throws a {@link DecodeException} if + * the provided {@link JxObject} class could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param json The string document containing a JSON object. @@ -191,7 +190,7 @@ public final T parseObject(final JsonReader reader, final Tr * @throws IOException If an I/O error has occurred. * @throws NullPointerException If {@code json} or {@code type} is null. */ - public final T parseObject(final String json, final TriPredicate onPropertyDecode, final Class type) throws DecodeException, IOException, JsonParseException { + public final T parseObject(final String json, final TriPredicate onPropertyDecode, final Class type) throws DecodeException, IOException, JsonParseException { try (final JsonReader in = new JsonReader(json)) { return parseObject(in, onPropertyDecode, type); } @@ -200,8 +199,8 @@ public final T parseObject(final String json, final TriPredi /** * Parses a JSON object from the provided {@link JsonReader} supplying the JSON document as per the specification of the provided * {@link JxObject} class defining the schema of the document. This method attempts to parse the supplied JSON document as per the - * specification of the provided {@link JxObject} class, and returns the parsed JSON object, or throws a {@link DecodeException} - * if the provided {@link JxObject} class could parse the supplied document. + * specification of the provided {@link JxObject} class, and returns the parsed JSON object, or throws a {@link DecodeException} if + * the provided {@link JxObject} class could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param reader The {@link JsonReader} containing the JSON object. @@ -211,15 +210,15 @@ public final T parseObject(final String json, final TriPredi * @throws IOException If an I/O error has occurred. * @throws NullPointerException If {@code reader} or {@code type} is null. */ - public final T parseObject(final JsonReader reader, final Class type) throws DecodeException, IOException { + public final T parseObject(final JsonReader reader, final Class type) throws DecodeException, IOException { return parseObject(reader, null, type); } /** * Parses a JSON object from the provided string supplying the JSON document as per the specification of the provided * {@link JxObject} class defining the schema of the document. This method attempts to parse the supplied JSON document as per the - * specification of the provided {@link JxObject} class, and returns the parsed JSON object, or throws a {@link DecodeException} - * if the provided {@link JxObject} class could parse the supplied document. + * specification of the provided {@link JxObject} class, and returns the parsed JSON object, or throws a {@link DecodeException} if + * the provided {@link JxObject} class could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param json The string document containing a JSON object. @@ -229,7 +228,7 @@ public final T parseObject(final JsonReader reader, final Cl * @throws IOException If an I/O error has occurred. * @throws NullPointerException If {@code json} or {@code type} is null. */ - public final T parseObject(final String json, final Class type) throws DecodeException, IOException { + public final T parseObject(final String json, final Class type) throws DecodeException, IOException { try (final JsonReader in = new JsonReader(json)) { return parseObject(in, type); } @@ -237,9 +236,9 @@ public final T parseObject(final String json, final Class The type parameter for the return object of {@link JxObject} class. * @param reader The {@link JsonReader} containing the JSON object. @@ -259,7 +258,7 @@ public final T parseObject(final String json, final ClassT parseObject(final JsonReader reader, final TriPredicate onPropertyDecode, final Class ... types) throws DecodeException, IOException, JsonParseException { + public final T parseObject(final JsonReader reader, final TriPredicate onPropertyDecode, final Class ... types) throws DecodeException, IOException, JsonParseException { DecodeException exception = null; for (final Class type : assertNotEmpty(types)) { // [A] final Object result = parseObject(reader, onPropertyDecode, type, exception); @@ -274,9 +273,9 @@ public final T parseObject(final JsonReader reader, final Tr /** * Parses a JSON object from the provided {@link JsonReader} supplying the JSON document as per the specification of the provided - * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per - * the specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or - * throws a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. + * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per the + * specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or throws + * a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param reader The {@link JsonReader} containing the JSON object. @@ -295,7 +294,7 @@ public final T parseObject(final JsonReader reader, final Tr * @throws IllegalArgumentException If {@code types} is null or empty. */ @SuppressWarnings({"null", "unchecked"}) - public final T parseObject(final JsonReader reader, final TriPredicate onPropertyDecode, final Collection> types) throws DecodeException, IOException, JsonParseException { + public final T parseObject(final JsonReader reader, final TriPredicate onPropertyDecode, final Collection> types) throws DecodeException, IOException, JsonParseException { DecodeException exception = null; for (final Class type : assertNotEmpty(types)) { // [C] final Object result = parseObject(reader, onPropertyDecode, type, exception); @@ -310,9 +309,9 @@ public final T parseObject(final JsonReader reader, final Tr /** * Parses a JSON object from the provided string supplying the JSON document as per the specification of the provided - * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per - * the specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or - * throws a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. + * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per the + * specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or throws + * a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param json The string document containing a JSON object. @@ -331,7 +330,7 @@ public final T parseObject(final JsonReader reader, final Tr * @throws IllegalArgumentException If {@code types} is null or empty. */ @SafeVarargs - public final T parseObject(final String json, final TriPredicate onPropertyDecode, final Class ... types) throws DecodeException, IOException, JsonParseException { + public final T parseObject(final String json, final TriPredicate onPropertyDecode, final Class ... types) throws DecodeException, IOException, JsonParseException { try (final JsonReader in = new JsonReader(json)) { return parseObject(in, onPropertyDecode, types); } @@ -339,9 +338,9 @@ public final T parseObject(final String json, final TriPredi /** * Parses a JSON object from the provided string supplying the JSON document as per the specification of the provided - * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per - * the specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or - * throws a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. + * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per the + * specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or throws + * a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param json The string document containing a JSON object. @@ -359,7 +358,7 @@ public final T parseObject(final String json, final TriPredi * @throws NullPointerException If {@code json} is null. * @throws IllegalArgumentException If {@code types} is null or empty. */ - public final T parseObject(final String json, final TriPredicate onPropertyDecode, final Collection> types) throws DecodeException, IOException, JsonParseException { + public final T parseObject(final String json, final TriPredicate onPropertyDecode, final Collection> types) throws DecodeException, IOException, JsonParseException { try (final JsonReader in = new JsonReader(json)) { return parseObject(in, onPropertyDecode, types); } @@ -367,9 +366,9 @@ public final T parseObject(final String json, final TriPredi /** * Parses a JSON object from the provided {@link JsonReader} supplying the JSON document as per the specification of the provided - * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per - * the specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or - * throws a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. + * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per the + * specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or throws + * a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param reader The {@link JsonReader} containing the JSON object. @@ -381,15 +380,15 @@ public final T parseObject(final String json, final TriPredi * @throws IllegalArgumentException If {@code types} is null or empty. */ @SafeVarargs - public final T parseObject(final JsonReader reader, final Class ... types) throws DecodeException, IOException { + public final T parseObject(final JsonReader reader, final Class ... types) throws DecodeException, IOException { return parseObject(reader, null, types); } /** * Parses a JSON object from the provided {@link JsonReader} supplying the JSON document as per the specification of the provided - * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per - * the specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or - * throws a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. + * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per the + * specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or throws + * a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param reader The {@link JsonReader} containing the JSON object. @@ -400,15 +399,15 @@ public final T parseObject(final JsonReader reader, final Cl * @throws NullPointerException If {@code reader} is null. * @throws IllegalArgumentException If {@code types} is null or empty. */ - public final T parseObject(final JsonReader reader, final Collection> types) throws DecodeException, IOException { + public final T parseObject(final JsonReader reader, final Collection> types) throws DecodeException, IOException { return parseObject(reader, null, types); } /** * Parses a JSON object from the provided string supplying the JSON document as per the specification of the provided - * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per - * the specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or - * throws a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. + * {@link JxObject} classes defining the schema of the document. This method attempts to parse the supplied JSON document as per the + * specification of the provided {@link JxObject} classes in order, and returns the first successfully parsed JSON object, or throws + * a {@link DecodeException} if none of the provided {@link JxObject} classes could parse the supplied document. * * @param The type parameter for the return object of {@link JxObject} class. * @param json The string document containing a JSON object. @@ -420,7 +419,7 @@ public final T parseObject(final JsonReader reader, final Co * @throws IllegalArgumentException If {@code types} is null or empty. */ @SafeVarargs - public final T parseObject(final String json, final Class ... types) throws DecodeException, IOException { + public final T parseObject(final String json, final Class ... types) throws DecodeException, IOException { try (final JsonReader in = new JsonReader(json)) { return parseObject(in, types); } @@ -428,9 +427,9 @@ public final T parseObject(final String json, final Class The type parameter for the return object of {@link JxObject} class. * @param json The string document containing a JSON object. @@ -441,7 +440,7 @@ public final T parseObject(final String json, final ClassT parseObject(final String json, final Collection> types) throws DecodeException, IOException { + public final T parseObject(final String json, final Collection> types) throws DecodeException, IOException { try (final JsonReader in = new JsonReader(json)) { return parseObject(in, types); } @@ -467,10 +466,9 @@ private Object parseArray(final JsonReader reader, final Class parseArray(final JsonReader reader, final Class parseArray(final String json, final Class parseArray(final JsonReader reader, final Class parseArray(final JsonReader reader, final Collection parseArray(final String json, final Class type() default Number.class; + String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/NumberProperty.java b/binding/src/main/java/org/jsonx/NumberProperty.java index 88d789e8..6e93cafe 100644 --- a/binding/src/main/java/org/jsonx/NumberProperty.java +++ b/binding/src/main/java/org/jsonx/NumberProperty.java @@ -25,11 +25,16 @@ @Retention(RetentionPolicy.RUNTIME) public @interface NumberProperty { String name(); + boolean nullable() default true; + Use use() default Use.REQUIRED; + int scale() default Integer.MAX_VALUE; + String range() default ""; String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/NumberType.java b/binding/src/main/java/org/jsonx/NumberType.java index 6e12d757..c998beb5 100644 --- a/binding/src/main/java/org/jsonx/NumberType.java +++ b/binding/src/main/java/org/jsonx/NumberType.java @@ -25,9 +25,12 @@ @Retention(RetentionPolicy.RUNTIME) public @interface NumberType { int scale() default Integer.MAX_VALUE; + String range() default ""; Class type() default Number.class; + String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/ObjectElement.java b/binding/src/main/java/org/jsonx/ObjectElement.java index f6bc7c05..0ee34bd8 100644 --- a/binding/src/main/java/org/jsonx/ObjectElement.java +++ b/binding/src/main/java/org/jsonx/ObjectElement.java @@ -27,8 +27,12 @@ @Retention(RetentionPolicy.RUNTIME) public @interface ObjectElement { int id(); + Class type(); + boolean nullable() default true; + int minOccurs() default 1; + int maxOccurs() default Integer.MAX_VALUE; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/ObjectProperty.java b/binding/src/main/java/org/jsonx/ObjectProperty.java index 20544627..49de53e4 100644 --- a/binding/src/main/java/org/jsonx/ObjectProperty.java +++ b/binding/src/main/java/org/jsonx/ObjectProperty.java @@ -27,6 +27,8 @@ @Retention(RetentionPolicy.RUNTIME) public @interface ObjectProperty { String name(); + boolean nullable() default true; + Use use() default Use.REQUIRED; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/PrimitiveCodec.java b/binding/src/main/java/org/jsonx/PrimitiveCodec.java index 2581442a..ba2eae39 100644 --- a/binding/src/main/java/org/jsonx/PrimitiveCodec.java +++ b/binding/src/main/java/org/jsonx/PrimitiveCodec.java @@ -55,12 +55,12 @@ else if ((method = parameterTypeToMethod.get(parameterClassName)) != null) { @Override Class type() { - return this.type; + return type; } @Override Executable decode() { - return this.decode; + return decode; } final Error matches(final String json, final JsonReader reader) { diff --git a/binding/src/main/java/org/jsonx/Range.java b/binding/src/main/java/org/jsonx/Range.java index c9c2b5e4..5145152d 100644 --- a/binding/src/main/java/org/jsonx/Range.java +++ b/binding/src/main/java/org/jsonx/Range.java @@ -54,7 +54,7 @@ public static Range from(final String string, final int scale, Class type) th return range; } - private static N parseNumber(final StringBuilder b, final String string, final int start, final boolean commaOk, final Class type) throws ParseException { + private static N parseNumber(final StringBuilder b, final String string, final int start, final boolean commaOk, final Class type) throws ParseException { try { for (int i = start, end = string.length() - 1; i < end; ++i) { // [N] final char ch = string.charAt(i); @@ -106,7 +106,7 @@ private static String toString(final Number number) { private final int hashCode; private final String toString; - Range(final N min, final boolean minInclusive, final N max, final boolean maxInclusive) { + Range(final N min, final boolean minInclusive, final N max, final boolean maxInclusive) { this.min = min; this.minStr = toString(min); this.minInclusive = minInclusive; diff --git a/binding/src/main/java/org/jsonx/StringElement.java b/binding/src/main/java/org/jsonx/StringElement.java index 307e2665..7692586e 100644 --- a/binding/src/main/java/org/jsonx/StringElement.java +++ b/binding/src/main/java/org/jsonx/StringElement.java @@ -27,12 +27,18 @@ @Retention(RetentionPolicy.RUNTIME) public @interface StringElement { int id(); + boolean nullable() default true; + String pattern() default ""; + int minOccurs() default 1; + int maxOccurs() default Integer.MAX_VALUE; Class type() default String.class; + String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/StringProperty.java b/binding/src/main/java/org/jsonx/StringProperty.java index fc8ae13c..38dd45ef 100644 --- a/binding/src/main/java/org/jsonx/StringProperty.java +++ b/binding/src/main/java/org/jsonx/StringProperty.java @@ -25,10 +25,14 @@ @Retention(RetentionPolicy.RUNTIME) public @interface StringProperty { String name(); + boolean nullable() default true; + Use use() default Use.REQUIRED; + String pattern() default ""; String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/StringType.java b/binding/src/main/java/org/jsonx/StringType.java index 30f02470..8003b26b 100644 --- a/binding/src/main/java/org/jsonx/StringType.java +++ b/binding/src/main/java/org/jsonx/StringType.java @@ -27,6 +27,8 @@ String pattern() default ""; Class type() default String.class; + String decode() default ""; + String encode() default ""; } \ No newline at end of file diff --git a/binding/src/main/java/org/jsonx/t.java b/binding/src/main/java/org/jsonx/t.java index fe19bba6..b5badb4c 100644 --- a/binding/src/main/java/org/jsonx/t.java +++ b/binding/src/main/java/org/jsonx/t.java @@ -22,9 +22,13 @@ @Retention(RetentionPolicy.RUNTIME) public @interface t { - BooleanType booleans() default @BooleanType(decode="\0"); - NumberType numbers() default @NumberType(decode="\0"); - StringType strings() default @StringType(decode="\0"); + BooleanType booleans() default @BooleanType(decode = "\0"); + + NumberType numbers() default @NumberType(decode = "\0"); + + StringType strings() default @StringType(decode = "\0"); + Class arrays() default Annotation.class; + Class objects() default JxObject.class; } \ No newline at end of file diff --git a/binding/src/test/java/org/jsonx/ArrayCodecTest.java b/binding/src/test/java/org/jsonx/ArrayCodecTest.java index 51a9bbe2..a9b7a15f 100644 --- a/binding/src/test/java/org/jsonx/ArrayCodecTest.java +++ b/binding/src/test/java/org/jsonx/ArrayCodecTest.java @@ -203,29 +203,29 @@ private static void assertMembersEqual(final List expected, final Relations a } } - @NumberElement(id=0, maxOccurs=1, range="xxxx") - @ArrayType(elementIds={0}) + @NumberElement(id = 0, maxOccurs = 1, range = "xxxx") + @ArrayType(elementIds = {0}) private @interface ArrayError1 { } - @BooleanElement(id=0, maxOccurs=0, nullable=false) - @ArrayType(elementIds={0}) + @BooleanElement(id = 0, maxOccurs = 0, nullable = false) + @ArrayType(elementIds = {0}) private @interface ArrayError2 { } - @BooleanElement(id=0, maxOccurs=-1, nullable=false) - @ArrayType(elementIds={-1}) + @BooleanElement(id = 0, maxOccurs = -1, nullable = false) + @ArrayType(elementIds = {-1}) private @interface ArrayError3 { } - @BooleanElement(id=0, maxOccurs=-1, nullable=false) - @ArrayType(elementIds={}) + @BooleanElement(id = 0, maxOccurs = -1, nullable = false) + @ArrayType(elementIds = {}) private @interface ArrayError4 { } - @BooleanElement(id=0, nullable=false) - @BooleanElement(id=0, nullable=false) - @ArrayType(elementIds={0}) + @BooleanElement(id = 0, nullable = false) + @BooleanElement(id = 0, nullable = false) + @ArrayType(elementIds = {0}) private @interface ArrayError5 { } diff --git a/binding/src/test/java/org/jsonx/Invalid.java b/binding/src/test/java/org/jsonx/Invalid.java index 71af824e..70179d72 100644 --- a/binding/src/test/java/org/jsonx/Invalid.java +++ b/binding/src/test/java/org/jsonx/Invalid.java @@ -36,7 +36,7 @@ public void setNoProperty(final Boolean noProperty) { public static class InvalidName implements JxObject { private Boolean invalidName; - @BooleanProperty(name="foo") + @BooleanProperty(name = "foo") public Boolean getInvalidName() { return this.invalidName; } @@ -49,7 +49,7 @@ public void setInvalidName(final Boolean invalidName) { public static class InvalidType implements JxObject { private Boolean invalidType; - @BooleanProperty(name="invalidType", use=Use.OPTIONAL) + @BooleanProperty(name = "invalidType", use = Use.OPTIONAL) public Boolean getInvalidType() { return this.invalidType; } @@ -62,7 +62,7 @@ public void setInvalidType(final Boolean invalidType) { public static class Bool implements JxObject { private Number invalidType; - @BooleanProperty(name="invalidType", use=Use.OPTIONAL, nullable=false) + @BooleanProperty(name = "invalidType", use = Use.OPTIONAL, nullable = false) public Number getInvalidType() { return this.invalidType; } @@ -73,7 +73,7 @@ public void setInvalidType(final Number invalidType) { private Boolean invalidAnnotation; - @NumberProperty(name="invalidAnnotation", use=Use.OPTIONAL, nullable=false) + @NumberProperty(name = "invalidAnnotation", use = Use.OPTIONAL, nullable = false) public Boolean getInvalidAnnotation() { return this.invalidAnnotation; } @@ -86,7 +86,7 @@ public void setInvalidAnnotation(final Boolean invalidAnnotation) { public static class NumRange implements JxObject { private Optional invalidRange; - @NumberProperty(name="invalidRange", use=Use.OPTIONAL, scale=0, range="[-3,") + @NumberProperty(name = "invalidRange", use = Use.OPTIONAL, scale = 0, range = "[-3,") public Optional getInvalidRange() { return this.invalidRange; } @@ -99,7 +99,7 @@ public void setInvalidRange(final Optional invalidRange) { public static class NumPrimitiveUse implements JxObject { private byte number; - @NumberProperty(name="number", use=Use.OPTIONAL, nullable=false) + @NumberProperty(name = "number", use = Use.OPTIONAL, nullable = false) public byte getNumber() { return this.number; } @@ -112,7 +112,7 @@ public void setNumber(final byte number) { public static class NumPrimitiveNullable implements JxObject { private int number; - @NumberProperty(name="number") + @NumberProperty(name = "number") public int getNumber() { return this.number; } @@ -125,7 +125,7 @@ public void setNumber(final int number) { public static class NumPrimitiveScale implements JxObject { private long number; - @NumberProperty(name="number", nullable=false, scale=1) + @NumberProperty(name = "number", nullable = false, scale = 1) public long getNumber() { return this.number; } @@ -138,7 +138,7 @@ public void setNumber(final long number) { public static class Num implements JxObject { private Boolean invalidType; - @NumberProperty(name="invalidType", use=Use.OPTIONAL, nullable=false) + @NumberProperty(name = "invalidType", use = Use.OPTIONAL, nullable = false) public Boolean getInvalidType() { return this.invalidType; } @@ -149,7 +149,7 @@ public void setInvalidType(final Boolean invalidType) { private Number invalidAnnotation; - @StringProperty(name="invalidAnnotation", use=Use.OPTIONAL, nullable=false) + @StringProperty(name = "invalidAnnotation", use = Use.OPTIONAL, nullable = false) public Number getInvalidAnnotation() { return this.invalidAnnotation; } @@ -160,7 +160,7 @@ public void setInvalidAnnotation(final Number invalidAnnotation) { private Optional invalidScale; - @NumberProperty(name="invalidScale", use=Use.OPTIONAL, scale=-1) + @NumberProperty(name = "invalidScale", use = Use.OPTIONAL, scale = -1) public Optional getInvalidScale() { return this.invalidScale; } @@ -173,7 +173,7 @@ public void setInvalidScale(final Optional invalidScale) { public static class Str implements JxObject { private Optional invalidType; - @StringProperty(name="invalidType", use=Use.OPTIONAL) + @StringProperty(name = "invalidType", use = Use.OPTIONAL) public Optional getInvalidType() { return this.invalidType; } @@ -184,7 +184,7 @@ public void setInvalidType(final Optional invalidType) { private Optional invalidAnnotation; - @BooleanProperty(name="invalidAnnotation", use=Use.OPTIONAL) + @BooleanProperty(name = "invalidAnnotation", use = Use.OPTIONAL) public Optional getInvalidAnnotation() { return this.invalidAnnotation; } @@ -195,7 +195,7 @@ public void setInvalidAnnotation(final Optional invalidAnnotation) { private Optional invalidPattern; - @StringProperty(name="invalidPattern", use=Use.OPTIONAL, pattern="[0-9]{{2,4}") + @StringProperty(name = "invalidPattern", use = Use.OPTIONAL, pattern = "[0-9]{{2,4}") public Optional getInvalidPattern() { return this.invalidPattern; } @@ -208,7 +208,7 @@ public void setInvalidPattern(final Optional invalidPattern) { public static class ArrAnnotationType implements JxObject { private Optional> invalidAnnotationType; - @ArrayProperty(name="invalidAnnotationType", use=Use.OPTIONAL, type=Override.class) + @ArrayProperty(name = "invalidAnnotationType", use = Use.OPTIONAL, type = Override.class) public Optional> getInvalidAnnotationType() { return this.invalidAnnotationType; } @@ -221,8 +221,8 @@ public void setInvalidAnnotationType(final Optional> invalidAnnotationTy public static class Arr implements JxObject { private Optional invalidType; - @StringElement(id=0) - @ArrayProperty(name="invalidType", use=Use.OPTIONAL, elementIds={0}) + @StringElement(id = 0) + @ArrayProperty(name = "invalidType", use = Use.OPTIONAL, elementIds = {0}) public Optional getInvalidType() { return this.invalidType; } @@ -233,7 +233,7 @@ public void setInvalidType(final Optional invalidType) { private List invalidAnnotation; - @BooleanProperty(name="invalidAnnotation", use=Use.OPTIONAL, nullable=false) + @BooleanProperty(name = "invalidAnnotation", use = Use.OPTIONAL, nullable = false) public List getInvalidAnnotation() { return this.invalidAnnotation; } diff --git a/binding/src/test/java/org/jsonx/JsdUtilTest.java b/binding/src/test/java/org/jsonx/JsdUtilTest.java index 3a9a1b30..a542af8f 100644 --- a/binding/src/test/java/org/jsonx/JsdUtilTest.java +++ b/binding/src/test/java/org/jsonx/JsdUtilTest.java @@ -40,7 +40,7 @@ public class JsdUtilTest { private static class TestObject1 implements JxObject { public Object _any; - @AnyProperty(name="any") + @AnyProperty(name = "any") public Object getAny() { return this._any; } @@ -51,7 +51,7 @@ public void setAny(final Object _any) { public List _array; - @ArrayProperty(name="array") + @ArrayProperty(name = "array") public List getArray() { return this._array; } @@ -62,7 +62,7 @@ public void setArray(final List _array) { public Boolean _boolean; - @BooleanProperty(name="boolean") + @BooleanProperty(name = "boolean") public Boolean getBoolean() { return this._boolean; } @@ -73,7 +73,7 @@ public void setBoolean(final Boolean _boolean) { public BigInteger _number; - @NumberProperty(name="number") + @NumberProperty(name = "number") public BigInteger getNumber() { return this._number; } @@ -84,7 +84,7 @@ public void setNumber(final BigInteger _number) { public TestObject1 _object; - @ObjectProperty(name="object") + @ObjectProperty(name = "object") public TestObject1 getObject() { return this._object; } @@ -95,7 +95,7 @@ public void setObject(final TestObject1 _object) { public String _string; - @StringProperty(name="string") + @StringProperty(name = "string") public String getString() { return this._string; } @@ -109,7 +109,7 @@ public void setString(final String _string) { private static class TestObject2 implements JxObject { public Object _any; - @AnyProperty(name="any") + @AnyProperty(name = "any") public Object any() { return this._any; } @@ -120,7 +120,7 @@ public void any(final Object _any) { public List _array; - @ArrayProperty(name="array") + @ArrayProperty(name = "array") public List array() { return this._array; } @@ -131,7 +131,7 @@ public void array(final List _array) { public Boolean _boolean; - @BooleanProperty(name="boolean") + @BooleanProperty(name = "boolean") public Boolean _boolean() { return this._boolean; } @@ -142,7 +142,7 @@ public void _boolean(final Boolean _boolean) { public BigInteger _number; - @NumberProperty(name="number") + @NumberProperty(name = "number") public BigInteger number() { return this._number; } @@ -153,7 +153,7 @@ public void number(final BigInteger _number) { public TestObject2 _object; - @ObjectProperty(name="object") + @ObjectProperty(name = "object") public TestObject2 object() { return this._object; } @@ -164,7 +164,7 @@ public void object(final TestObject2 _object) { public String _string; - @StringProperty(name="string") + @StringProperty(name = "string") public String string() { return this._string; } diff --git a/binding/src/test/java/org/jsonx/LibraryTest.java b/binding/src/test/java/org/jsonx/LibraryTest.java index 32893a9d..b2dc3dd5 100644 --- a/binding/src/test/java/org/jsonx/LibraryTest.java +++ b/binding/src/test/java/org/jsonx/LibraryTest.java @@ -126,8 +126,9 @@ public void testLibrary() throws DecodeException, IOException { book.setTitle("Magical Book"); book.setAuthors(Optional.of(Arrays.asList("Z&$GY 6-4si[1", "Billy Bob", "Jimmy James", "Wendy Woo"))); book.setEditors(Optional.of(Arrays.asList("[&]$b |6)?f)A$", "Silly Willy", "Johnie John", "Randy Dandy"))); - book.setIndex(Arrays.asList(Arrays.asList(1, "Part 1, Chapter 1"), Arrays.asList(2, "Part 1, Chapter 2"), Arrays.asList(3, "Part 1, Chapter 3"), - Arrays.asList(1, "Part 2, Chapter 1"), Arrays.asList(2, "Part 2, Chapter 2"), Arrays.asList(3, "Part 2, Chapter 3"))); + book.setIndex(Arrays.asList(Arrays.asList(1, "Part 1, Chapter 1"), Arrays.asList(2, "Part 1, Chapter 2"), + Arrays.asList(3, "Part 1, Chapter 3"), Arrays.asList(1, "Part 2, Chapter 1"), + Arrays.asList(2, "Part 2, Chapter 2"), Arrays.asList(3, "Part 2, Chapter 3"))); book.setIsbn("978-3-16-148410-0"); book.setPublishings(new ArrayList<>()); book.getPublishings().add(bookPub1); @@ -167,7 +168,8 @@ public void testLibrary() throws DecodeException, IOException { library.setAddress(Optional.of(createAddress())); library.setHandicap(true); final List> schedule = new ArrayList<>(); - for (final String[] slot : new String[][] {{"07:00", "17:00"}, {"08:00", "18:00"}, {"09:00", "19:00"}, {"10:00", "20:00"}, {"11:00", "21:00"}, {"12:00", "22:00"}, {"13:00", "23:00"}}) + for (final String[] slot : new String[][] {{"07:00", "17:00"}, {"08:00", "18:00"}, {"09:00", "19:00"}, + {"10:00", "20:00"}, {"11:00", "21:00"}, {"12:00", "22:00"}, {"13:00", "23:00"}}) schedule.add(Arrays.asList(slot)); library.setSchedule(schedule); @@ -179,7 +181,7 @@ public void testLibrary() throws DecodeException, IOException { library.setStaff(Collections.singletonList(createEmployee())); final String json = encoder.toString(library); - if (logger.isInfoEnabled()) logger.info(json); + if (logger.isInfoEnabled()) { logger.info(json); } JxDecoder.VALIDATING.parseObject(json, Library.class); } @@ -196,4 +198,16 @@ public void testOnPropertyDecode() throws DecodeException, IOException { JxDecoder.VALIDATING.parseObject(json, (o, p, v) -> o instanceof Publishing, Publishing.class); } + + @Test + public void testNullValidateError() throws IOException { + final String json = "{\"number\":1894,\"street\":\"Welcome Circle\",\"city\":\"San Francisco\",\"postalCode\":\"94110\",\"locality\":\"San Francisco\",\"country\":null}"; + try { + JxDecoder.VALIDATING.parseObject(json, Address.class); + fail("Expected DecodeException"); + } + catch (final DecodeException e) { + assertTrue(e.getMessage().startsWith("Property \"country\" is not nullable: null")); + } + } } \ No newline at end of file diff --git a/binding/src/test/java/org/jsonx/ParseArrayTest.java b/binding/src/test/java/org/jsonx/ParseArrayTest.java index 79ca1e3f..524f17ff 100644 --- a/binding/src/test/java/org/jsonx/ParseArrayTest.java +++ b/binding/src/test/java/org/jsonx/ParseArrayTest.java @@ -25,8 +25,8 @@ import org.openjax.json.JsonReader; public class ParseArrayTest { - @NumberElement(id=0, minOccurs=1, nullable=false) - @ArrayType(elementIds={0}) + @NumberElement(id = 0, minOccurs = 1, nullable = false) + @ArrayType(elementIds = {0}) @interface LongArray { } diff --git a/binding/src/test/java/org/jsonx/TestArray.java b/binding/src/test/java/org/jsonx/TestArray.java index d016902d..9db6500d 100644 --- a/binding/src/test/java/org/jsonx/TestArray.java +++ b/binding/src/test/java/org/jsonx/TestArray.java @@ -20,16 +20,16 @@ import java.util.Optional; public class TestArray implements JxObject { - @AnyElement(id=2, types={@t(strings=@StringType)}, minOccurs=0, nullable=false) - @AnyElement(id=1, types={@t(numbers=@NumberType)}, minOccurs=0, nullable=false) - @AnyElement(id=0, types={@t(booleans=@BooleanType)}, minOccurs=0, nullable=false) - @ArrayType(elementIds={0, 1, 2}, minIterate=0, maxIterate=Integer.MAX_VALUE) + @AnyElement(id = 2, types = {@t(strings = @StringType)}, minOccurs = 0, nullable = false) + @AnyElement(id = 1, types = {@t(numbers = @NumberType)}, minOccurs = 0, nullable = false) + @AnyElement(id = 0, types = {@t(booleans = @BooleanType)}, minOccurs = 0, nullable = false) + @ArrayType(elementIds = {0, 1, 2}, minIterate = 0, maxIterate = Integer.MAX_VALUE) @interface ArrayAny { } private Optional> arrayAny; - @ArrayProperty(name="arrayAny", type=ArrayAny.class, use=Use.OPTIONAL) + @ArrayProperty(name = "arrayAny", type = ArrayAny.class, use = Use.OPTIONAL) public Optional> getArrayAny() { return this.arrayAny; } @@ -44,16 +44,16 @@ public TestArray setArrayAny(final List arrayAny) { return this; } - @StringElement(id=2, minOccurs=0, nullable=false) - @NumberElement(id=1, minOccurs=0, nullable=false) - @BooleanElement(id=0, minOccurs=0, nullable=false) - @ArrayType(elementIds={0, 1, 2}, minIterate=0, maxIterate=Integer.MAX_VALUE) + @StringElement(id = 2, minOccurs = 0, nullable = false) + @NumberElement(id = 1, minOccurs = 0, nullable = false) + @BooleanElement(id = 0, minOccurs = 0, nullable = false) + @ArrayType(elementIds = {0, 1, 2}, minIterate = 0, maxIterate = Integer.MAX_VALUE) @interface ArrayLoop { } private Optional> arrayLoop; - @ArrayProperty(name="arrayLoop", type=ArrayLoop.class, use=Use.OPTIONAL) + @ArrayProperty(name = "arrayLoop", type = ArrayLoop.class, use = Use.OPTIONAL) public Optional> getArrayLoop() { return this.arrayLoop; } @@ -68,14 +68,14 @@ public TestArray setArrayLoop(final List arrayLoop) { return this; } - @BooleanElement(id=0, maxOccurs=2) - @ArrayType(elementIds={0}, minIterate=0, maxIterate=2) + @BooleanElement(id = 0, maxOccurs = 2) + @ArrayType(elementIds = {0}, minIterate = 0, maxIterate = 2) @interface Array1d1 { } private Optional> array1d1; - @ArrayProperty(name="array1d1", type=Array1d1.class, use=Use.OPTIONAL) + @ArrayProperty(name = "array1d1", type = Array1d1.class, use = Use.OPTIONAL) public Optional> getArray1d1() { return this.array1d1; } @@ -90,15 +90,15 @@ public TestArray setArray1d1(final List array1d1) { return this; } - @BooleanElement(id=1, maxOccurs=1, nullable=false) - @BooleanElement(id=0, minOccurs=0, maxOccurs=2) - @ArrayType(elementIds={0, 1}, minIterate=3, maxIterate=Integer.MAX_VALUE) + @BooleanElement(id = 1, maxOccurs = 1, nullable = false) + @BooleanElement(id = 0, minOccurs = 0, maxOccurs = 2) + @ArrayType(elementIds = {0, 1}, minIterate = 3, maxIterate = Integer.MAX_VALUE) @interface Array1d2 { } private Optional> array1d2; - @ArrayProperty(name="array1d2", type=Array1d2.class, use=Use.OPTIONAL) + @ArrayProperty(name = "array1d2", type = Array1d2.class, use = Use.OPTIONAL) public Optional> getArray1d2() { return this.array1d2; } @@ -113,18 +113,18 @@ public TestArray setArray1d2(final List array1d2) { return this; } - @NumberElement(id=4, minOccurs=1, maxOccurs=2, range="[0,10]") - @NumberElement(id=3, minOccurs=0, maxOccurs=2, scale=0, range="[0,4]", nullable=false) - @StringElement(id=2, minOccurs=0, maxOccurs=2, pattern="[a-z0-9]+") - @StringElement(id=1, minOccurs=2, maxOccurs=3, pattern="[a-z]+") - @BooleanElement(id=0, minOccurs=0, maxOccurs=3) - @ArrayType(elementIds={0, 1, 2, 3, 4}, minIterate=0, maxIterate=Integer.MAX_VALUE) + @NumberElement(id = 4, minOccurs = 1, maxOccurs = 2, range = "[0,10]") + @NumberElement(id = 3, minOccurs = 0, maxOccurs = 2, scale = 0, range = "[0,4]", nullable = false) + @StringElement(id = 2, minOccurs = 0, maxOccurs = 2, pattern = "[a-z0-9]+") + @StringElement(id = 1, minOccurs = 2, maxOccurs = 3, pattern = "[a-z]+") + @BooleanElement(id = 0, minOccurs = 0, maxOccurs = 3) + @ArrayType(elementIds = {0, 1, 2, 3, 4}, minIterate = 0, maxIterate = Integer.MAX_VALUE) @interface Array1d3 { } private Optional> array1d3; - @ArrayProperty(name="array1d3", type=Array1d3.class, use=Use.OPTIONAL) + @ArrayProperty(name = "array1d3", type = Array1d3.class, use = Use.OPTIONAL) public Optional> getArray1d3() { return this.array1d3; } @@ -139,14 +139,14 @@ public TestArray setArray1d3(final List array1d3) { return this; } - @ArrayElement(id=0, type=Array1d3.class, nullable=false, maxOccurs=1) - @ArrayType(elementIds={0}, minIterate=0, maxIterate=2) + @ArrayElement(id = 0, type = Array1d3.class, nullable = false, maxOccurs = 1) + @ArrayType(elementIds = {0}, minIterate = 0, maxIterate = 2) @interface Array2d1 { } private Optional> array2d1; - @ArrayProperty(name="array2d1", type=Array2d1.class, use=Use.OPTIONAL) + @ArrayProperty(name = "array2d1", type = Array2d1.class, use = Use.OPTIONAL) public Optional> getArray2d1() { return this.array2d1; } @@ -161,23 +161,23 @@ public TestArray setArray2d1(final List array2d1) { return this; } - @NumberElement(id=9, scale=0, range="[0,5]", minOccurs=0, maxOccurs=1, nullable=false) - @NumberElement(id=8, scale=0, range="[5,10]", minOccurs=0, maxOccurs=1, nullable=false) - @NumberElement(id=7, minOccurs=1, maxOccurs=2, range="[0,10]") - @NumberElement(id=6, minOccurs=0, maxOccurs=2, scale=0, range="[0,4]", nullable=false) - @StringElement(id=5, minOccurs=0, maxOccurs=2, pattern="[A-Z0-9]+") - @StringElement(id=4, minOccurs=2, maxOccurs=3, pattern="[A-Z]+") - @BooleanElement(id=3, minOccurs=0, maxOccurs=3) - @ArrayElement(id=2, elementIds={3, 4, 5, 6, 7}, minOccurs=0, maxIterate=2, nullable=false) - @BooleanElement(id=1, minOccurs=0) - @ArrayElement(id=0, type=Array1d3.class, minOccurs=0, nullable=false) - @ArrayType(elementIds={0, 1, 2, 8, 9}) + @NumberElement(id = 9, scale = 0, range = "[0,5]", minOccurs = 0, maxOccurs = 1, nullable = false) + @NumberElement(id = 8, scale = 0, range = "[5,10]", minOccurs = 0, maxOccurs = 1, nullable = false) + @NumberElement(id = 7, minOccurs = 1, maxOccurs = 2, range = "[0,10]") + @NumberElement(id = 6, minOccurs = 0, maxOccurs = 2, scale = 0, range = "[0,4]", nullable = false) + @StringElement(id = 5, minOccurs = 0, maxOccurs = 2, pattern = "[A-Z0-9]+") + @StringElement(id = 4, minOccurs = 2, maxOccurs = 3, pattern = "[A-Z]+") + @BooleanElement(id = 3, minOccurs = 0, maxOccurs = 3) + @ArrayElement(id = 2, elementIds = {3, 4, 5, 6, 7}, minOccurs = 0, maxIterate = 2, nullable = false) + @BooleanElement(id = 1, minOccurs = 0) + @ArrayElement(id = 0, type = Array1d3.class, minOccurs = 0, nullable = false) + @ArrayType(elementIds = {0, 1, 2, 8, 9}) @interface Array2d2 { } private Optional> array2d2; - @ArrayProperty(name="array2d2", type=Array2d2.class, use=Use.OPTIONAL) + @ArrayProperty(name = "array2d2", type = Array2d2.class, use = Use.OPTIONAL) public Optional> getArray2d2() { return this.array2d2; } @@ -192,15 +192,15 @@ public TestArray setArray2d2(final List array2d2) { return this; } - @ArrayElement(id=1, type=Array2d2.class, nullable=false) - @ArrayElement(id=0, type=Array1d3.class, minOccurs=0, nullable=false) - @ArrayType(elementIds={0, 1}) + @ArrayElement(id = 1, type = Array2d2.class, nullable = false) + @ArrayElement(id = 0, type = Array1d3.class, minOccurs = 0, nullable = false) + @ArrayType(elementIds = {0, 1}) @interface Array3d { } private Optional> array3d; - @ArrayProperty(name="array3d", type=Array3d.class, use=Use.OPTIONAL) + @ArrayProperty(name = "array3d", type = Array3d.class, use = Use.OPTIONAL) public Optional> getArray3d() { return this.array3d; } diff --git a/binding/src/test/java/org/jsonx/TestUtil.java b/binding/src/test/java/org/jsonx/TestUtil.java index e87ce9f0..d44276e0 100644 --- a/binding/src/test/java/org/jsonx/TestUtil.java +++ b/binding/src/test/java/org/jsonx/TestUtil.java @@ -28,12 +28,12 @@ static Method getMethod(final Class cls, final String propertyName) throws No } @SafeVarargs - static List l(final T ... members) { + static List l(final T ... members) { return Arrays.asList(members); } @SafeVarargs - static T[] a(final T ... members) { + static T[] a(final T ... members) { return members; } diff --git a/binding/src/test/java/org/jsonx/library/Address.java b/binding/src/test/java/org/jsonx/library/Address.java index 60fbb33c..3413da00 100644 --- a/binding/src/test/java/org/jsonx/library/Address.java +++ b/binding/src/test/java/org/jsonx/library/Address.java @@ -22,11 +22,12 @@ import org.jsonx.JxObject; import org.jsonx.NumberProperty; import org.jsonx.StringProperty; +import org.jsonx.Use; public class Address implements JxObject { private BigInteger number; - @NumberProperty(name="number", scale=0, range="[0,]") + @NumberProperty(name = "number", scale = 0, range = "[0,]") public BigInteger getNumber() { return this.number; } @@ -37,7 +38,7 @@ public void setNumber(BigInteger number) { private String street; - @StringProperty(name="street", pattern="\\S|\\S.*\\S") + @StringProperty(name = "street", pattern = "\\S|\\S.*\\S", nullable = false) public String getStreet() { return this.street; } @@ -48,7 +49,7 @@ public void setStreet(String street) { private String city; - @StringProperty(name="city", pattern="(\\S)|(\\S.*\\S)") + @StringProperty(name = "city", pattern = "(\\S)|(\\S.*\\S)", nullable = false) public String getCity() { return this.city; } @@ -59,7 +60,7 @@ public void setCity(String city) { private String postalCode; - @StringProperty(name="postalCode", pattern="(\\S)|(\\S.*\\S)") + @StringProperty(name = "postalCode", pattern = "(\\S)|(\\S.*\\S)") public String getPostalCode() { return this.postalCode; } @@ -70,7 +71,7 @@ public void setPostalCode(String postalCode) { private String locality; - @StringProperty(name="locality", pattern="(\\S)|(\\S.*\\S)") + @StringProperty(name = "locality", pattern = "(\\S)|(\\S.*\\S)") public String getLocality() { return this.locality; } @@ -81,7 +82,7 @@ public void setLocality(String locality) { private String country; - @StringProperty(name="country", pattern="(\\S)|(\\S.*\\S)") + @StringProperty(name = "country", pattern = "(\\S)|(\\S.*\\S)", nullable = false, use = Use.OPTIONAL) public String getCountry() { return this.country; } diff --git a/binding/src/test/java/org/jsonx/library/Book.java b/binding/src/test/java/org/jsonx/library/Book.java index 839bdbd7..422b0910 100644 --- a/binding/src/test/java/org/jsonx/library/Book.java +++ b/binding/src/test/java/org/jsonx/library/Book.java @@ -28,7 +28,7 @@ public class Book extends Publication { private String isbn; - @StringProperty(name="isbn", pattern="\\d{3}-\\d-\\d{2}-\\d{6}-\\d") + @StringProperty(name = "isbn", pattern = "\\d{3}-\\d-\\d{2}-\\d{6}-\\d") public String getIsbn() { return this.isbn; } @@ -43,10 +43,10 @@ public void setIsbn(final String isbn) { * [[1, "Part 1, Chapter 1"], [2, "Part 1, Chapter 2"], [3, "Part 1, Chapter 3"], [1, "Part 2, Chapter 1"], [2, "Part 2, Chapter * 2"], [3, "Part 2, Chapter 3"]...] */ - @StringElement(id=3, pattern="\\S|\\S.*\\S", nullable=false, maxOccurs=1) - @NumberElement(id=2, range="[1,]", nullable=false, maxOccurs=1) - @ArrayElement(id=1, nullable=false, elementIds={2, 3}) - @ArrayProperty(name="index", elementIds={1}) + @StringElement(id = 3, pattern = "\\S|\\S.*\\S", nullable = false, maxOccurs = 1) + @NumberElement(id = 2, range = "[1,]", nullable = false, maxOccurs = 1) + @ArrayElement(id = 1, nullable = false, elementIds = {2, 3}) + @ArrayProperty(name = "index", elementIds = {1}) public List getIndex() { return this.index; } diff --git a/binding/src/test/java/org/jsonx/library/Employee.java b/binding/src/test/java/org/jsonx/library/Employee.java index 30054636..c18280ae 100644 --- a/binding/src/test/java/org/jsonx/library/Employee.java +++ b/binding/src/test/java/org/jsonx/library/Employee.java @@ -21,7 +21,7 @@ public class Employee extends Individual { private Individual emergencyContact; - @ObjectProperty(name="emergencyContact") + @ObjectProperty(name = "emergencyContact") public Individual getEmergencyContact() { return this.emergencyContact; } diff --git a/binding/src/test/java/org/jsonx/library/Individual.java b/binding/src/test/java/org/jsonx/library/Individual.java index 95c951a7..5811c77a 100644 --- a/binding/src/test/java/org/jsonx/library/Individual.java +++ b/binding/src/test/java/org/jsonx/library/Individual.java @@ -24,7 +24,7 @@ public class Individual implements JxObject { private String name; - @StringProperty(name="name", pattern="\\S+ \\S+") + @StringProperty(name = "name", pattern = "\\S+ \\S+") public String getName() { return this.name; } @@ -35,7 +35,7 @@ public void setName(final String name) { private String gender; - @StringProperty(name="gender", pattern="[MF]") + @StringProperty(name = "gender", pattern = "[MF]") public String getGender() { return this.gender; } @@ -46,7 +46,7 @@ public void setGender(final String gender) { private Address address; - @ObjectProperty(name="address") + @ObjectProperty(name = "address") public Address getAddress() { return this.address; } diff --git a/binding/src/test/java/org/jsonx/library/Library.java b/binding/src/test/java/org/jsonx/library/Library.java index 10e64e0f..72f1a5cb 100644 --- a/binding/src/test/java/org/jsonx/library/Library.java +++ b/binding/src/test/java/org/jsonx/library/Library.java @@ -35,7 +35,7 @@ public class Library implements JxObject { public static class Journal extends Publication { private Optional subject; - @StringProperty(name="subject") + @StringProperty(name = "subject") public Optional getSubject() { return this.subject; } @@ -46,7 +46,7 @@ public void setSubject(final Optional subject) { private Optional openAccess; - @BooleanProperty(name="openAccess", use=Use.OPTIONAL) + @BooleanProperty(name = "openAccess", use = Use.OPTIONAL) public Optional getOpenAccess() { return this.openAccess; } @@ -58,7 +58,7 @@ public void setOpenAccess(final Optional openAccess) { private Optional
address; - @ObjectProperty(name="address", use=Use.OPTIONAL) + @ObjectProperty(name = "address", use = Use.OPTIONAL) public Optional
getAddress() { return this.address; } @@ -69,7 +69,7 @@ public void setAddress(final Optional
address) { private Boolean _handicap; - @BooleanProperty(name="handicap", use=Use.OPTIONAL, nullable=false) + @BooleanProperty(name = "handicap", use = Use.OPTIONAL, nullable = false) public Boolean getHandicap() { return this._handicap; } @@ -80,9 +80,9 @@ public void setHandicap(final Boolean handicap) { private List> schedule; - @StringElement(id=2, pattern="\\d{2}:\\d{2}", nullable=false, minOccurs=2, maxOccurs=2) - @ArrayElement(id=1, nullable=false, elementIds=2, minOccurs=7, maxOccurs=7) - @ArrayProperty(name="schedule", elementIds=1) + @StringElement(id = 2, pattern = "\\d{2}:\\d{2}", nullable = false, minOccurs = 2, maxOccurs = 2) + @ArrayElement(id = 1, nullable = false, elementIds = 2, minOccurs = 7, maxOccurs = 7) + @ArrayProperty(name = "schedule", elementIds = 1) public List> getSchedule() { return this.schedule; } @@ -93,8 +93,8 @@ public void setSchedule(final List> schedule) { private List books; - @ObjectElement(id=1, type=Book.class, nullable=false) - @ArrayProperty(name="books", elementIds=1) + @ObjectElement(id = 1, type = Book.class, nullable = false) + @ArrayProperty(name = "books", elementIds = 1) public List getBooks() { return this.books; } @@ -105,8 +105,8 @@ public void setBooks(final List books) { private List articles; - @ObjectElement(id=1, type=OnlineArticle.class, nullable=false) - @ArrayProperty(name="article", elementIds=1) + @ObjectElement(id = 1, type = OnlineArticle.class, nullable = false) + @ArrayProperty(name = "article", elementIds = 1) public List getArticles() { return this.articles; } @@ -117,8 +117,8 @@ public void setArticles(final List articles) { private List journals; - @ObjectElement(id=1, type=Journal.class, nullable=false) - @ArrayProperty(name="journals", elementIds=1) + @ObjectElement(id = 1, type = Journal.class, nullable = false) + @ArrayProperty(name = "journals", elementIds = 1) public List getJournals() { return this.journals; } @@ -127,14 +127,14 @@ public void setJournals(final List journals) { this.journals = journals; } - @ObjectElement(id=0, type=Employee.class) - @ArrayType(elementIds={0}) + @ObjectElement(id = 0, type = Employee.class) + @ArrayType(elementIds = {0}) public @interface Staff { } private List staff; - @ArrayProperty(name="staff", type=Staff.class) + @ArrayProperty(name = "staff", type = Staff.class) public List getStaff() { return this.staff; } diff --git a/binding/src/test/java/org/jsonx/library/OnlineArticle.java b/binding/src/test/java/org/jsonx/library/OnlineArticle.java index 0cd73284..d418ae08 100644 --- a/binding/src/test/java/org/jsonx/library/OnlineArticle.java +++ b/binding/src/test/java/org/jsonx/library/OnlineArticle.java @@ -22,7 +22,7 @@ public class OnlineArticle extends Publication { private String url; - @StringProperty(name="url", pattern=URLs.REGEX) + @StringProperty(name = "url", pattern = URLs.REGEX) public String getUrl() { return this.url; } diff --git a/binding/src/test/java/org/jsonx/library/Publication.java b/binding/src/test/java/org/jsonx/library/Publication.java index 80541cd5..e5a7b5f5 100644 --- a/binding/src/test/java/org/jsonx/library/Publication.java +++ b/binding/src/test/java/org/jsonx/library/Publication.java @@ -30,7 +30,7 @@ public abstract class Publication implements JxObject { private String title; - @StringProperty(name="title") + @StringProperty(name = "title") public String getTitle() { return this.title; } @@ -41,8 +41,8 @@ public void setTitle(final String title) { private Optional> authors; - @StringElement(id=1, pattern="\\S+ \\S+", nullable=false) - @ArrayProperty(name="authors", use=Use.OPTIONAL, elementIds=1) + @StringElement(id = 1, pattern = "\\S+ \\S+", nullable = false) + @ArrayProperty(name = "authors", use = Use.OPTIONAL, elementIds = 1) public Optional> getAuthors() { return this.authors; } @@ -53,8 +53,8 @@ public void setAuthors(final Optional> authors) { private Optional> editors; - @StringElement(id=1, pattern="\\S+ \\S+", nullable=false) - @ArrayProperty(name="editors", use=Use.OPTIONAL, elementIds=1) + @StringElement(id = 1, pattern = "\\S+ \\S+", nullable = false) + @ArrayProperty(name = "editors", use = Use.OPTIONAL, elementIds = 1) public Optional> getEditors() { return this.editors; } @@ -65,8 +65,8 @@ public void setEditors(final Optional> editors) { private List publishings; - @ObjectElement(id=1, type=Publishing.class, nullable=false) - @ArrayProperty(name="publishings", elementIds=1) + @ObjectElement(id = 1, type = Publishing.class, nullable = false) + @ArrayProperty(name = "publishings", elementIds = 1) public List getPublishings() { return this.publishings; } diff --git a/binding/src/test/java/org/jsonx/library/Publishing.java b/binding/src/test/java/org/jsonx/library/Publishing.java index f7e77e77..111a179b 100644 --- a/binding/src/test/java/org/jsonx/library/Publishing.java +++ b/binding/src/test/java/org/jsonx/library/Publishing.java @@ -26,7 +26,7 @@ public class Publishing implements JxObject { private BigInteger year; - @NumberProperty(name="year", scale=0) + @NumberProperty(name = "year", scale = 0) public BigInteger getYear() { return this.year; } @@ -37,7 +37,7 @@ public void setYear(final BigInteger year) { private String publisher; - @StringProperty(name="publisher", pattern="\\S+ \\S+") + @StringProperty(name = "publisher", pattern = "\\S+ \\S+") public String getPublisher() { return this.publisher; } diff --git a/generator/src/main/java/org/jsonx/AnnotationType.java b/generator/src/main/java/org/jsonx/AnnotationType.java index 73c43a83..5e17a1ea 100644 --- a/generator/src/main/java/org/jsonx/AnnotationType.java +++ b/generator/src/main/java/org/jsonx/AnnotationType.java @@ -52,14 +52,15 @@ private StringBuilder render() { continue; } - b.append(key).append('='); + b.append(key).append(" = "); if (i$ == 1) { b.append(items.get(0)); } else { b.append('{'); if (CollectionUtil.isRandomAccess(items)) { - int i = 0; do { // [RA] + int i = 0; + do { // [RA] if (i > 0) b.append(", "); @@ -69,7 +70,8 @@ private StringBuilder render() { } else { final Iterator it = items.iterator(); - int j = 0; do { // [RA] + int j = 0; + do { // [RA] if (j > 0) b.append(", "); @@ -84,7 +86,7 @@ private StringBuilder render() { else { final Object fixedDefaultValue = defaultValue != null && value instanceof String ? "\"" + defaultValue + "\"" : defaultValue; if (!Objects.equals(fixedDefaultValue, value)) - b.append(key).append('=').append(value); + b.append(key).append(" = ").append(value); } } } diff --git a/generator/src/main/java/org/jsonx/AnyModel.java b/generator/src/main/java/org/jsonx/AnyModel.java index f26bcc09..76223a05 100644 --- a/generator/src/main/java/org/jsonx/AnyModel.java +++ b/generator/src/main/java/org/jsonx/AnyModel.java @@ -71,12 +71,14 @@ final class AnyModel extends Referrer { final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addBinding(xsb, bindings.get(i)); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] addBinding(xsb, i.next()); while (i.hasNext()); } @@ -226,12 +228,14 @@ private ArrayList getTypes(final Boolean nullable, Use use, final $IDREF final ArrayList types = new ArrayList<>(i$); if (idrefs instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addReference(types, idrefs.get(i), nullable, use); while (++i < i$); } else { - final Iterator i = idrefs.iterator(); do // [I] + final Iterator i = idrefs.iterator(); + do // [I] addReference(types, i.next(), nullable, use); while (i.hasNext()); } @@ -467,10 +471,10 @@ void toAnnotationAttributes(final AttributeMap attributes, final Member owner) { for (int i = 0, i$ = types.size(); i < i$; ++i) { // [RA] final Member type = types.get(i); if (type instanceof ArrayModel) { - values.add("@" + t.class.getName() + "(arrays=" + ((ArrayModel)type).classType().getCanonicalName() + ".class)"); + values.add("@" + t.class.getName() + "(arrays = " + ((ArrayModel)type).classType().getCanonicalName() + ".class)"); } else if (type instanceof ObjectModel) { - values.add("@" + t.class.getName() + "(objects=" + ((ObjectModel)type).classType().getCanonicalName() + ".class)"); + values.add("@" + t.class.getName() + "(objects = " + ((ObjectModel)type).classType().getCanonicalName() + ".class)"); } else if (type instanceof BooleanModel || type instanceof NumberModel || type instanceof StringModel) { final Model model = (Model)type; @@ -490,7 +494,7 @@ else if (type instanceof BooleanModel || type instanceof NumberModel || type ins b.append(", "); final Map.Entry entry = iterator.next(); - b.append(entry.getKey()).append('=').append(entry.getValue()); + b.append(entry.getKey()).append(" = ").append(entry.getValue()); } b.append(')'); diff --git a/generator/src/main/java/org/jsonx/AttributeMap.java b/generator/src/main/java/org/jsonx/AttributeMap.java index 28ad4b44..8dec3682 100644 --- a/generator/src/main/java/org/jsonx/AttributeMap.java +++ b/generator/src/main/java/org/jsonx/AttributeMap.java @@ -54,7 +54,7 @@ protected boolean beforeRemove(final Object key, final Object value) { protected Object beforePut(final String key, final Object oldValue, final Object newValue, final Object preventDefault) { // Commented out, because may end up being overwritten for non-root-based reference/model pairs // if (oldValue != null && !oldValue.equals(newValue) && !"xsi:schemaLocation".equals(key)) - // throw new IllegalArgumentException("Attribute overwrite: [" + key + "] from [" + oldValue + "] to [" + newValue + "]"); + // throw new IllegalArgumentException("Attribute overwrite: [" + key + "] from [" + oldValue + "] to [" + newValue + "]"); target.put(prefix != null ? prefix + key : key, newValue); return preventDefault; diff --git a/generator/src/main/java/org/jsonx/BooleanModel.java b/generator/src/main/java/org/jsonx/BooleanModel.java index 441738ba..6a4506e3 100644 --- a/generator/src/main/java/org/jsonx/BooleanModel.java +++ b/generator/src/main/java/org/jsonx/BooleanModel.java @@ -66,12 +66,14 @@ private static Schema.Boolean type(final schema.Boolean jsd, final String name) final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] xsb.addBinding(typeBinding(bindings.get(i))); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] xsb.addBinding(typeBinding(i.next())); while (i.hasNext()); } @@ -103,12 +105,14 @@ private static Schema.Boolean type(final schema.Boolean jsd, final String name) final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addBinding(xsb, (schema.TypeFieldBinding)bindings.get(i)); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] addBinding(xsb, (schema.TypeFieldBinding)i.next()); while (i.hasNext()); } @@ -159,12 +163,14 @@ private static void addBinding(final $Boolean xsb, final schema.TypeFieldBinding final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] xsb.addBinding(typeBinding(bindings.get(i))); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] xsb.addBinding(typeBinding(i.next())); while (i.hasNext()); } diff --git a/generator/src/main/java/org/jsonx/ClassSpec.java b/generator/src/main/java/org/jsonx/ClassSpec.java index d3036f30..1d4e5f8b 100644 --- a/generator/src/main/java/org/jsonx/ClassSpec.java +++ b/generator/src/main/java/org/jsonx/ClassSpec.java @@ -117,7 +117,7 @@ private String toString(final ClassSpec parent) { if (memberDoc != null) b.append("\n ").append(memberDoc); - b.append("\n @").append(JxBinding.class.getName()).append("(targetNamespace=\"").append(registry.targetNamespace).append("\")"); + b.append("\n @").append(JxBinding.class.getName()).append("(targetNamespace = \"").append(registry.targetNamespace).append("\")"); final StringBuilder annotation = memberClass.getAnnotation(); if (annotation != null) diff --git a/generator/src/main/java/org/jsonx/Member.java b/generator/src/main/java/org/jsonx/Member.java index aae3fe5c..756c5af4 100644 --- a/generator/src/main/java/org/jsonx/Member.java +++ b/generator/src/main/java/org/jsonx/Member.java @@ -56,13 +56,14 @@ abstract class Member extends Element { private static final Logger logger = LoggerFactory.getLogger(Model.class); - static T getBinding(final List bindings) { + static T getBinding(final List bindings) { final int i$; if (bindings == null || (i$ = bindings.size()) == 0) return null; if (bindings instanceof RandomAccess) { - int i = 0; do { // [RA] + int i = 0; + do { // [RA] final T binding = bindings.get(i); if ("java".equals(binding.getLang$().text())) return binding; @@ -70,7 +71,8 @@ abstract class Member extends Element { while (++i < i$); } else { - final Iterator i = bindings.iterator(); do { // [I] + final Iterator i = bindings.iterator(); + do { // [I] final T binding = i.next(); if ("java".equals(binding.getLang$().text())) return binding; @@ -230,7 +232,7 @@ final Class validateTypeBinding() { if (!(e.getCause() instanceof ClassNotFoundException)) throw e; - if (logger.isWarnEnabled()) logger.warn("Unable to validate \"decode\": " + typeBinding.decode + " due to: " + e.getCause().getMessage()); + if (logger.isWarnEnabled()) { logger.warn("Unable to validate \"decode\": " + typeBinding.decode + " due to: " + e.getCause().getMessage()); } } } @@ -244,7 +246,7 @@ final Class validateTypeBinding() { if (!(e.getCause() instanceof ClassNotFoundException)) throw e; - if (logger.isWarnEnabled()) logger.warn("Unable to validate \"encode\": " + typeBinding.encode + " due to: " + e.getCause().getMessage()); + if (logger.isWarnEnabled()) { logger.warn("Unable to validate \"encode\": " + typeBinding.encode + " due to: " + e.getCause().getMessage()); } } } @@ -445,8 +447,8 @@ List toElementAnnotations() { } /** - * Intended to be overridden by each concrete subclass, this method collects all {@link Registry.Type} declarations of elements - * that are members of this {@link Member}. + * Intended to be overridden by each concrete subclass, this method collects all {@link Registry.Type} declarations of elements that + * are members of this {@link Member}. * * @param types The {@link Set} into which the {@link Registry.Type} declarations must be added. */ diff --git a/generator/src/main/java/org/jsonx/NumberModel.java b/generator/src/main/java/org/jsonx/NumberModel.java index 9720de57..6ee22491 100644 --- a/generator/src/main/java/org/jsonx/NumberModel.java +++ b/generator/src/main/java/org/jsonx/NumberModel.java @@ -73,12 +73,14 @@ private static Schema.Number type(final schema.Number jsd, final String name) { final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] xsb.addBinding(typeBinding(bindings.get(i))); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] xsb.addBinding(typeBinding(i.next())); while (i.hasNext()); } @@ -110,12 +112,14 @@ private static Schema.Number type(final schema.Number jsd, final String name) { final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addBinding(xsb, (schema.TypeFieldBinding)bindings.get(i)); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] addBinding(xsb, (schema.TypeFieldBinding)i.next()); while (i.hasNext()); } @@ -166,12 +170,14 @@ private static void addBinding(final $Number xsb, final schema.TypeFieldBinding final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] xsb.addBinding(typeBinding(bindings.get(i))); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] xsb.addBinding(typeBinding(i.next())); while (i.hasNext()); } diff --git a/generator/src/main/java/org/jsonx/ObjectModel.java b/generator/src/main/java/org/jsonx/ObjectModel.java index 2d0ccfec..0e4445d6 100644 --- a/generator/src/main/java/org/jsonx/ObjectModel.java +++ b/generator/src/main/java/org/jsonx/ObjectModel.java @@ -93,12 +93,14 @@ private static Schema.Object type(final schema.ObjectType jsd, final String name final List bindings = jsd.getBindings(); if (bindings != null && (i$ = bindings.size()) > 0) { if (CollectionUtil.isRandomAccess(bindings)) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addBinding(xsb, bindings.get(i)); while (++i < i$); } else { - final Iterator it = bindings.iterator(); do // [I] + final Iterator it = bindings.iterator(); + do // [I] addBinding(xsb, it.next()); while (it.hasNext()); } @@ -411,7 +413,7 @@ private void resolveProperties() { property.setOverride(superProperty.member); else { superProperty.member.isAssignableFrom(property.member); - throw new ValidationException("Object " + (name() != null ? name(): JsdUtil.flipName(id().toString())) + "." + entry.getKey() + " overrides " + property.member.name() + "." + entry.getKey() + " with incompatible type"); + throw new ValidationException("Object " + (name() != null ? name() : JsdUtil.flipName(id().toString())) + "." + entry.getKey() + " overrides " + property.member.name() + "." + entry.getKey() + " with incompatible type"); } } } diff --git a/generator/src/main/java/org/jsonx/Reference.java b/generator/src/main/java/org/jsonx/Reference.java index ede2184d..dcd3af56 100644 --- a/generator/src/main/java/org/jsonx/Reference.java +++ b/generator/src/main/java/org/jsonx/Reference.java @@ -88,12 +88,14 @@ final class Reference extends Member { final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (CollectionUtil.isRandomAccess(bindings)) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addBinding(xsb, bindings.get(i)); while (++i < i$); } else { - final Iterator it = bindings.iterator(); do // [I] + final Iterator it = bindings.iterator(); + do // [I] addBinding(xsb, it.next()); while (it.hasNext()); } diff --git a/generator/src/main/java/org/jsonx/Referrer.java b/generator/src/main/java/org/jsonx/Referrer.java index 5324008f..c030fa30 100644 --- a/generator/src/main/java/org/jsonx/Referrer.java +++ b/generator/src/main/java/org/jsonx/Referrer.java @@ -63,7 +63,8 @@ static Registry.Type getGreatestCommonSuperType(final List mem while (++i < i$); } else { - final Iterator it = members.iterator(); do // [I] + final Iterator it = members.iterator(); + do // [I] gct = getGreatestCommonSuperType(gct, it.next()); while (it.hasNext()); } diff --git a/generator/src/main/java/org/jsonx/Registry.java b/generator/src/main/java/org/jsonx/Registry.java index c7ad247a..8732d71a 100644 --- a/generator/src/main/java/org/jsonx/Registry.java +++ b/generator/src/main/java/org/jsonx/Registry.java @@ -47,7 +47,7 @@ private Value(final String name) { this.name = name; } - T value(final T model, final Referrer referrer) { + T value(final T model, final Referrer referrer) { refToModel.put(name, model); return reference(model, referrer); } @@ -571,7 +571,7 @@ Value declare(final $Object xsb) { return new Value(ObjectModel.getFullyQualifiedName(xsb)); } - T reference(final T model, final Referrer referrer) { + T reference(final T model, final Referrer referrer) { deferredReferences.add(() -> { if (model instanceof Referrer) ((Referrer)model).resolveReferences(); diff --git a/generator/src/main/java/org/jsonx/SchemaElement.java b/generator/src/main/java/org/jsonx/SchemaElement.java index c560ee5d..7b2d3468 100644 --- a/generator/src/main/java/org/jsonx/SchemaElement.java +++ b/generator/src/main/java/org/jsonx/SchemaElement.java @@ -60,7 +60,7 @@ * The root {@link Element} of a JSON Schema Document. */ public final class SchemaElement extends Element implements Declarer { - private static final String GENERATED = "(value=\"" + Generator.class.getName() + "\", date=\"" + LocalDateTime.now().toString() + "\")"; + private static final String GENERATED = "(value = \"" + Generator.class.getName() + "\", date = \"" + LocalDateTime.now().toString() + "\")"; private static Schema jsdToXsb(final schema.Schema jsd) { final Schema xsb = new Schema(); @@ -136,8 +136,8 @@ public static SchemaElement parseJsdx(final URL url, final Settings settings) th } /** - * Creates a {@link SchemaElement} from the contents of the specified {@code file}. The supported content formats are JSDx and - * JSD. If the supplied file is not in one of the supported formats, an {@link IllegalArgumentException} is thrown. + * Creates a {@link SchemaElement} from the contents of the specified {@code file}. The supported content formats are JSDx and JSD. + * If the supplied file is not in one of the supported formats, an {@link IllegalArgumentException} is thrown. * * @param url The file from which to read the contents. * @param settings The {@link Settings} to be used for the parsed {@link SchemaElement}. @@ -306,8 +306,8 @@ private static Set> findClasses(final Package pkg, final ClassLoader cl } /** - * Creates a new {@link SchemaElement} by scanning the specified package in the provided class loader, filtered with the given - * class predicate. + * Creates a new {@link SchemaElement} by scanning the specified package in the provided class loader, filtered with the given class + * predicate. * * @param pkg The package to be scanned for JSD bindings. * @param classLoader The {@link ClassLoader} containing the defined package. @@ -441,7 +441,8 @@ XmlElement toXml(final Element owner, final String packageName) { final int i$ = members.size(); if (i$ > 0) { elements = new ArrayList<>(); - int i = 0; do // [RA] + int i = 0; + do // [RA] elements.add(members.get(i).toXml(this, packageName)); while (++i < i$); } @@ -548,7 +549,7 @@ public Map toSource() { b.append("\n@").append(SuppressWarnings.class.getName()).append("(\"all\")"); if (classSpec.referrer != null) - b.append("\n@").append(JxBinding.class.getName()).append("(targetNamespace=\"").append(registry.targetNamespace).append("\")"); + b.append("\n@").append(JxBinding.class.getName()).append("(targetNamespace = \"").append(registry.targetNamespace).append("\")"); b.append("\n@").append(Generated.class.getName()).append(GENERATED); b.append("\npublic ").append(classSpec); diff --git a/generator/src/main/java/org/jsonx/Settings.java b/generator/src/main/java/org/jsonx/Settings.java index bf832d31..5dde58ee 100644 --- a/generator/src/main/java/org/jsonx/Settings.java +++ b/generator/src/main/java/org/jsonx/Settings.java @@ -56,14 +56,14 @@ public Builder withSetBuilder(final boolean setBuilder) { private Class integerPrimitive = long.class; /** - * Sets the name of the primitive {@link Class} to be used as default type binding for \"number\" types with scale=0 && - * Use=REQUIRED && nullable=false, and returns {@code this} builder. + * Sets the name of the primitive {@link Class} to be used as default type binding for \"number\" types with scale=0 && Use=REQUIRED + * && nullable=false, and returns {@code this} builder. * * @param integerPrimitive The primitive {@link Class} to be used as default type binding for \"number\" types with scale=0 && * Use=REQUIRED && nullable=false. * @return {@code this} builder. - * @throws IllegalArgumentException If the provided {@code integerPrimitive} class name does not resolve to a {@link Class}, or - * if the resolved {@link Class} is not primitive. + * @throws IllegalArgumentException If the provided {@code integerPrimitive} class name does not resolve to a {@link Class}, or if + * the resolved {@link Class} is not primitive. */ public Builder withIntegerPrimitive(final String integerPrimitive) { if (integerPrimitive == null) { @@ -87,8 +87,8 @@ public Builder withIntegerPrimitive(final String integerPrimitive) { * @param integerObject The non-primitive {@link Class} to be used as default type binding for \"number\" types with scale=0 && * (Use=OPTIONAL || nullable=true). * @return {@code this} builder. - * @throws IllegalArgumentException If the provided {@code integerObject} class name does not resolve to a {@link Class}, or if - * the resolved {@link Class} is primitive. + * @throws IllegalArgumentException If the provided {@code integerObject} class name does not resolve to a {@link Class}, or if the + * resolved {@link Class} is primitive. */ public Builder withIntegerObject(final String integerObject) { try { @@ -107,14 +107,14 @@ public Builder withIntegerObject(final String integerObject) { private Class realPrimitive = double.class; /** - * Sets the name of the primitive {@link Class} to be used as default type binding for \"number\" types with scale>0 && - * Use=REQUIRED && nullable=false, and returns {@code this} builder. + * Sets the name of the primitive {@link Class} to be used as default type binding for \"number\" types with scale>0 && Use=REQUIRED + * && nullable=false, and returns {@code this} builder. * * @param realPrimitive The primitive {@link Class} to be used as default type binding for \"number\" types with scale>0 && * Use=REQUIRED && nullable=false. * @return {@code this} builder. - * @throws IllegalArgumentException If the provided {@code realPrimitive} class name does not resolve to a {@link Class}, or if - * the resolved {@link Class} is not primitive. + * @throws IllegalArgumentException If the provided {@code realPrimitive} class name does not resolve to a {@link Class}, or if the + * resolved {@link Class} is not primitive. */ public Builder withRealPrimitive(final String realPrimitive) { if (realPrimitive == null) { diff --git a/generator/src/main/java/org/jsonx/Spec.java b/generator/src/main/java/org/jsonx/Spec.java index d793d866..538d7678 100644 --- a/generator/src/main/java/org/jsonx/Spec.java +++ b/generator/src/main/java/org/jsonx/Spec.java @@ -25,7 +25,7 @@ class Spec { * @param get The calculated value to be gotten from this {@link Spec}. * @return A new {@link Spec} with the specified {@code set} and {@code get} values. */ - static Spec from(final T set, final T get) { + static Spec from(final T set, final T get) { return new Spec<>(set, get); } diff --git a/generator/src/main/java/org/jsonx/StringModel.java b/generator/src/main/java/org/jsonx/StringModel.java index fea38823..5b076a96 100644 --- a/generator/src/main/java/org/jsonx/StringModel.java +++ b/generator/src/main/java/org/jsonx/StringModel.java @@ -70,12 +70,14 @@ private static Schema.String type(final schema.String jsd, final String name) { final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] xsb.addBinding(typeBinding(bindings.get(i))); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] xsb.addBinding(typeBinding(i.next())); while (i.hasNext()); } @@ -107,12 +109,14 @@ private static Schema.String type(final schema.String jsd, final String name) { final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] addBinding(xsb, (schema.TypeFieldBinding)bindings.get(i)); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] addBinding(xsb, (schema.TypeFieldBinding)i.next()); while (i.hasNext()); } @@ -163,12 +167,14 @@ private static void addBinding(final $String xsb, final schema.TypeFieldBinding final int i$; if (bindings != null && (i$ = bindings.size()) > 0) { if (bindings instanceof RandomAccess) { - int i = 0; do // [RA] + int i = 0; + do // [RA] xsb.addBinding(typeBinding(bindings.get(i))); while (++i < i$); } else { - final Iterator i = bindings.iterator(); do // [I] + final Iterator i = bindings.iterator(); + do // [I] xsb.addBinding(typeBinding(i.next())); while (i.hasNext()); } @@ -180,11 +186,11 @@ private static void addBinding(final $String xsb, final schema.TypeFieldBinding static $StringMember jsdToXsb(final schema.String jsd, final String name) { final $StringMember xsb; if (jsd instanceof schema.StringProperty) - xsb = property((schema.StringProperty)jsd, name); + xsb = property((schema.StringProperty)jsd, name); else if (jsd instanceof schema.StringElement) - xsb = element((schema.StringElement)jsd); + xsb = element((schema.StringElement)jsd); else if (name != null) - xsb = type(jsd, name); + xsb = type(jsd, name); else throw new UnsupportedOperationException("Unsupported type: " + jsd.getClass().getName()); diff --git a/generator/src/main/java/org/jsonx/schema.java b/generator/src/main/java/org/jsonx/schema.java index d05a1761..c3c86eac 100644 --- a/generator/src/main/java/org/jsonx/schema.java +++ b/generator/src/main/java/org/jsonx/schema.java @@ -1,11 +1,11 @@ package org.jsonx; @java.lang.SuppressWarnings("all") -@javax.annotation.Generated(value="org.jsonx.Generator", date="2023-06-17T14:26:40.669") +@javax.annotation.Generated(value = "org.jsonx.Generator", date = "2023-09-26T17:08:33.194") public class schema { - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public abstract static class Any extends org.jsonx.schema.Member { - @org.jsonx.StringProperty(name="jx:type", pattern="any", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "any", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -17,7 +17,7 @@ public Any setJx3aType(final java.lang.String jx3aType) { private java.lang.String jx3aType; - @org.jsonx.StringProperty(name="types", pattern="\\S|\\S.*\\S", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "types", pattern = "\\S|\\S.*\\S", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getTypes() { return types; } @@ -66,9 +66,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class AnyElement extends org.jsonx.schema.Any { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -80,7 +80,7 @@ public AnyElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -92,7 +92,7 @@ public AnyElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -157,9 +157,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class AnyProperty extends org.jsonx.schema.Any { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -171,7 +171,7 @@ public AnyProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -183,7 +183,7 @@ public AnyProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.FieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.FieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -248,9 +248,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class Array extends org.jsonx.schema.Member { - @org.jsonx.StringProperty(name="jx:type", pattern="array", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "array", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -263,7 +263,7 @@ public Array setJx3aType(final java.lang.String jx3aType) { private java.lang.String jx3aType; /** Specifies the minimum inclusive number of iterations of child elements. Default: 1. **/ - @org.jsonx.StringProperty(name="minIterate", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minIterate", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinIterate() { return minIterate; } @@ -277,7 +277,7 @@ public Array setMinIterate(final java.lang.String minIterate) { private java.lang.String minIterate; /** Specifies the maximum inclusive number of iterations of child elements. Default: 1. **/ - @org.jsonx.StringProperty(name="maxIterate", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxIterate", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxIterate() { return maxIterate; } @@ -290,14 +290,14 @@ public Array setMaxIterate(final java.lang.String maxIterate) { private java.lang.String maxIterate; - @org.jsonx.ObjectElement(id=6, type=org.jsonx.schema.ObjectElement.class, minOccurs=0, nullable=false) - @org.jsonx.ObjectElement(id=5, type=org.jsonx.schema.StringElement.class, minOccurs=0, nullable=false) - @org.jsonx.ObjectElement(id=4, type=org.jsonx.schema.ReferenceElement.class, minOccurs=0, nullable=false) - @org.jsonx.ObjectElement(id=3, type=org.jsonx.schema.NumberElement.class, minOccurs=0, nullable=false) - @org.jsonx.ObjectElement(id=2, type=org.jsonx.schema.BooleanElement.class, minOccurs=0, nullable=false) - @org.jsonx.ObjectElement(id=1, type=org.jsonx.schema.ArrayElement.class, minOccurs=0, nullable=false) - @org.jsonx.ObjectElement(id=0, type=org.jsonx.schema.AnyElement.class, minOccurs=0, nullable=false) - @org.jsonx.ArrayProperty(name="elements", elementIds={0, 1, 2, 3, 4, 5, 6}, maxIterate=2147483647, nullable=false) + @org.jsonx.ObjectElement(id = 6, type = org.jsonx.schema.ObjectElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ObjectElement(id = 5, type = org.jsonx.schema.StringElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ObjectElement(id = 4, type = org.jsonx.schema.ReferenceElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ObjectElement(id = 3, type = org.jsonx.schema.NumberElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ObjectElement(id = 2, type = org.jsonx.schema.BooleanElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ObjectElement(id = 1, type = org.jsonx.schema.ArrayElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ObjectElement(id = 0, type = org.jsonx.schema.AnyElement.class, minOccurs = 0, nullable = false) + @org.jsonx.ArrayProperty(name = "elements", elementIds = {0, 1, 2, 3, 4, 5, 6}, maxIterate = 2147483647, nullable = false) public java.util.List getElements() { return elements; } @@ -358,9 +358,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ArrayElement extends org.jsonx.schema.Array { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -372,7 +372,7 @@ public ArrayElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -384,7 +384,7 @@ public ArrayElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -456,9 +456,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ArrayProperty extends org.jsonx.schema.Array { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -470,7 +470,7 @@ public ArrayProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -482,7 +482,7 @@ public ArrayProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.FieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.FieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -554,10 +554,10 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public abstract static class Binding implements org.jsonx.JxObject { /** Specifies the language to which this binding applies. **/ - @org.jsonx.StringProperty(name="lang", pattern="\\S|\\S.*\\S", nullable=false) + @org.jsonx.StringProperty(name = "lang", pattern = "\\S|\\S.*\\S", nullable = false) public java.lang.String getLang() { return lang; } @@ -600,9 +600,9 @@ public java.lang.String toString() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class Boolean extends org.jsonx.schema.Member { - @org.jsonx.StringProperty(name="jx:type", pattern="boolean", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "boolean", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -614,7 +614,7 @@ public Boolean setJx3aType(final java.lang.String jx3aType) { private java.lang.String jx3aType; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.TypeBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.TypeBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -663,9 +663,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class BooleanElement extends org.jsonx.schema.Boolean { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -677,7 +677,7 @@ public BooleanElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -689,7 +689,7 @@ public BooleanElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -749,9 +749,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class BooleanProperty extends org.jsonx.schema.Boolean { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -763,7 +763,7 @@ public BooleanProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -775,7 +775,7 @@ public BooleanProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.TypeFieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.TypeFieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return super.getBindings(); } @@ -822,10 +822,10 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public abstract static class Documented implements org.jsonx.JxObject { /** Defines text comments. Optional. **/ - @org.jsonx.StringProperty(name="doc") + @org.jsonx.StringProperty(name = "doc") public java.lang.String getDoc() { return doc; } @@ -869,10 +869,10 @@ public java.lang.String toString() { } /** Specifies language-specific binding. **/ - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class FieldBinding extends org.jsonx.schema.Binding { /** Specifies the "field" identifier. **/ - @org.jsonx.StringProperty(name="field", pattern="[a-zA-Z_$][a-zA-Z\\d_$]*", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "field", pattern = "[a-zA-Z_$][a-zA-Z\\d_$]*", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getField() { return field; } @@ -917,14 +917,14 @@ public int hashCode() { } /** Specifies language-specific bindings. **/ - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) - @org.jsonx.ObjectElement(id=0, type=org.jsonx.schema.FieldBinding.class, nullable=false) - @org.jsonx.ArrayType(elementIds={0}) + @org.jsonx.ObjectElement(id = 0, type = org.jsonx.schema.FieldBinding.class, nullable = false) + @org.jsonx.ArrayType(elementIds = {0}) public static @interface FieldBindings { } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public abstract static class Member extends org.jsonx.schema.Documented { /** Defines text comments. Optional. **/ public Member setDoc(final java.lang.String doc) { @@ -949,9 +949,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class Number extends org.jsonx.schema.Member { - @org.jsonx.StringProperty(name="jx:type", pattern="number", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "number", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -968,7 +968,7 @@ public Number setJx3aType(final java.lang.String jx3aType) { Closed (inclusive) interval: [min,max] Half-open or half-closed interval: [min,max) Degenerate interval: [val] **/ - @org.jsonx.StringProperty(name="range", pattern="[\\(\\[](-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?([1-9]\\d*))?)?,(-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?([1-9]\\d*))?)?[\\)\\]]", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "range", pattern = "[\\(\\[](-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?([1-9]\\d*))?)?,(-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?([1-9]\\d*))?)?[\\)\\]]", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getRange() { return range; } @@ -986,7 +986,7 @@ public Number setRange(final java.lang.String range) { private java.lang.String range; /** The number of digits to the right of the decimal point. If a value is not specified, the scale is unbounded. **/ - @org.jsonx.NumberProperty(name="scale", scale=0, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.NumberProperty(name = "scale", scale = 0, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Long getScale() { return scale; } @@ -999,7 +999,7 @@ public Number setScale(final java.lang.Long scale) { private java.lang.Long scale; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.TypeBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.TypeBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -1060,9 +1060,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class NumberElement extends org.jsonx.schema.Number { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -1074,7 +1074,7 @@ public NumberElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -1086,7 +1086,7 @@ public NumberElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -1162,9 +1162,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class NumberProperty extends org.jsonx.schema.Number { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -1176,7 +1176,7 @@ public NumberProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -1188,7 +1188,7 @@ public NumberProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.TypeFieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.TypeFieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return super.getBindings(); } @@ -1251,11 +1251,11 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public abstract static class Object extends org.jsonx.schema.Member { - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class Properties implements org.jsonx.JxObject { - @org.jsonx.AnyProperty(name=".*", types={@org.jsonx.t(objects=org.jsonx.schema.AnyProperty.class), @org.jsonx.t(objects=org.jsonx.schema.ArrayProperty.class), @org.jsonx.t(objects=org.jsonx.schema.BooleanProperty.class), @org.jsonx.t(objects=org.jsonx.schema.NumberProperty.class), @org.jsonx.t(objects=org.jsonx.schema.ObjectProperty.class), @org.jsonx.t(objects=org.jsonx.schema.ReferenceProperty.class), @org.jsonx.t(objects=org.jsonx.schema.StringProperty.class)}, nullable=false) + @org.jsonx.AnyProperty(name = ".*", types = {@org.jsonx.t(objects = org.jsonx.schema.AnyProperty.class), @org.jsonx.t(objects = org.jsonx.schema.ArrayProperty.class), @org.jsonx.t(objects = org.jsonx.schema.BooleanProperty.class), @org.jsonx.t(objects = org.jsonx.schema.NumberProperty.class), @org.jsonx.t(objects = org.jsonx.schema.ObjectProperty.class), @org.jsonx.t(objects = org.jsonx.schema.ReferenceProperty.class), @org.jsonx.t(objects = org.jsonx.schema.StringProperty.class)}, nullable = false) public java.util.LinkedHashMap getProperties() { return properties; } @@ -1297,7 +1297,7 @@ public java.lang.String toString() { } } - @org.jsonx.StringProperty(name="jx:type", pattern="object", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "object", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -1310,7 +1310,7 @@ public Object setJx3aType(final java.lang.String jx3aType) { private java.lang.String jx3aType; /** Specifies the name of the type to extend. Optional. **/ - @org.jsonx.StringProperty(name="extends", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "extends", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getExtends() { return _extends; } @@ -1323,7 +1323,7 @@ public Object setExtends(final java.lang.String _extends) { private java.lang.String _extends; - @org.jsonx.ObjectProperty(name="properties", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ObjectProperty(name = "properties", use = org.jsonx.Use.OPTIONAL, nullable = false) public org.jsonx.schema.Object.Properties getProperties() { return properties; } @@ -1378,9 +1378,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ObjectElement extends org.jsonx.schema.Object { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -1392,7 +1392,7 @@ public ObjectElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -1404,7 +1404,7 @@ public ObjectElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -1475,9 +1475,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ObjectProperty extends org.jsonx.schema.Object { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -1489,7 +1489,7 @@ public ObjectProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -1501,7 +1501,7 @@ public ObjectProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.FieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.FieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -1572,10 +1572,10 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ObjectType extends org.jsonx.schema.Object { /** Specifies whether the object is abstract. Default: false. **/ - @org.jsonx.BooleanProperty(name="abstract", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "abstract", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getAbstract() { return _abstract; } @@ -1635,9 +1635,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public abstract static class Reference extends org.jsonx.schema.Member { - @org.jsonx.StringProperty(name="jx:type", pattern="reference", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "reference", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -1650,7 +1650,7 @@ public Reference setJx3aType(final java.lang.String jx3aType) { private java.lang.String jx3aType; /** Specifies the name of the referenced type. Required. **/ - @org.jsonx.StringProperty(name="type", pattern="\\S|\\S.*\\S", nullable=false) + @org.jsonx.StringProperty(name = "type", pattern = "\\S|\\S.*\\S", nullable = false) public java.lang.String getType() { return type; } @@ -1700,9 +1700,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ReferenceElement extends org.jsonx.schema.Reference { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -1714,7 +1714,7 @@ public ReferenceElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -1726,7 +1726,7 @@ public ReferenceElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -1792,9 +1792,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class ReferenceProperty extends org.jsonx.schema.Reference { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -1806,7 +1806,7 @@ public ReferenceProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -1818,7 +1818,7 @@ public ReferenceProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.FieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.FieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -1884,9 +1884,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class Schema extends org.jsonx.schema.Documented { - @org.jsonx.StringProperty(name="jx:ns", pattern="http://www.jsonx.org/schema-0.5.jsd", nullable=false) + @org.jsonx.StringProperty(name = "jx:ns", pattern = "http://www.jsonx.org/schema-0.5.jsd", nullable = false) public java.lang.String getJx3aNs() { return jx3aNs; } @@ -1898,7 +1898,7 @@ public Schema setJx3aNs(final java.lang.String jx3aNs) { private java.lang.String jx3aNs; - @org.jsonx.StringProperty(name="jx:schemaLocation", pattern="http://www.jsonx.org/schema-0.5.jsd [^ ]+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "jx:schemaLocation", pattern = "http://www.jsonx.org/schema-0.5.jsd [^ ]+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getJx3aSchemaLocation() { return jx3aSchemaLocation; } @@ -1910,7 +1910,7 @@ public Schema setJx3aSchemaLocation(final java.lang.String jx3aSchemaLocation) { private java.lang.String jx3aSchemaLocation; - @org.jsonx.StringProperty(name="jx:targetNamespace", pattern="\\S|\\S.*\\S", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "jx:targetNamespace", pattern = "\\S|\\S.*\\S", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getJx3aTargetNamespace() { return jx3aTargetNamespace; } @@ -1922,7 +1922,7 @@ public Schema setJx3aTargetNamespace(final java.lang.String jx3aTargetNamespace) private java.lang.String jx3aTargetNamespace; - @org.jsonx.AnyProperty(name="[a-zA-Z_][-a-zA-Z\\d_]*", types={@org.jsonx.t(objects=org.jsonx.schema.Array.class), @org.jsonx.t(objects=org.jsonx.schema.Boolean.class), @org.jsonx.t(objects=org.jsonx.schema.Number.class), @org.jsonx.t(objects=org.jsonx.schema.ObjectType.class), @org.jsonx.t(objects=org.jsonx.schema.String.class)}, nullable=false) + @org.jsonx.AnyProperty(name = "[a-zA-Z_][-a-zA-Z\\d_]*", types = {@org.jsonx.t(objects = org.jsonx.schema.Array.class), @org.jsonx.t(objects = org.jsonx.schema.Boolean.class), @org.jsonx.t(objects = org.jsonx.schema.Number.class), @org.jsonx.t(objects = org.jsonx.schema.ObjectType.class), @org.jsonx.t(objects = org.jsonx.schema.String.class)}, nullable = false) public java.util.LinkedHashMap getDeclarations() { return declarations; } @@ -1983,9 +1983,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class String extends org.jsonx.schema.Member { - @org.jsonx.StringProperty(name="jx:type", pattern="string", nullable=false) + @org.jsonx.StringProperty(name = "jx:type", pattern = "string", nullable = false) public java.lang.String getJx3aType() { return jx3aType; } @@ -1997,7 +1997,7 @@ public String setJx3aType(final java.lang.String jx3aType) { private java.lang.String jx3aType; - @org.jsonx.StringProperty(name="pattern", pattern="\\S|\\S.*\\S", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "pattern", pattern = "\\S|\\S.*\\S", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getPattern() { return pattern; } @@ -2009,7 +2009,7 @@ public String setPattern(final java.lang.String pattern) { private java.lang.String pattern; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.TypeBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.TypeBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return bindings; } @@ -2064,9 +2064,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class StringElement extends org.jsonx.schema.String { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -2078,7 +2078,7 @@ public StringElement setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="minOccurs", pattern="\\d+", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "minOccurs", pattern = "\\d+", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMinOccurs() { return minOccurs; } @@ -2090,7 +2090,7 @@ public StringElement setMinOccurs(final java.lang.String minOccurs) { private java.lang.String minOccurs; - @org.jsonx.StringProperty(name="maxOccurs", pattern="\\d+|unbounded", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "maxOccurs", pattern = "\\d+|unbounded", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getMaxOccurs() { return maxOccurs; } @@ -2155,9 +2155,9 @@ public int hashCode() { } } - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class StringProperty extends org.jsonx.schema.String { - @org.jsonx.BooleanProperty(name="nullable", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.BooleanProperty(name = "nullable", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.Boolean getNullable() { return nullable; } @@ -2169,7 +2169,7 @@ public StringProperty setNullable(final java.lang.Boolean nullable) { private java.lang.Boolean nullable; - @org.jsonx.StringProperty(name="use", pattern="required|optional", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "use", pattern = "required|optional", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getUse() { return use; } @@ -2181,7 +2181,7 @@ public StringProperty setUse(final java.lang.String use) { private java.lang.String use; - @org.jsonx.ArrayProperty(name="bindings", type=org.jsonx.schema.TypeFieldBindings.class, use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.ArrayProperty(name = "bindings", type = org.jsonx.schema.TypeFieldBindings.class, use = org.jsonx.Use.OPTIONAL, nullable = false) public java.util.List getBindings() { return super.getBindings(); } @@ -2234,10 +2234,10 @@ public int hashCode() { } /** Specifies language-specific binding. **/ - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class TypeBinding extends org.jsonx.schema.Binding { /** Specifies the "type" qualified identifier. **/ - @org.jsonx.StringProperty(name="type", pattern="(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\[\\])?", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "type", pattern = "(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\[\\])?", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getType() { return type; } @@ -2251,7 +2251,7 @@ public TypeBinding setType(final java.lang.String type) { private java.lang.String type; /** Specifies the "decode" qualified function identifier that accepts input as a string, or as the native JSON type of this property, and returns an output of the specified "type" (or the default type if "type" is unspecified). **/ - @org.jsonx.StringProperty(name="decode", pattern="(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\.)?", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "decode", pattern = "(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\.)?", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getDecode() { return decode; } @@ -2265,7 +2265,7 @@ public TypeBinding setDecode(final java.lang.String decode) { private java.lang.String decode; /** Specifies the "encode" qualified function identifier that accepts input of the type specified in "type" (or the default type if "type" is unspecified), and returns an output as a string, or as the native JSON type of this property. **/ - @org.jsonx.StringProperty(name="encode", pattern="(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\.)?", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "encode", pattern = "(([a-zA-Z_$][a-zA-Z\\d_$]*)\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*(\\.)?", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getEncode() { return encode; } @@ -2322,18 +2322,18 @@ public int hashCode() { } /** Specifies language-specific bindings. **/ - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) - @org.jsonx.ObjectElement(id=0, type=org.jsonx.schema.TypeBinding.class, nullable=false) - @org.jsonx.ArrayType(elementIds={0}) + @org.jsonx.ObjectElement(id = 0, type = org.jsonx.schema.TypeBinding.class, nullable = false) + @org.jsonx.ArrayType(elementIds = {0}) public static @interface TypeBindings { } /** Specifies language-specific binding. **/ - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") public static class TypeFieldBinding extends org.jsonx.schema.TypeBinding { /** Specifies the "field" identifier. **/ - @org.jsonx.StringProperty(name="field", pattern="[a-zA-Z_$][a-zA-Z\\d_$]*", use=org.jsonx.Use.OPTIONAL, nullable=false) + @org.jsonx.StringProperty(name = "field", pattern = "[a-zA-Z_$][a-zA-Z\\d_$]*", use = org.jsonx.Use.OPTIONAL, nullable = false) public java.lang.String getField() { return field; } @@ -2396,10 +2396,10 @@ public int hashCode() { } /** Specifies language-specific bindings. **/ - @org.jsonx.JxBinding(targetNamespace="http://www.jsonx.org/schema-0.5.jsdx") + @org.jsonx.JxBinding(targetNamespace = "http://www.jsonx.org/schema-0.5.jsdx") @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) - @org.jsonx.ObjectElement(id=0, type=org.jsonx.schema.TypeFieldBinding.class, nullable=false) - @org.jsonx.ArrayType(elementIds={0}) + @org.jsonx.ObjectElement(id = 0, type = org.jsonx.schema.TypeFieldBinding.class, nullable = false) + @org.jsonx.ArrayType(elementIds = {0}) public static @interface TypeFieldBindings { } } \ No newline at end of file diff --git a/generator/src/test/java/org/jsonx/SchemaTest.java b/generator/src/test/java/org/jsonx/SchemaTest.java index 1762caa4..f31695dd 100644 --- a/generator/src/test/java/org/jsonx/SchemaTest.java +++ b/generator/src/test/java/org/jsonx/SchemaTest.java @@ -103,22 +103,22 @@ private static void validate(final String xml, final String fileName) throws IOE Validator.validate(xml); } catch (final SAXException e) { - if (logger.isErrorEnabled()) logger.error(xml); + if (logger.isErrorEnabled()) { logger.error(xml); } throw e; } } private static SchemaElement testParseSchema(final Schema controlBinding, final String prefix, final String fileName) throws IOException, SAXException { - if (logger.isInfoEnabled()) logger.info(" Parse XML..."); - if (logger.isInfoEnabled()) logger.info(" a) XML(1) -> Schema"); + if (logger.isInfoEnabled()) { logger.info(" Parse XML..."); } + if (logger.isInfoEnabled()) { logger.info(" a) XML(1) -> Schema"); } final SchemaElement controlSchema = new SchemaElement(controlBinding, new Settings.Builder().withPrefix(prefix).build()); - if (logger.isInfoEnabled()) logger.info(" b) Schema -> XML(2)"); + if (logger.isInfoEnabled()) { logger.info(" b) Schema -> XML(2)"); } final String xml = toXml(controlSchema).toString(); - if (logger.isInfoEnabled()) logger.info(" c) Validate XML: c-" + fileName); + if (logger.isInfoEnabled()) { logger.info(" c) Validate XML: c-" + fileName); } validate(xml, "c-" + fileName); final Schema testBinding = (Schema)Bindings.parse(xml); - if (logger.isInfoEnabled()) logger.info(" d) XML(1) == XML(2)"); + if (logger.isInfoEnabled()) { logger.info(" d) XML(1) == XML(2)"); } AssertXml.compare(controlBinding.toDOM(), testBinding.toDOM()).assertEqual(true); return controlSchema; } @@ -222,11 +222,11 @@ private static void assertSources(final Map expected, final Map Java(1)"); + if (logger.isInfoEnabled()) { logger.info(" 4) Schema -> Java(1)"); } final SchemaElement controlSchema = testParseSchema(controlBinding, prefix, fileName); final Map test1Sources = controlSchema.toSource(generatedSourcesDir); if (test1Sources.size() > 0) { @@ -255,20 +255,20 @@ private static void test(final URL resource) throws CompilationException, Decode for (final Map.Entry entry : test1Sources.entrySet()) // [S] compiler.addSource(entry.getValue()); - if (logger.isInfoEnabled()) logger.info(" 5) -- Java(1) Compile --"); + if (logger.isInfoEnabled()) { logger.info(" 5) -- Java(1) Compile --"); } final ClassLoader classLoader = compiler.compile(compiledClassesDir, "-g"); - if (logger.isInfoEnabled()) logger.info(" 6) Java(1) -> Schema"); + if (logger.isInfoEnabled()) { logger.info(" 6) Java(1) -> Schema"); } final SchemaElement test1Schema = newSchema(classLoader, packageName); - if (logger.isInfoEnabled()) logger.info(" 7) Schema -> XML"); + if (logger.isInfoEnabled()) { logger.info(" 7) Schema -> XML"); } final String xml = toXml(test1Schema).toString(); - if (logger.isInfoEnabled()) logger.info(" 8) Validate XML: 8-" + fileName); + if (logger.isInfoEnabled()) { logger.info(" 8) Validate XML: 8-" + fileName); } validate(xml, "8-" + fileName); final SchemaElement test2Schema = testParseSchema((Schema)Bindings.parse(xml), prefix, fileName); - if (logger.isInfoEnabled()) logger.info(" 9) Schema -> Java(2)"); + if (logger.isInfoEnabled()) { logger.info(" 9) Schema -> Java(2)"); } final Map test2Sources = test2Schema.toSource(); - if (logger.isInfoEnabled()) logger.info(" 10) Java(1) == Java(2)"); + if (logger.isInfoEnabled()) { logger.info(" 10) Java(1) == Java(2)"); } assertSources(test1Sources, test2Sources, false); } @@ -285,7 +285,7 @@ private static void testSettings(final URL resource, final String fileName, fina final String outFile = templateThreshold + "-" + fileName; final String outFile1 = "sa-" + outFile; final String outFile2 = "sb-" + outFile; - if (logger.isInfoEnabled()) logger.info(" testSettings(\"" + fileName + "\", new Settings(" + templateThreshold + ")): " + outFile1 + " " + outFile2); + if (logger.isInfoEnabled()) { logger.info(" testSettings(\"" + fileName + "\", new Settings(" + templateThreshold + ")): " + outFile1 + " " + outFile2); } final Schema controlBinding = (Schema)Bindings.parse(resource); final SchemaElement controlSchema = new SchemaElement(controlBinding, settings); final String xml1 = toXml(controlSchema).toString(); @@ -327,14 +327,14 @@ static void assertEquals(final Object expected, final Object actual) { private static String testJson(final String fileName, final Schema controlBinding, final Settings settings) throws DecodeException, IOException, SAXException { final SchemaElement controlSchema = new SchemaElement(controlBinding, settings); - if (logger.isInfoEnabled()) logger.info(" testJson..."); + if (logger.isInfoEnabled()) { logger.info(" testJson..."); } final String outFile = fileName + ".jsd"; - if (logger.isInfoEnabled()) logger.info(" a) Schema -> JSON " + outFile); + if (logger.isInfoEnabled()) { logger.info(" a) Schema -> JSON " + outFile); } final String jsd = JSON.toString(controlSchema.toJson(), 2); writeJsonFile(outFile, jsd); - if (logger.isInfoEnabled()) logger.info(" b) JSON -> Schema"); + if (logger.isInfoEnabled()) { logger.info(" b) JSON -> Schema"); } final SchemaElement schema = new SchemaElement(testParseSchema(jsd, true), settings); - if (logger.isInfoEnabled()) logger.info(" c) Schema -> XML(3)"); + if (logger.isInfoEnabled()) { logger.info(" c) Schema -> XML(3)"); } final String jsdx = toXml(schema).toString(); final Schema jsonBinding = (Schema)Bindings.parse(jsdx); AssertXml.compare(controlBinding.toDOM(), jsonBinding.toDOM()).assertEqual(true); diff --git a/jaxrs/src/main/java/org/jsonx/JxObjectProvider.java b/jaxrs/src/main/java/org/jsonx/JxObjectProvider.java index 41ebfcdc..5a76c20b 100644 --- a/jaxrs/src/main/java/org/jsonx/JxObjectProvider.java +++ b/jaxrs/src/main/java/org/jsonx/JxObjectProvider.java @@ -167,7 +167,8 @@ public void writeTo(final Object t, final Class rawType, final Type genericTy throw new ProcessingException("Unknown type: " + rawType.getName()); final Charset charset = getCharset(mediaType); - if (bufferSize / 2 < json.length()) { // FIXME: This is just an estimate, because UTF-8 can be 1, 2, 3, and 4 bytes; UTF-16 can be 2 or 4 bytes; UTF-32 is 4 bytes. To do this right, we need to count the bytes without encoding them. + if (bufferSize / 2 < json.length()) { // FIXME: This is just an estimate, because UTF-8 can be 1, 2, 3, and 4 bytes; UTF-16 can be 2 or 4 bytes; UTF-32 is 4 bytes. To do + // this right, we need to count the bytes without encoding them. final Writer writer = Channels.newWriter(Channels.newChannel(entityStream), charset.newEncoder(), bufferSize); writer.write(json); writer.flush(); diff --git a/jaxrs/src/test/java/org/jsonx/JxObjectProviderTest.java b/jaxrs/src/test/java/org/jsonx/JxObjectProviderTest.java index ae2eef35..06cb68f8 100644 --- a/jaxrs/src/test/java/org/jsonx/JxObjectProviderTest.java +++ b/jaxrs/src/test/java/org/jsonx/JxObjectProviderTest.java @@ -37,7 +37,7 @@ public class JxObjectProviderTest { public static class Message implements JxObject { private String content; - @StringProperty(name="content") + @StringProperty(name = "content") public String getContent() { return this.content; } @@ -47,8 +47,8 @@ public void setContent(String content) { } } - @ObjectElement(id=0, type=Message.class) - @ArrayType(elementIds={0}) + @ObjectElement(id = 0, type = Message.class) + @ArrayType(elementIds = {0}) @Retention(RetentionPolicy.RUNTIME) public @interface Messages { } diff --git a/jsonx-maven-plugin/src/main/java/org/jsonx/ConvertMojo.java b/jsonx-maven-plugin/src/main/java/org/jsonx/ConvertMojo.java index 52dd1852..51fe2db3 100644 --- a/jsonx-maven-plugin/src/main/java/org/jsonx/ConvertMojo.java +++ b/jsonx-maven-plugin/src/main/java/org/jsonx/ConvertMojo.java @@ -31,8 +31,8 @@ import org.libj.net.URLs; import org.xml.sax.SAXException; -@Mojo(name="convert", defaultPhase=LifecyclePhase.GENERATE_RESOURCES) -@Execute(goal="convert") +@Mojo(name = "convert", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +@Execute(goal = "convert") public class ConvertMojo extends JxMojo { @Override public void execute(final Configuration configuration) throws MojoExecutionException, MojoFailureException { diff --git a/jsonx-maven-plugin/src/main/java/org/jsonx/GenerateMojo.java b/jsonx-maven-plugin/src/main/java/org/jsonx/GenerateMojo.java index e26d91db..df037596 100644 --- a/jsonx-maven-plugin/src/main/java/org/jsonx/GenerateMojo.java +++ b/jsonx-maven-plugin/src/main/java/org/jsonx/GenerateMojo.java @@ -30,19 +30,19 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; import org.libj.lang.Identifiers; -@Mojo(name="generate", defaultPhase=LifecyclePhase.GENERATE_SOURCES) -@Execute(goal="generate") +@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES) +@Execute(goal = "generate") public class GenerateMojo extends JxMojo { - @Parameter(property="prefix", required=true) + @Parameter(property = "prefix", required = true) private String prefix; - @Parameter(property="templateThreshold", required=false) + @Parameter(property = "templateThreshold", required = false) private int templateThreshold = 1; - @Parameter(property="setBuilder", required=false) + @Parameter(property = "setBuilder", required = false) private boolean setBuilder = true; - @Parameter(property="defaultBinding", required=false) + @Parameter(property = "defaultBinding", required = false) private DefaultBinding defaultBinding; // FIXME: Remove this. public static class DefaultBinding { diff --git a/jsonx-maven-plugin/src/main/java/org/jsonx/JxMojo.java b/jsonx-maven-plugin/src/main/java/org/jsonx/JxMojo.java index b92ce2cc..f713ee71 100644 --- a/jsonx-maven-plugin/src/main/java/org/jsonx/JxMojo.java +++ b/jsonx-maven-plugin/src/main/java/org/jsonx/JxMojo.java @@ -25,6 +25,6 @@ public abstract class JxMojo extends GeneratorMojo { @FilterParameter(FilterType.URL) - @Parameter(property="schemas", required=true) + @Parameter(property = "schemas", required = true) List schemas; } \ No newline at end of file diff --git a/jsonx-maven-plugin/src/main/java/org/jsonx/ValidateMojo.java b/jsonx-maven-plugin/src/main/java/org/jsonx/ValidateMojo.java index f847a7fe..cc0a6aa0 100644 --- a/jsonx-maven-plugin/src/main/java/org/jsonx/ValidateMojo.java +++ b/jsonx-maven-plugin/src/main/java/org/jsonx/ValidateMojo.java @@ -32,11 +32,11 @@ import org.openjax.maven.mojo.FilterType; import org.openjax.maven.mojo.PatternSetMojo; -@Mojo(name="validate", defaultPhase=LifecyclePhase.COMPILE) -@Execute(goal="validate") +@Mojo(name = "validate", defaultPhase = LifecyclePhase.COMPILE) +@Execute(goal = "validate") public class ValidateMojo extends PatternSetMojo { @FilterParameter(FilterType.URL) - @Parameter(property="schemas", required=true) + @Parameter(property = "schemas", required = true) private List schemas; @Override diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/AnyTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/AnyTrial.java index bc3ec6b6..8ac51c25 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/AnyTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/AnyTrial.java @@ -69,7 +69,7 @@ else if (AnyType.isEnabled(type.strings())) { } static void add(final List> trials, final Method getMethod, final Method setMethod, final Object object, final AnyProperty property) { - if (logger.isDebugEnabled()) logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); + if (logger.isDebugEnabled()) { logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); } final PentaConsumer,String,String,Annotation> typeDecode = new PentaConsumer,String,String,Annotation>() { @Override public void accept(final Object value, final Class type, final String decode, final String encode, final Annotation typeAnnotation) { diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/ArrayTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/ArrayTrial.java index 1c1259b7..cf90ee9b 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/ArrayTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/ArrayTrial.java @@ -100,7 +100,7 @@ else if (trialType == TrialType.MAX_OCCURS) { } if (annotationToCount.size() == 0) { - if (logger.isWarnEnabled()) logger.warn("Could not create TrialType.MAX_OCCURS"); + if (logger.isWarnEnabled()) { logger.warn("Could not create TrialType.MAX_OCCURS"); } return null; } @@ -126,7 +126,7 @@ else if (trialType == TrialType.MAX_OCCURS) { } static void add(final List> trials, final Method getMethod, final Method setMethod, final Object object, final ArrayProperty property) { - if (logger.isDebugEnabled()) logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); + if (logger.isDebugEnabled()) { logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); } trials.add(new ArrayTrial<>(ValidCase.CASE, getMethod, setMethod, object, createValid(property.type(), property.minIterate(), property.maxIterate(), property.elementIds(), new IdToElement()), property)); final Object testNullable = createArray(property.type(), property.minIterate(), property.maxIterate(), property.elementIds(), new IdToElement(), TrialType.NULLABLE); if (testNullable != null) diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/BooleanTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/BooleanTrial.java index 247380ae..989ac0df 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/BooleanTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/BooleanTrial.java @@ -22,7 +22,7 @@ final class BooleanTrial extends PropertyTrial { static void add(final List> trials, final Method getMethod, final Method setMethod, final Object object, final BooleanProperty property) { - if (logger.isDebugEnabled()) logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); + if (logger.isDebugEnabled()) { logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); } trials.add(new BooleanTrial(ValidCase.CASE, getMethod, setMethod, object, createValid(JsdUtil.getRealType(getMethod), property.decode()), property)); if (getMethod.getReturnType().isPrimitive()) return; diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/ClassTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/ClassTrial.java index fcbab695..3de84e42 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/ClassTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/ClassTrial.java @@ -196,7 +196,7 @@ private String testEncode(final PropertyTrial trial, final Relations[] relati ++count; } catch (final Throwable t) { - if (logger.isInfoEnabled()) logger.info(String.format("%06d", count) + " onEncode(" + trial.getMethod.getDeclaringClass().getSimpleName() + "." + trial.getMethod.getName() + "(), " + trial.kase.getClass().getSimpleName() + ")"); + if (logger.isInfoEnabled()) { logger.info(String.format("%06d", count) + " onEncode(" + trial.getMethod.getDeclaringClass().getSimpleName() + "." + trial.getMethod.getName() + "(), " + trial.kase.getClass().getSimpleName() + ")"); } if (logger.isErrorEnabled()) { logger.error(" Value: " + Strings.indent(String.valueOf(value), 2)); logger.error(" JSON: " + Strings.indent(String.valueOf(json), 2)); @@ -250,7 +250,7 @@ private JxObject testDecode(final PropertyTrial trial, final Relations[] rela ++count; } catch (final Throwable t) { - if (logger.isInfoEnabled()) logger.info(String.format("%06d", count) + " onDecode(" + trial.getMethod.getDeclaringClass().getSimpleName() + "." + trial.getMethod.getName() + "(), " + trial.kase.getClass().getSimpleName() + ")"); + if (logger.isInfoEnabled()) { logger.info(String.format("%06d", count) + " onDecode(" + trial.getMethod.getDeclaringClass().getSimpleName() + "." + trial.getMethod.getName() + "(), " + trial.kase.getClass().getSimpleName() + ")"); } logger.error(" Value: " + Strings.indent(String.valueOf(object[0]), 2)); logger.error(" JSON: " + Strings.indent(String.valueOf(json), 2)); logger.error(t.getMessage(), t); diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/NumberTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/NumberTrial.java index 48fb4609..8e03fe67 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/NumberTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/NumberTrial.java @@ -30,7 +30,7 @@ final class NumberTrial extends PropertyTrial { static void add(final List> trials, final Method getMethod, final Method setMethod, final Object object, final NumberProperty property) { try { - if (logger.isDebugEnabled()) logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); + if (logger.isDebugEnabled()) { logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); } final Range range = property.range().length() == 0 ? null : Range.from(property.range(), property.scale(), JsdUtil.getRealType(getMethod)); trials.add(new NumberTrial(ValidCase.CASE, getMethod, setMethod, object, toProperForm(JsdUtil.getRealType(getMethod), property.decode(), property.scale(), makeValid(range)), property)); diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/ObjectTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/ObjectTrial.java index a30d799d..92616fb8 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/ObjectTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/ObjectTrial.java @@ -143,7 +143,7 @@ public void accept(final Object value, final Class type, final String decode, } static void add(final List> trials, final Method getMethod, final Method setMethod, final Object object, final ObjectProperty property) { - if (logger.isDebugEnabled()) logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); + if (logger.isDebugEnabled()) { logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); } trials.add(new ObjectTrial(ValidCase.CASE, getMethod, setMethod, object, createValid(JsdUtil.getRealType(getMethod)), property)); if (getMethod.getReturnType().isPrimitive()) return; diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/RuntimeTest.java b/jsonx-maven-plugin/src/test/java/org/jsonx/RuntimeTest.java index d1ecea4c..e3bd2e71 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/RuntimeTest.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/RuntimeTest.java @@ -38,7 +38,7 @@ private static void test(final Class cls) throws Exception { @AfterClass public static void afterClass() { - if (logger.isInfoEnabled()) logger.info("Successful tests: " + count); + if (logger.isInfoEnabled()) { logger.info("Successful tests: " + count); } } @Test diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/SchemaGeneratorTest.java b/jsonx-maven-plugin/src/test/java/org/jsonx/SchemaGeneratorTest.java index b3d71a82..9cb69c10 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/SchemaGeneratorTest.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/SchemaGeneratorTest.java @@ -35,8 +35,8 @@ private static void test(final String version) throws IOException { final File controlJavaFile = new File("../generator/src/main/java", javaPath); final File testJavaFile = new File(destDir, javaPath); - final String controlSource = new String(Files.readAllBytes(controlJavaFile.toPath())).replaceFirst(", date=\"[^\"]+\"", ", date=\"\""); - final String testSource = new String(Files.readAllBytes(testJavaFile.toPath())).replaceFirst(", date=\"[^\"]+\"", ", date=\"\""); + final String controlSource = new String(Files.readAllBytes(controlJavaFile.toPath())).replaceFirst(", date = \"[^\"]+\"", ", date = \"\""); + final String testSource = new String(Files.readAllBytes(testJavaFile.toPath())).replaceFirst(", date = \"[^\"]+\"", ", date = \"\""); if (!controlSource.equals(testSource)) { System.out.println(testSource); fail(); diff --git a/jsonx-maven-plugin/src/test/java/org/jsonx/StringTrial.java b/jsonx-maven-plugin/src/test/java/org/jsonx/StringTrial.java index 263cab63..c3200db0 100644 --- a/jsonx-maven-plugin/src/test/java/org/jsonx/StringTrial.java +++ b/jsonx-maven-plugin/src/test/java/org/jsonx/StringTrial.java @@ -86,7 +86,7 @@ String random() { } static void add(final List> trials, final Method getMethod, final Method setMethod, final Object object, final StringProperty property) { - if (logger.isDebugEnabled()) logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); + if (logger.isDebugEnabled()) { logger.debug("Adding: " + getMethod.getDeclaringClass() + "." + getMethod.getName() + "()"); } trials.add(new StringTrial(ValidCase.CASE, getMethod, setMethod, object, createValid(JsdUtil.getRealType(getMethod), property.decode(), property.pattern()), property)); if (property.pattern().length() > 0) trials.add(new StringTrial(PatternCase.CASE, getMethod, setMethod, object, createInvalid(JsdUtil.getRealType(getMethod), property.decode(), property.pattern()), property)); diff --git a/jsonxml/src/main/java/org/jsonx/JxConverter.java b/jsonxml/src/main/java/org/jsonx/JxConverter.java index 23576985..f0ef18d8 100644 --- a/jsonxml/src/main/java/org/jsonx/JxConverter.java +++ b/jsonxml/src/main/java/org/jsonx/JxConverter.java @@ -110,7 +110,7 @@ else if (c0 == ',') { } else { appendValue(reader, off, len, b); -// CharacterDatas.escapeForElem(b, reader.buf(), off, len); + // CharacterDatas.escapeForElem(b, reader.buf(), off, len); prev = '\0'; token = -1; } @@ -337,7 +337,7 @@ private boolean processCharacters(final boolean hasMore) { final String value = matcher.group("value"); if (value != null) b.append(value); // The SAXParser automatically unescapes the text - // CharacterDatas.unescapeFromElem(b, value); + // CharacterDatas.unescapeFromElem(b, value); final String ws = matcher.group("ws"); if (ws != null && ws.length() > 0) @@ -374,19 +374,19 @@ else if (prevWs != null) { } /** - * Converts a JSON document from the specified {@link JsonReader} to a JSONx - * document without declaring the XML namespace. + * Converts a JSON document from the specified {@link JsonReader} to a JSONx document without declaring the XML namespace. *

* This method is equivalent to calling * *

-   * {@code jsonToJsonx(reader, false)}
+   * {@code
+   * jsonToJsonx(reader, false)
+   * }
    * 
* * @implSpec This method is thread safe. - * @param reader The {@link JsonReader} for the JSON document to be converted. - * declare the {@code xmlns} and {@code xsi:schemaLocation} - * attributes in the root element. + * @param reader The {@link JsonReader} for the JSON document to be converted. declare the {@code xmlns} and + * {@code xsi:schemaLocation} attributes in the root element. * @return A JSONx document equivalent of the JSON document. * @throws IOException If an I/O error has occurred. * @throws IllegalArgumentException If {@code reader} is null.