for (int i = 0; i < identityFieldCount; i += 1) {
// Get the field name.
String fieldName = tags [i].text ();
FieldInfo identityField;
// If it is inherited from the base class then ignore it.
identityField = identityBaseClassInfo.getField (fieldName, true);
if (identityField != null) {
if (GenerateUtilities.isProjectField(identityField)) {
projectIdentityField = identityField;
}
// Add it to the list of all the identity fields.
allIdentityFields.add (identityField);
continue;
}
// Get the details of the object's field.
FieldInfo objectField = objectClassInfo.getField (fieldName, true);
String comment = objectField.getComment ();
comment = getConstructorParameterComment (objectClassDoc,
fieldName,
comment);
// Create a field for the identity class.
identityField = new FieldInfo (objectField, comment);
// Add it to the class.
identityClassInfo.addField (identityField);
// Add it to the list of all the identity fields.
allIdentityFields.add (identityField);
// Get the details of the object's getter method.
MethodInfo objectGetter = objectClassInfo.getGetterMethod (fieldName,
true);
MethodInfo identityGetter
= new MethodInfo (objectGetter.getName (),
objectGetter.getReturnType (),
objectGetter.getComment ());
// Add it to the class.
identityClassInfo.addMethod (identityGetter);
}
// Create the list of parameters for the constructor.
List constructorParameters = new ArrayList ();
for (Iterator i = allIdentityFields.iterator (); i.hasNext ();) {
FieldInfo field = (FieldInfo) i.next ();
ParameterInfo parameter = new ParameterInfo (field.getClassInfo (),
field.getName (),
field.getType ());
constructorParameters.add (parameter);
}
ConstructorInfo constructor = new ConstructorInfo (constructorParameters);
identityClassInfo.addConstructor (constructor);
// Get the list of extra identity fields.
if (guardianInfo == null) {
extraIdentityFields = new ArrayList (allIdentityFields);
} else {
ClassInfo guardianIdentityClassInfo
= guardianInfo.getIdentityClassInfo ();
extraIdentityFields = getExtraFields (allIdentityFields,
guardianIdentityClassInfo);
}
// Create the set of the names of fields to ignore.
Set ignore = new HashSet ();
ignore.add ("identity");
tags = objectClassDoc.tags ("mariner-object-ignore-field");
for (int i = 0; i < tags.length; i += 1) {
//System.out.println ("Field " + tags [i].text ()
//+ " should be ignored");
ignore.add (tags [i].text ());
}
// Initialise the list of object fields.
allObjectFields = objectClassInfo.getAllInstanceFields ();
for (Iterator i = allObjectFields.iterator (); i.hasNext ();) {
FieldInfo field = (FieldInfo) i.next ();
String fieldName = field.getName ();
if (ignore.contains (fieldName)) {
//System.out.println ("Ignoring " + fieldName);
i.remove ();
}
}
extraObjectFields = getExtraFields (allObjectFields, identityClassInfo);
dependentsInfo = new ArrayList ();
tags = objectClassDoc.tags ("mariner-object-dependent");
for (int i = 0; i < tags.length; i += 1) {
String dependentClassName = tags [i].text ();
ClassDoc dependentClassDoc = rootDoc.classNamed (dependentClassName);
if (dependentClassDoc == null) {
throw new IllegalStateException ("Cannot find class named "
+ dependentClassName);
}
RepositoryObjectInfo dependentInfo = getInstance (rootDoc,
dependentClassDoc);
dependentsInfo.add (dependentInfo);
}
tags = objectClassDoc.tags("mariner-separate-accessors");
if (tags.length == 0) {
hasSeparateAccessors = false;
} else if (tags.length == 1) {
hasSeparateAccessors = true;
} else {
throw new IllegalStateException ("Class can only have one"
+ " mariner-separate-accessors");
}
requiredFields = new HashSet ();
tags = objectClassDoc.tags ("mariner-object-required-field");
for (int i = 0; i < tags.length; i += 1) {
String fieldName = tags [i].text ();
requiredFields.add (fieldName);
}
// All the identity fields are also required.
for (Iterator i = allIdentityFields.iterator (); i.hasNext ();) {
FieldInfo field = (FieldInfo) i.next ();
String fieldName = field.getName();
requiredFields.add (fieldName);
}