mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 16:34:56 +01:00
Merge branch 'main' into dev-scene
This commit is contained in:
@@ -79,6 +79,15 @@ public final class Utils {
|
||||
return v7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string with the path to a file.
|
||||
* @param path The path to the file.
|
||||
* @return A path using the operating system's file separator.
|
||||
*/
|
||||
public static String toFilePath(String path) {
|
||||
return path.replace("/", File.separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a file exists on the file system.
|
||||
* @param path The path to the file.
|
||||
@@ -118,6 +127,16 @@ public final class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object with null fallback.
|
||||
* @param nonNull The object to return if not null.
|
||||
* @param fallback The object to return if null.
|
||||
* @return One of the two provided objects.
|
||||
*/
|
||||
public static <T> T requireNonNullElseGet(T nonNull, T fallback) {
|
||||
return nonNull != null ? nonNull : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for required files and folders before startup.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user