Skip to content

Commit 1e3d77e

Browse files
committed
Issue #22.
1 parent 8100eea commit 1e3d77e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

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

3-
import java.util.ArrayList;
4-
import java.util.List;
3+
import java.util.LinkedHashMap;
4+
import java.util.Map;
5+
import java.util.Map.Entry;
56

67
import javax.xml.namespace.QName;
78

@@ -58,24 +59,28 @@ public JsonSchemaBuilder compile(MClassInfo<T, C> classInfo) {
5859
typeInfoSchemaBuilder = classInfoSchemaBuilder;
5960
}
6061

61-
final List<JsonSchemaBuilder> propertyInfoSchemaBuilders = compilePropertyInfos(classInfo);
62-
for (JsonSchemaBuilder propertyInfoSchemaBuilder : propertyInfoSchemaBuilders) {
63-
classInfoSchemaBuilder.addItem(propertyInfoSchemaBuilder);
62+
// TODO move to the builder
63+
final Map<String, JsonSchemaBuilder> propertyInfoSchemaBuilders = compilePropertyInfos(classInfo);
64+
for (Entry<String, JsonSchemaBuilder> entry : propertyInfoSchemaBuilders
65+
.entrySet()) {
66+
classInfoSchemaBuilder
67+
.addProperty(entry.getKey(), entry.getValue());
6468
}
6569

6670
return typeInfoSchemaBuilder;
6771
}
6872

69-
private List<JsonSchemaBuilder> compilePropertyInfos(
73+
private Map<String, JsonSchemaBuilder> compilePropertyInfos(
7074
MClassInfo<T, C> classInfo) {
71-
final List<JsonSchemaBuilder> propertyInfoSchemaBuilders = new ArrayList<JsonSchemaBuilder>(
75+
final Map<String, JsonSchemaBuilder> propertyInfoSchemaBuilders = new LinkedHashMap<String, JsonSchemaBuilder>(
7276
classInfo.getProperties().size());
7377
for (MPropertyInfo<T, C> propertyInfo : classInfo.getProperties()) {
7478
if (mapping.getPropertyInfos().contains(propertyInfo)) {
7579
propertyInfoSchemaBuilders
76-
.add(propertyInfo
77-
.acceptPropertyInfoVisitor(new JsonSchemaPropertyInfoCompilerVisitor<T, C>(
78-
this)));
80+
.put(propertyInfo.getPrivateName(),
81+
propertyInfo
82+
.acceptPropertyInfoVisitor(new JsonSchemaPropertyInfoCompilerVisitor<T, C>(
83+
this)));
7984
}
8085
}
8186
return propertyInfoSchemaBuilders;

0 commit comments

Comments
 (0)