Class PrintUtils

java.lang.Object
com.github.ushiosan23.jvm.io.PrintUtils

public final class PrintUtils extends Object
  • Method Details

    • isToStringOverwritten

      public static boolean isToStringOverwritten(@NotNull @NotNull Object obj)
      Checks if the object has the default "toString" method.

      Note: This method is quite slow when parsing many objects, so it is recommended to use it only in necessary places.

      Parameters:
      obj - The object to analyze
      Returns:
      Returns true if the object has a Object.toString() method of its own, or false if it has the default behavior.
    • toString

      @Contract(pure=true) @NotNull public static @NotNull String toString(@Nullable @Nullable Object obj, boolean verbose)
      Manages the printing process of an object. This in order to have an informative and clean way of displaying objects and avoid the default method that can be confusing when debugging.
      Parameters:
      obj - The object to analyze
      verbose - Determines whether the printer should be wide or short
      Returns:
      Returns the representation of the object in text
    • toString

      @Contract(pure=true) @NotNull public static @NotNull String toString(@Nullable @Nullable Object obj)
      Manages the printing process of an object. This in order to have an informative and clean way of displaying objects and avoid the default method that can be confusing when debugging.
      Parameters:
      obj - The object to analyze
      Returns:
      Returns the representation of the object in text
    • toClassString

      @NotNull public static @NotNull String toClassString(@NotNull @NotNull Class<?> cls, boolean verbose)
      Class object string representation
      Parameters:
      cls - The class to convert
      verbose - Determines if the result is going to be verbose or simple
      Returns:
      Returns the object string representation
    • toCollectionString

      @NotNull public static @NotNull String toCollectionString(@NotNull @NotNull Collection<?> obj, boolean verbose, @NotNull @NotNull PrintUtils.CollectionType type, boolean verboseItems)
      Collection object string representation. Method used for any object that implements the Collection interface commonly used for any collection of objects.
      Parameters:
      obj - The collection to convert
      verbose - Determines if the result is going to be verbose or simple
      type - The type of collection to generate.
      verboseItems - Property that determines whether each object in the collection will be presented verbose or simply.
      Returns:
      Returns the object string representation
    • toCollectionString

      @NotNull public static @NotNull String toCollectionString(Collection<?> obj, boolean verbose)
      Collection object string representation. Method used for any object that implements the Collection interface commonly used for any collection of objects.
      Parameters:
      obj - The collection to convert
      verbose - Determines if the result is going to be verbose or simple
      Returns:
      Returns the object string representation
    • toMapString

      @NotNull public static @NotNull String toMapString(@NotNull @NotNull Map<?,?> obj, boolean verbose)
      Map object string representation.
      Parameters:
      obj - The map to convert
      verbose - Determines if the result is going to be verbose or simple
      Returns:
      Returns the object string representation
    • toEntryString

      @NotNull public static @NotNull String toEntryString(@NotNull Map.Entry<?,?> obj, boolean verbose)
      Map.Entry object string representation.
      Parameters:
      obj - The entry to convert
      verbose - Determines if the result is going to be verbose or simple
      Returns:
      Returns the object string representation
    • toRawString

      @NotNull public static @NotNull String toRawString(@NotNull @NotNull Object obj, boolean verbose)
      Any object string representation.
      Parameters:
      obj - The object to convert
      verbose - Determines if the result is going to be verbose or simple
      Returns:
      Returns the object string representation