Enum Class Radix

java.lang.Object
java.lang.Enum<Radix>
net.luis.utils.math.Radix
All Implemented Interfaces:
Serializable, Comparable<Radix>, Constable

public enum Radix extends Enum<Radix>
Represents a radix for number conversion.
The radix is the base of a number system.
This class represents the most common radices used in computer science:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Represents the binary radix (base 2) with the prefix 0b.
    Represents the decimal radix (base 10) with no prefix.
    Represents the hexadecimal radix (base 16) with the prefix 0x.
    Represents the octal radix (base 8) with the prefix 0.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The prefix for the radix used in string conversion.
    private final int
    The radix value.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Radix(int radix, @NotNull String prefix)
    Constructs a new radix with the given radix value and prefix.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String
    Returns the prefix for the radix used in string conversion.
    int
    Returns the radix value.
     
    static Radix
    Returns the enum constant of this class with the specified name.
    static Radix[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • BINARY

      public static final Radix BINARY
      Represents the binary radix (base 2) with the prefix 0b.
    • OCTAL

      public static final Radix OCTAL
      Represents the octal radix (base 8) with the prefix 0.
    • DECIMAL

      public static final Radix DECIMAL
      Represents the decimal radix (base 10) with no prefix.
    • HEXADECIMAL

      public static final Radix HEXADECIMAL
      Represents the hexadecimal radix (base 16) with the prefix 0x.
  • Field Details

    • radix

      private final int radix
      The radix value.
    • prefix

      private final String prefix
      The prefix for the radix used in string conversion.
  • Constructor Details

    • Radix

      private Radix(int radix, @NotNull @NotNull String prefix)
      Constructs a new radix with the given radix value and prefix.
      Parameters:
      radix - The radix value
      prefix - The prefix for the radix
      Throws:
      IllegalArgumentException - If the radix is less than or equal to 0
      NullPointerException - If the prefix is null
  • Method Details

    • values

      public static Radix[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Radix valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getRadix

      public int getRadix()
      Returns the radix value.
      Returns:
      The radix value
    • getPrefix

      @NotNull public @NotNull String getPrefix()
      Returns the prefix for the radix used in string conversion.
      Returns:
      The prefix for the radix
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Radix>