-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #920 from PBH-BTN/master
v7.3.3
- Loading branch information
Showing
55 changed files
with
1,138 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/java/com/ghostchu/peerbanhelper/ExternalSwitch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.ghostchu.peerbanhelper; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Locale; | ||
|
||
public class ExternalSwitch { | ||
public static String parse(String args, @Nullable String def) { | ||
var value = System.getProperty(args); | ||
if (value == null) | ||
value = System.getenv(args.replace(".", "_").replace("-", "_").toUpperCase(Locale.ROOT)); | ||
if (value == null) | ||
return def; | ||
return value; | ||
} | ||
|
||
public static boolean parseBoolean(String args, boolean def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Boolean.parseBoolean(value); | ||
} | ||
|
||
public static int parseInt(String args, int def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Integer.parseInt(value); | ||
} | ||
|
||
public static long parseLong(String args, long def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Long.parseLong(value); | ||
} | ||
|
||
public static double parseDouble(String args, double def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Double.parseDouble(value); | ||
} | ||
|
||
public static float parseFloat(String args, float def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Float.parseFloat(value); | ||
} | ||
|
||
public static short parseShort(String args, short def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Short.parseShort(value); | ||
} | ||
|
||
public static byte parseByte(String args, byte def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return Byte.parseByte(value); | ||
} | ||
|
||
public static char parseChar(String args, char def) { | ||
var value = parse(args, null); | ||
if (value == null) | ||
return def; | ||
return value.charAt(0); | ||
} | ||
|
||
public static String parse(String args) { | ||
return parse(args, null); | ||
} | ||
|
||
public static boolean parseBoolean(String args) { | ||
return parseBoolean(args, false); | ||
} | ||
|
||
public static int parseInt(String args) { | ||
return parseInt(args, 0); | ||
} | ||
|
||
public static long parseLong(String args) { | ||
return parseLong(args, 0); | ||
} | ||
|
||
public static double parseDouble(String args) { | ||
return parseDouble(args, 0); | ||
} | ||
|
||
public static float parseFloat(String args) { | ||
return parseFloat(args, 0); | ||
} | ||
|
||
public static short parseShort(String args) { | ||
return parseShort(args, (short) 0); | ||
} | ||
|
||
public static byte parseByte(String args) { | ||
return parseByte(args, (byte) 0); | ||
} | ||
|
||
public static char parseChar(String args) { | ||
return parseChar(args, '\u0000'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.