Skip to content

Commit 4d2d100

Browse files
committed
Issue #22.
1 parent cceeb60 commit 4d2d100

File tree

5 files changed

+34
-37
lines changed

5 files changed

+34
-37
lines changed

compiler/src/main/java/org/hisrc/jsonix/compilation/jsc/JsonSchemaClassInfoCompiler.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ public JsonSchemaBuilder compile(MClassInfo<T, C> classInfo) {
4444
// TODO addId ?
4545
// ...
4646
final MClassTypeInfo<T, C> baseTypeInfo = classInfo.getBaseTypeInfo();
47-
final JsonSchemaBuilder typeInfoSchemaBuilder;
47+
final JsonSchemaBuilder typeInfoSchema;
4848
if (baseTypeInfo != null) {
49-
final JsonSchemaBuilder baseTypeInfoSchemaBuilder = mappingCompiler
49+
final JsonSchemaBuilder baseTypeInfoSchema = mappingCompiler
5050
.createTypeInfoSchemaRef(baseTypeInfo);
51-
typeInfoSchemaBuilder = new JsonSchemaBuilder();
52-
typeInfoSchemaBuilder.addAllOf(baseTypeInfoSchemaBuilder);
53-
typeInfoSchemaBuilder.addAllOf(classInfoSchema);
51+
typeInfoSchema = new JsonSchemaBuilder();
52+
typeInfoSchema.addAllOf(baseTypeInfoSchema);
53+
typeInfoSchema.addAllOf(classInfoSchema);
5454
} else {
55-
typeInfoSchemaBuilder = classInfoSchema;
55+
typeInfoSchema = classInfoSchema;
5656
}
5757

5858
// TODO move to the builder
59-
final Map<String, JsonSchemaBuilder> propertyInfoSchemaBuilders = compilePropertyInfos(classInfo);
60-
for (Entry<String, JsonSchemaBuilder> entry : propertyInfoSchemaBuilders
59+
final Map<String, JsonSchemaBuilder> propertyInfoSchemas = compilePropertyInfos(classInfo);
60+
for (Entry<String, JsonSchemaBuilder> entry : propertyInfoSchemas
6161
.entrySet()) {
6262
classInfoSchema.addProperty(entry.getKey(), entry.getValue());
6363
}
@@ -74,22 +74,22 @@ public JsonSchemaBuilder compile(MClassInfo<T, C> classInfo) {
7474
typeName.getNamespaceURI()));
7575
}
7676

77-
return typeInfoSchemaBuilder;
77+
return typeInfoSchema;
7878
}
7979

8080
private Map<String, JsonSchemaBuilder> compilePropertyInfos(
8181
MClassInfo<T, C> classInfo) {
82-
final Map<String, JsonSchemaBuilder> propertyInfoSchemaBuilders = new LinkedHashMap<String, JsonSchemaBuilder>(
82+
final Map<String, JsonSchemaBuilder> propertyInfoSchemas = new LinkedHashMap<String, JsonSchemaBuilder>(
8383
classInfo.getProperties().size());
8484
for (MPropertyInfo<T, C> propertyInfo : classInfo.getProperties()) {
8585
if (mapping.getPropertyInfos().contains(propertyInfo)) {
86-
propertyInfoSchemaBuilders
86+
propertyInfoSchemas
8787
.put(propertyInfo.getPrivateName(),
8888
propertyInfo
8989
.acceptPropertyInfoVisitor(new JsonSchemaPropertyInfoCompilerVisitor<T, C>(
9090
this)));
9191
}
9292
}
93-
return propertyInfoSchemaBuilders;
93+
return propertyInfoSchemas;
9494
}
9595
}

compiler/src/main/java/org/hisrc/jsonix/compilation/jsc/JsonSchemaModuleCompiler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ public Module<T, C> getModule() {
3737
}
3838

3939
public JsonSchemaBuilder compile() {
40-
final List<JsonSchemaBuilder> mappingSchemaBuilders = new ArrayList<JsonSchemaBuilder>(
40+
final List<JsonSchemaBuilder> mappingSchemas = new ArrayList<JsonSchemaBuilder>(
4141
this.module.getMappings().size());
4242
for (Mapping<T, C> mapping : this.module.getMappings()) {
4343
if (!mapping.isEmpty()) {
4444
final JsonSchemaMappingCompiler<T, C> mappingCompiler = new JsonSchemaMappingCompiler<T, C>(
4545
this, mapping);
4646

47-
final JsonSchemaBuilder mappingSchemaBuilder = mappingCompiler
47+
final JsonSchemaBuilder mappingSchema = mappingCompiler
4848
.compile();
4949

50-
mappingSchemaBuilders.add(mappingSchemaBuilder);
50+
mappingSchemas.add(mappingSchema);
5151
}
5252
}
5353

54-
if (mappingSchemaBuilders.size() == 1) {
55-
return mappingSchemaBuilders.get(0);
54+
if (mappingSchemas.size() == 1) {
55+
return mappingSchemas.get(0);
5656
} else {
57-
final JsonSchemaBuilder schemaBuilder = new JsonSchemaBuilder();
58-
for (JsonSchemaBuilder mappingSchemaBuilder : mappingSchemaBuilders) {
59-
schemaBuilder.addAnyOf(mappingSchemaBuilder);
57+
final JsonSchemaBuilder schema = new JsonSchemaBuilder();
58+
for (JsonSchemaBuilder mappingSchema : mappingSchemas) {
59+
schema.addAnyOf(mappingSchema);
6060
}
61-
return schemaBuilder;
61+
return schema;
6262
}
6363
}
6464

compiler/src/main/java/org/hisrc/jsonix/compilation/jsc/JsonSchemaModulesCompiler.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.hisrc.jsonix.compilation.jsc;
22

33
import javax.json.JsonBuilderFactory;
4-
import javax.json.JsonObject;
54
import javax.json.spi.JsonProvider;
65

76
import org.apache.commons.lang3.Validate;
@@ -33,11 +32,9 @@ public void compile(JsonStructureWriter<T, C> writer) {
3332
for (Output output : module.getOutputs()) {
3433
final JsonSchemaModuleCompiler<T, C> moduleCompiler = new JsonSchemaModuleCompiler<T, C>(
3534
this, module);
36-
final JsonSchemaBuilder schemaBuilder = moduleCompiler
37-
.compile();
38-
final JsonObject schema = schemaBuilder
39-
.build(builderFactory);
40-
writer.writeJsonStructure(module, schema, output);
35+
final JsonSchemaBuilder schema = moduleCompiler.compile();
36+
writer.writeJsonStructure(module,
37+
schema.build(builderFactory), output);
4138
}
4239
}
4340
}

compiler/src/main/java/org/hisrc/jsonix/compilation/jsc/JsonSchemaPropertyInfoCompilerVisitor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ private void addPropertyInfoTypeSchema(String string,
224224
}
225225

226226
private void addPropertyInfoSchema(MPropertyInfo<T, C> propertyInfo,
227-
JsonSchemaBuilder schemaBuilder) {
228-
schemaBuilder.addTitle(propertyInfo.getPrivateName());
227+
JsonSchemaBuilder schema) {
228+
schema.addTitle(propertyInfo.getPrivateName());
229229
}
230230

231231
private void addWrappableSchema(MWrappable info, JsonSchemaBuilder schema) {
@@ -336,15 +336,15 @@ private JsonSchemaBuilder createPossiblyAnyOfTypeSchema(
336336

337337
private JsonSchemaBuilder createPossiblyCollectionTypeSchema(
338338
boolean collection, final JsonSchemaBuilder itemTypeSchema) {
339-
final JsonSchemaBuilder typeSchemaBuilder;
339+
final JsonSchemaBuilder typeSchema;
340340
if (collection) {
341-
typeSchemaBuilder = new JsonSchemaBuilder();
342-
typeSchemaBuilder.addType(JsonSchemaConstants.ARRAY_TYPE).addItem(
341+
typeSchema = new JsonSchemaBuilder();
342+
typeSchema.addType(JsonSchemaConstants.ARRAY_TYPE).addItem(
343343
itemTypeSchema);
344344
} else {
345-
typeSchemaBuilder = itemTypeSchema;
345+
typeSchema = itemTypeSchema;
346346
}
347-
return typeSchemaBuilder;
347+
return typeSchema;
348348
}
349349

350350
private JsonSchemaBuilder createTypeSchema(MTypeInfo<T, C> typeInfo) {

compiler/src/main/java/org/hisrc/jsonix/compilation/jsc/JsonSchemaRefTypeInfoCompilerVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ public JsonSchemaBuilder visitIDREFS(MIDREFS<T, C> info) {
9696
public JsonSchemaBuilder visitBuiltinLeafInfo(MBuiltinLeafInfo<T, C> info) {
9797
final QName typeName = info.getTypeName();
9898
final String $ref = this.typeNameSchemaRefs.get(typeName);
99-
final JsonSchemaBuilder schemaBuilder = new JsonSchemaBuilder();
99+
final JsonSchemaBuilder schema = new JsonSchemaBuilder();
100100
if ($ref != null) {
101-
return schemaBuilder.addRef($ref);
101+
return schema.addRef($ref);
102102
} else {
103-
return schemaBuilder
103+
return schema
104104
.addDescription(MessageFormat
105105
.format("WARNING, the type [{0}] is not supported, using the lax schema {}.",
106106
typeName));

0 commit comments

Comments
 (0)