* or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
* specified authority has been found.
*/
private static String getName(final IdentifiedObject object, final Citation authority, final Collection<String> addTo) {
if (object != null) {
Identifier identifier = object.getName();
if (authority == null) {
if (identifier != null) {
final String name = identifier.getCode();
if (name != null) {
if (addTo == null) {
return name;
}
addTo.add(name);
}
}
final Iterator<GenericName> it = iterator(object.getAlias());
if (it != null) while (it.hasNext()) {
final GenericName alias = it.next();
if (alias != null) {
final String name = (alias instanceof Identifier) ?
((Identifier) alias).getCode() : alias.toString();
if (name != null) {
if (addTo == null) {
return name;
}
addTo.add(name);
}
}
}
} else {
if (identifier != null) {
if (identifierMatches(authority, identifier.getAuthority())) {
final String name = identifier.getCode();
if (name != null) {
if (addTo == null) {
return name;
}
addTo.add(name);
}
}
}
final Iterator<GenericName> it = iterator(object.getAlias());
if (it != null) while (it.hasNext()) {
final GenericName alias = it.next();
if (alias != null) {
if (alias instanceof Identifier) {
identifier = (Identifier) alias;
if (identifierMatches(authority, identifier.getAuthority())) {
final String name = identifier.getCode();
if (name != null) {
if (addTo == null) {
return name;
}
addTo.add(name);