Class Utils

java.lang.Object
me.despical.commandframework.utils.Utils

@Internal public final class Utils extends Object
This class is a part of Despical's Commons library.

Created at 30.05.2020

Author:
Despical
  • Method Details

    • getInt

      public static int getInt(String string)
      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

      public static double getDouble(String string)
      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

      public static long getLong(String string)
      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

      public static float getFloat(String string)
      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

      public static <K, V> Map.Entry<K,V> mapEntry(K a, V b)
      Returns a Map.Entry containing 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.Entry containing the given key and value.
    • mapOf

      public static <K, V> Map<K,V> mapOf(K a, V b)
      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

      @SafeVarargs public static <K, V> Map<K,V> mapOf(Map.Entry<K,V>... a)
      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

      public static void handleExceptions(Exception exception)
    • createCommand

      public static Command createCommand(Command command, String commandName)