|
1 | 1 | package org.hisrc.jsonix.compilation.jsc; |
2 | 2 |
|
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; |
5 | 6 |
|
6 | 7 | import javax.xml.namespace.QName; |
7 | 8 |
|
@@ -58,24 +59,28 @@ public JsonSchemaBuilder compile(MClassInfo<T, C> classInfo) { |
58 | 59 | typeInfoSchemaBuilder = classInfoSchemaBuilder; |
59 | 60 | } |
60 | 61 |
|
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()); |
64 | 68 | } |
65 | 69 |
|
66 | 70 | return typeInfoSchemaBuilder; |
67 | 71 | } |
68 | 72 |
|
69 | | - private List<JsonSchemaBuilder> compilePropertyInfos( |
| 73 | + private Map<String, JsonSchemaBuilder> compilePropertyInfos( |
70 | 74 | MClassInfo<T, C> classInfo) { |
71 | | - final List<JsonSchemaBuilder> propertyInfoSchemaBuilders = new ArrayList<JsonSchemaBuilder>( |
| 75 | + final Map<String, JsonSchemaBuilder> propertyInfoSchemaBuilders = new LinkedHashMap<String, JsonSchemaBuilder>( |
72 | 76 | classInfo.getProperties().size()); |
73 | 77 | for (MPropertyInfo<T, C> propertyInfo : classInfo.getProperties()) { |
74 | 78 | if (mapping.getPropertyInfos().contains(propertyInfo)) { |
75 | 79 | 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))); |
79 | 84 | } |
80 | 85 | } |
81 | 86 | return propertyInfoSchemaBuilders; |
|
0 commit comments