@SuppressWarnings("unchecked")
private static void createLabelcodeMatchFromLabel(
Map<NfoField, MatchResult> matches, MatchResult labelNameMatch) {
SimilarScanResult<Label> sr = (SimilarScanResult<Label>) labelNameMatch.getSimilarScanResult();
if (sr != null) { // at least one found label
Label l = null; // holds the found label
Labelcode lc;
SimilarScanResult<Labelcode> srlc = null; // holds the label code alternatives
Match<Labelcode> mt = null; // holds the virtual match
// => create virtual label code match from best label match having codes
final int c = sr.size();
MatchResult mr = null;
for (int i = 0; i < c; i++) { // iterate label matches
l = sr.get(i).getFoundObject(); // get label object from match
if (l.size() == 0) { continue; } // label has no codes => skip
// label has codes => create matches
int ci = 0;
if (mr == null) { // no match result yet => create from best entry & store
mr = new MatchResult(l.get(ci++).getName(), Source.LOOKUP, Status.SIMILAR); // XXX derived, (not similar) entry !
matches.put(NfoField.LABEL_CODE, mr);
}
for (int y = ci; y < l.size(); y++) { // => add other codes as alternatives
lc = l.get(y);
// XXX for now, use fake leven, but create virtual match type l8a on
mt = new Match<Labelcode>(MatchType.LEVENSHTEIN, lc.getName(), lc);
if (srlc == null) {
srlc = new SimilarScanResult<Labelcode>(mt);
mr.setSimilarScanResult(srlc);