*/
public String currentElementComparator(Node source, Node dest, NodeList srcNodes, NodeList destNodes) {
StringBuilder comparator = new StringBuilder();
MapperKey key = new MapperKey(source.elementRef.type(), dest.elementRef.type());
ClassMap<?,?> classMap = mapperFactory.getClassMap(key);
if (classMap == null) {
classMap = mapperFactory.classMap(key.getAType(), key.getBType()).byDefault().toClassMap();
}
String or = "";
Set<FieldMap> fieldMaps = new HashSet<FieldMap>(classMap.getFieldsMapping());
for (Node node: source.children) {
if (node.value != null) {
fieldMaps.add(node.value);
}
}
for (Node node: dest.children) {
if (node.value != null) {
fieldMaps.add(node.value);
}
}
Set<String> comparisons = new HashSet<String>();
for (FieldMap fieldMap: fieldMaps) {
if (!(fieldMap.is(aMultiOccurrenceElementMap()) && fieldMap.isByDefault())
&& !fieldMap.isExcluded()
&& !fieldMap.isIgnored()) {
Node srcNode = Node.findFieldMap(fieldMap, srcNodes, true);
if (srcNode != null && srcNode.parent != null) {
srcNode = srcNode.parent;
} else {
srcNode = source;
}
Node destNode = Node.findFieldMap(fieldMap, destNodes, false);
if (destNode != null && destNode.parent != null) {
destNode = destNode.parent;
} else {
destNode = dest;
}
Type<?> sourceType = source.elementRef.type();
Type<?> destType = dest.elementRef.type();
try {
propertyResolver.getProperty(sourceType, fieldMap.getSource().getName());
propertyResolver.getProperty(destType, fieldMap.getDestination().getName());
VariableRef s = new VariableRef(fieldMap.getSource(), srcNode.elementRef);
VariableRef d = new VariableRef(fieldMap.getDestination(), destNode.elementRef);
String code = this.compareFields(fieldMap, s, d, key.getBType(), null);
if (!"".equals(code) && comparisons.add(code)) {
comparator.append(or + "!(" + code + ")");
or = " || ";
}
} catch (Exception e) {