- moduleFields.add(new ModuleField(type, varName, attributeIfc
- .getUpperCaseCammelCase(), nullableDefaultWrapped, isDependency, dependency));
+
+ ModuleField field;
+
+ if (isIdentity) {
+ String identityBaseClass = getInnerTypeFromIdentity(((TypedAttribute) attributeIfc).getType());
+ IdentityRefModuleField identityField = new IdentityRefModuleField(type, varName,
+ attributeIfc.getUpperCaseCammelCase(), identityBaseClass);
+
+ String getterName = "get"
+ + attributeIfc.getUpperCaseCammelCase() + "Identity";
+ MethodDefinition additionalGetter = new MethodDefinition(type, getterName, Collections.<Field> emptyList(),
+ Collections.<Annotation> emptyList(), "return " + identityField.getIdentityClassName()
+ + ";");
+ methods.add(additionalGetter);
+
+ String setterName = "set"
+ + attributeIfc.getUpperCaseCammelCase();
+
+ String setterBody = "this." + identityField.getIdentityClassName() + " = " + identityField.getIdentityClassName() + ";";
+ MethodDefinition additionalSetter = new MethodDefinition("void",
+ setterName,
+ Lists.newArrayList(new Field(type, identityField.getIdentityClassName())),
+ Collections.<Annotation> emptyList(), setterBody);
+ additionalSetter.setJavadoc(attributeIfc.getNullableDescription());
+
+ methods.add(additionalSetter);
+
+ type = serializeType(identityRefType);
+ field = identityField;
+ } else {
+ field = new ModuleField(type, varName, attributeIfc.getUpperCaseCammelCase(),
+ nullableDefaultWrapped, isDependency, dependency, isListOfDependencies, needsDepResolver);
+ }
+ moduleFields.add(field);