Class ObjectUtils

java.lang.Object
panda.utilities.ObjectUtils

public final class ObjectUtils extends Object
  • Method Details

    • cast

      @Nullable public static <T> T cast(Class<T> clazz, @Nullable @Nullable Object object)
      Try to cast or get null
      Type Parameters:
      T - the result type
      Parameters:
      object - the object to cast
      clazz - the type to cast
      Returns:
      casted object or null if object is not a clazz type
    • cast

      @Nullable public static <T> T cast(Object object)
    • isNotNull

      public static boolean isNotNull(@Nullable @Nullable Object object)
      Check if object is not null
      Parameters:
      object - object to check
      Returns:
      true if object is not null
    • areNull

      public static boolean areNull(Object... objects)
      Check if all values are null
      Parameters:
      objects - array to check
      Returns:
      true if all values are null and false for non null element/empty array
    • equalsOneOf

      public static boolean equalsOneOf(Object value, Object... expected)
      Check if the value is one of the expected
      Parameters:
      value - value to check
      expected - expected values
      Returns:
      true if expected values contains the specified value
    • equals

      public static <T, C> boolean equals(T object, C value, Object to, Function<T,C> getter)
      Compare only one value that belongs to class and determines equality
      Type Parameters:
      T - type of current object
      C - type of compared values
      Parameters:
      object - the current object (~ this)
      value - the value of current object
      to - the object to compare with
      getter - the getter to obtain value from compared object
      Returns:
      true if compared objects are equal
    • equals

      public static <T> boolean equals(T object, Object to, BiPredicate<T,T> equals)
      Compare objects without boilerplate initial statements like (object == this) and (getClass() != to.getClass())
      Type Parameters:
      T - type of objects to compare
      Parameters:
      object - the current object (this)
      to - the object to compare with
      equals - the predicate which determines equality
      Returns:
      true if objects are the same type and fulfils the predicate