Skip to content

Commit e51483d

Browse files
committed
OS is now never nullable, will always at least return UNKNOWN
1 parent 143227e commit e51483d

File tree

1 file changed

+7
-14
lines changed
  • json-data-utils/src/main/java/net/minecraftforge/util/data

1 file changed

+7
-14
lines changed

json-data-utils/src/main/java/net/minecraftforge/util/data/OS.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,39 @@ public enum OS {
3434
/** The operating system that this tool is being run on. */
3535
public static final OS CURRENT = getCurrent();
3636

37-
private final String key;
37+
/** The primary name, and enum key, of the operating system. */
38+
public final String key;
3839
private final String[] names;
3940

4041
OS(String... names) {
4142
this.key = names[0];
4243
this.names = names;
4344
}
4445

45-
/**
46-
* The primary name, and enum key, of the operating system.
47-
*
48-
* @return The primary name
49-
*/
50-
public String key() {
51-
return this.key;
52-
}
53-
5446
/**
5547
* Returns the OS enum for the given key.
5648
*
5749
* @param key The key to search for
5850
* @return The OS enum, or null if not found
5951
*/
60-
public static @Nullable OS byKey(String key) {
52+
public static OS byKey(@Nullable String key) {
6153
for (OS value : $values) {
6254
if (value.key.equals(key))
6355
return value;
6456
}
6557

66-
return null;
58+
return UNKNOWN;
6759
}
6860

69-
public static @Nullable OS byName(String name) {
61+
public static OS byName(@Nullable String name) {
7062
for (OS value : $values) {
7163
for (String n : value.names) {
7264
if (n.equals(name))
7365
return value;
7466
}
7567
}
7668

77-
return null;
69+
return UNKNOWN;
7870
}
7971

8072
/**
@@ -95,6 +87,7 @@ private static OS getCurrent() {
9587
return os == LINUX ? getCurrentLinux() : os;
9688
}
9789
}
90+
9891
return UNKNOWN;
9992
}
10093

0 commit comments

Comments
 (0)