// now process the last bit
String last = splits[splits.length-1];
if (entity.attributeNamed(last) != null) {
// it's a plain attribute value comparison
return new Comparison(rels, entity.attributeNamed(last), operator, value);
} else {
// it's a relationship value comparison, let's represent it as attribute comparison
EORelationship lastRel = entity.relationshipNamed(last);
EOAttribute srcAtt = asOne(lastRel.sourceAttributes());
EOAttribute dstAtt = asOne(lastRel.destinationAttributes());
rels.add(lastRel);
if (value != null) {
value = ((NSKeyValueCoding) value).valueForKey(dstAtt.name());
}
return new Comparison(rels, srcAtt, operator, value);
}
}