public PathCost process(PathCost cost, PasswordResults password) {
PathCost newPath = new PathCost(password);
List<PasswordPattern> path = cost.getPath();
for (int len = path.size() - 1, i = len; i >= 0; i--) {
PasswordPattern pass = path.get(i);
boolean foundDuplicate = false;
for (int j = i - 1; j >= 0; j--) {
PasswordPattern toCompare = path.get(j);
if (!toCompare.getName().equals(RandomPattern.RANDOM_PATTERN)
&& toCompare.getName().equals(pass.getName())
&& toCompare.getMatchString().equals(pass.getMatchString())) {
//repeated-duplicate pattern instance
foundDuplicate = true;
break;
}
}
if (foundDuplicate) {
PasswordPattern dupp = new PasswordPattern(pass.getStartIndex(), pass.getLength(), pass.getMatchString(), 1,
"Duplication of an earlier pattern: " + pass.getName(), DUPLICATE_PATTERN, null);
newPath.addPattern(dupp);
} else {
newPath.addPattern(pass);
}