Cleanup: use Java17 switch statements.

AndroidStudio code cleanup.
This commit is contained in:
Dennis Guse
2023-04-13 14:52:20 +02:00
parent 3a8e547e10
commit efddb31391
30 changed files with 355 additions and 640 deletions
@@ -29,6 +29,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import de.dennisguse.opentracks.BuildConfig;
import de.dennisguse.opentracks.data.models.Track;
@@ -162,34 +163,8 @@ public class FileUtils {
* @param character the character
*/
private static boolean isSpecialFat32(char character) {
switch (character) {
case '$':
case '%':
case '\'':
case '-':
case '_':
case '@':
case '~':
case '`':
case '!':
case '(':
case ')':
case '{':
case '}':
case '^':
case '#':
case '&':
case '+':
case ',':
case ';':
case '=':
case '[':
case ']':
case ' ':
return true;
default:
return false;
}
return List.of('$', '%', '\'', '-', '_', '@', '~', '`', '!', '(', ')', '{', '}', '^', '#', '&', '+', ',', ';', '=', '[', ']', ' ')
.contains(character);
}
/**
@@ -40,11 +40,9 @@ public class TrackIconUtils {
it -> it.getId().equals(activityTypeId)
).findFirst();
if (found.isEmpty()) {
return ActivityType.UNKNOWN.getIconId();
}
return found.map(ActivityType::getIconId)
.orElseGet(ActivityType.UNKNOWN::getIconId);
return found.get().getIconId();
}
public static int getIconActivityType(String activityTypeId) {
@@ -52,11 +50,9 @@ public class TrackIconUtils {
it -> it.getId().equals(activityTypeId)
).findFirst();
if (found.isEmpty()) {
return ActivityType.UNKNOWN.getFirstLocalizedStringId();
}
return found.map(ActivityType::getFirstLocalizedStringId)
.orElseGet(ActivityType.UNKNOWN::getFirstLocalizedStringId);
return found.get().getFirstLocalizedStringId();
}
/**
@@ -96,10 +92,8 @@ public class TrackIconUtils {
)
.findFirst();
if (selected.isEmpty()) {
return false;
}
return selected.map(ActivityType::isShowSpeedPreferred)
.orElse(false);
return selected.get().isShowSpeedPreferred();
}
}