int serverFieldIdx = 0;
if (DEBUG) System.out.printf("B: Server List: %s\nB: Client List: %s\n", Lists.transform(sFields, FieldName.instance), Lists.transform(cFields, FieldName.instance));
for (int clientFieldIdx = 0; clientFieldIdx < cFields.size(); clientFieldIdx++)
{
FieldNode clientField = cFields.get(clientFieldIdx);
if (serverFieldIdx < sFields.size())
{
FieldNode serverField = sFields.get(serverFieldIdx);
if (!clientField.name.equals(serverField.name))
{
boolean foundServerField = false;
for (int serverFieldSearchIdx = serverFieldIdx + 1; serverFieldSearchIdx < sFields.size(); serverFieldSearchIdx++)
{
if (clientField.name.equals(sFields.get(serverFieldSearchIdx).name))
{
foundServerField = true;
break;
}
}
// Found a server field match ahead in the list - walk to it and add the missing server fields to the client
if (foundServerField)
{
boolean foundClientField = false;
for (int clientFieldSearchIdx = clientFieldIdx + 1; clientFieldSearchIdx < cFields.size(); clientFieldSearchIdx++)
{
if (serverField.name.equals(cFields.get(clientFieldSearchIdx).name))
{
foundClientField = true;
break;
}
}
if (!foundClientField)
{
if (serverField.visibleAnnotations == null)
{
serverField.visibleAnnotations = new ArrayList<AnnotationNode>();
}
serverField.visibleAnnotations.add(getSideAnn(false));
cFields.add(clientFieldIdx, serverField);
if (DEBUG) System.out.printf("1. Server List: %s\n1. Client List: %s\nIdx: %d %d\n", Lists.transform(sFields, FieldName.instance), Lists.transform(cFields, FieldName.instance), serverFieldIdx, clientFieldIdx);
}
}
else
{
if (clientField.visibleAnnotations == null)
{
clientField.visibleAnnotations = new ArrayList<AnnotationNode>();
}
clientField.visibleAnnotations.add(getSideAnn(true));
sFields.add(serverFieldIdx, clientField);
if (DEBUG) System.out.printf("2. Server List: %s\n2. Client List: %s\nIdx: %d %d\n", Lists.transform(sFields, FieldName.instance), Lists.transform(cFields, FieldName.instance), serverFieldIdx, clientFieldIdx);
}
}
}
else
{
if (clientField.visibleAnnotations == null)
{
clientField.visibleAnnotations = new ArrayList<AnnotationNode>();
}
clientField.visibleAnnotations.add(getSideAnn(true));
sFields.add(serverFieldIdx, clientField);
if (DEBUG) System.out.printf("3. Server List: %s\n3. Client List: %s\nIdx: %d %d\n", Lists.transform(sFields, FieldName.instance), Lists.transform(cFields, FieldName.instance), serverFieldIdx, clientFieldIdx);
}
serverFieldIdx++;
}
if (DEBUG) System.out.printf("A. Server List: %s\nA. Client List: %s\n", Lists.transform(sFields, FieldName.instance), Lists.transform(cFields, FieldName.instance));
if (sFields.size() != cFields.size())
{
for (int x = cFields.size(); x < sFields.size(); x++)
{
FieldNode sF = sFields.get(x);
if (sF.visibleAnnotations == null)
{
sF.visibleAnnotations = new ArrayList<AnnotationNode>();
}
sF.visibleAnnotations.add(getSideAnn(true));