19 package org.sleuthkit.autopsy.datamodel.persons;
21 import java.util.Collection;
23 import java.util.stream.Collectors;
24 import java.util.stream.Stream;
25 import org.apache.commons.lang3.StringUtils;
26 import org.openide.util.NbBundle;
46 "PersonNameValidator_getValidationMessage_onEmpty=Please provide some text for the person name.",
47 "PersonNameValidator_getValidationMessage_sameAsOriginal=Please provide a new name for this person.",
48 "PersonNameValidator_getValidationMessage_onDuplicate=Another person already has the same name. Please choose a different name.",})
49 public static String
getValidationMessage(String curName, String initialName, Set<String> currentPersonsTrimmedUpper) {
51 if (StringUtils.isBlank(curName)) {
52 return Bundle.PersonNameValidator_getValidationMessage_onEmpty();
55 if (StringUtils.equalsIgnoreCase(initialName, curName)) {
56 return Bundle.PersonNameValidator_getValidationMessage_sameAsOriginal();
59 if (currentPersonsTrimmedUpper.contains(curName.trim().toUpperCase())) {
60 return Bundle.PersonNameValidator_getValidationMessage_onDuplicate();
74 Stream<Person> personsStream = persons != null ? persons.stream() : Stream.empty();
76 .map(h -> h == null ? null : h.getName())
77 .filter(hName -> StringUtils.isNotBlank(hName))
78 .map(hName -> hName.trim().toUpperCase())
79 .collect(Collectors.toSet());
static String getValidationMessage(String curName, String initialName, Set< String > currentPersonsTrimmedUpper)
static Set< String > getSanitizedPersonNames(Collection< Person > persons)