Enum Class ClassArrayFormat

java.lang.Object
java.lang.Enum<ClassArrayFormat>
org.apache.juneau.commons.reflect.ClassArrayFormat
All Implemented Interfaces:
Serializable, Comparable<ClassArrayFormat>, Constable

Defines how array types should be formatted when rendered as strings.

Controls the notation used to represent array dimensions in class names.

Example:

// Given class: String[][] ClassArrayFormat.JVM // "[[Ljava.lang.String;" ClassArrayFormat.BRACKETS // "String[][]" ClassArrayFormat.WORD // "StringArrayArray"

See Also:
  • Enum Constant Details

    • JVM

      public static final ClassArrayFormat JVM
      JVM bytecode notation - prefix with [ for each dimension.
      Examples:
      • "[Ljava.lang.String;" - String[]
      • "[[Ljava.lang.String;" - String[][]
      • "[I" - int[]
      • "[[I" - int[][]
      • "[Z" - boolean[]

      This is the format returned by Class.getName() for array types. It uses JVM internal type descriptors where object arrays are prefixed with [L and suffixed with ;, and primitive arrays use single-letter codes (I, Z, B, C, D, F, J, S).

      This format is primarily used for reflection and JVM internals.

    • BRACKETS

      public static final ClassArrayFormat BRACKETS
      Source code notation - suffix with [] for each dimension.
      Examples:
      • "String[]" - String[]
      • "String[][]" - String[][]
      • "int[]" - int[]
      • "int[][]" - int[][]
      • "boolean[]" - boolean[]

      This is the format used in Java source code and is the most human-readable. It's returned by Class.getSimpleName() and Class.getCanonicalName() for array types.

      This is the most common format for documentation and display purposes.

    • WORD

      public static final ClassArrayFormat WORD
      Word notation - suffix with "Array" for each dimension.
      Examples:
      • "StringArray" - String[]
      • "StringArrayArray" - String[][]
      • "intArray" - int[]
      • "intArrayArray" - int[][]
      • "booleanArray" - boolean[]

      This format is useful for generating variable names, method names, or other identifiers where special characters like [] are not allowed.

      This format is particularly useful in code generation scenarios where you need valid Java identifiers.

  • Method Details

    • values

      public static ClassArrayFormat[] 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 ClassArrayFormat 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