Class ChecksBase<T,C extends ChecksBase<T,C>>

java.lang.Object
dev.prozilla.pine.common.util.checks.ChecksBase<T,C>
Direct Known Subclasses:
ArrayChecks, CollectionChecks, ObjectChecks, StringChecks

public abstract class ChecksBase<T,C extends ChecksBase<T,C>> extends Object
Utility class for chaining checks using functional programming on a named value and throwing a descriptive error if one of the checks is not met.
  • Field Details

    • value

      protected final T value
    • name

      protected String name
  • Constructor Details

    • ChecksBase

      public ChecksBase(T value, String name)
  • Method Details

    • named

      public final C named(String name)
    • get

      public final T get()
    • asString

      public final C asString(Consumer<StringChecks> stringChecks)
      Performs checks on the value as a string.
      Parameters:
      stringChecks - The checks to perform
    • isEqualTo

      public final C isEqualTo(Object other) throws InvalidObjectException
      Checks that the value is equal to a given object.
      Parameters:
      other - The object
      Throws:
      InvalidObjectException - If the value is not equal to the object
    • isNotEqualTo

      public final C isNotEqualTo(Object other) throws InvalidObjectException
      Checks that the value is not equal to a given object.
      Parameters:
      other - The object
      Throws:
      InvalidObjectException - If the value is equal to the object
    • isNotNull

      public final C isNotNull() throws InvalidObjectException
      Checks that the value is not null.
      Throws:
      InvalidObjectException - If the value is null.
    • self

      protected abstract C self()
    • getDefaultName

      protected abstract String getDefaultName()