cleanup nameWithoutVersion() code

This commit is contained in:
Daniel Gultsch 2017-06-24 16:13:55 +02:00
parent 5fd4169720
commit d24022d755

View file

@ -130,21 +130,17 @@ public class Presences {
private static String nameWithoutVersion(String name) { private static String nameWithoutVersion(String name) {
String[] parts = name.split(" "); String[] parts = name.split(" ");
if (parts.length <= 1) { if (parts.length > 1 && Character.isDigit(parts[parts.length -1].charAt(0))) {
return name; StringBuilder output = new StringBuilder();
} else { for(int i = 0; i < parts.length -1; ++i) {
if (Character.isDigit(parts[parts.length -1].charAt(0))) { if (output.length() != 0) {
StringBuilder output = new StringBuilder(); output.append(' ');
for(int i = 0; i < parts.length -1; ++i) {
if (output.length() != 0) {
output.append(' ');
}
output.append(parts[i]);
} }
return output.toString(); output.append(parts[i]);
} else {
return name;
} }
return output.toString();
} else {
return name;
} }
} }
} }