Class Utils
java.lang.Object
me.despical.commandframework.utils.Utils
This class is a part of Despical's Commons library.
Created at 30.05.2020
- Author:
- Despical
-
Method Summary
Modifier and TypeMethodDescriptionstatic CommandcreateCommand(Command command, String commandName) static doubleConvert a String to a double, returning zero if the conversion fails.static floatConvert a String to a float, returning zero if the conversion fails.static intConvert a String to an int, returning zero if the conversion fails.static longConvert a String to a long, returning zero if the conversion fails.static voidhandleExceptions(Exception exception) static <K,V> Map.Entry <K, V> mapEntry(K a, V b) Returns aMap.Entrycontaining the given key and value.static <K,V> Map <K, V> Returns a mutable map containing an arbitrary number of elements.static <K,V> Map <K, V> mapOf(K a, V b) Returns an mutable map containing one element.
-
Method Details
-
getInt
Convert a String to an int, returning zero if the conversion fails. If the string is null, zero is returned.- Parameters:
string- the string to convert, may be null- Returns:
- the int represented by the string, or zero if conversion fails
-
getDouble
Convert a String to a double, returning zero if the conversion fails. If the string is null, zero is returned.- Parameters:
string- the string to convert, may be null- Returns:
- the double represented by the string, or zero if conversion fails
-
getLong
Convert a String to a long, returning zero if the conversion fails. If the string is null, zero is returned.- Parameters:
string- the string to convert, may be null- Returns:
- the long represented by the string, or zero if conversion fails
-
getFloat
Convert a String to a float, returning zero if the conversion fails. If the string is null, zero is returned.- Parameters:
string- the string to convert, may be null- Returns:
- the float represented by the string, or zero if conversion fails
-
mapEntry
Returns aMap.Entrycontaining the given key and value.- Type Parameters:
K- new key type to be stored in this entry.V- new value type to be stored in this entry.- Parameters:
a- new key to be stored in this entry.b- new value to be stored in this entry.- Returns:
- new
Map.Entrycontaining the given key and value.
-
mapOf
Returns an mutable map containing one element.- Type Parameters:
K- key type to be stored in this map.V- value type to be stored in this map.- Parameters:
a- key to be stored in this map.b- value to be stored in this map.- Returns:
- Returns an mutable map containing one element.
-
mapOf
Returns a mutable map containing an arbitrary number of elements.- Type Parameters:
K- key type to be stored in this map.V- value type to be stored in this map.- Parameters:
a- Array of given entries to be stored in this map.- Returns:
- Returns a mutable map containing an arbitrary number of elements.
-
handleExceptions
-
createCommand
-