java.lang.Object
de.team33.patterns.proving.kerberos.Guard

public final class Guard extends Object
  • Method Details

    • prove

      public static void prove(boolean condition)
      Proves that the given condition is true. Otherwise, throws an IllegalStateException with a default message.
    • prove

      public static void prove(boolean condition, Supplier<String> toMessage)
      Proves that the given condition is true. Otherwise, throws an IllegalStateException with a message supplied by toMessage.
    • prove

      public static <E extends Exception> void prove(boolean condition, Supplier<String> toMessage, Function<? super String,E> toException) throws E
      Proves that the given condition is true. Otherwise, throws an exception provided by toException with a message supplied by toMessage.
      Throws:
      E extends Exception
    • proved

      public static <T> T proved(T candidate, Predicate<? super T> condition)
      Returns a given candidate if it meets the given condition. Otherwise, throws an exception with a default message.
      Type Parameters:
      T - The type of candidate.
      Throws:
      IllegalArgumentException - if the candidate does not meet the condition.
    • proved

      public static <T> T proved(T candidate, Predicate<? super T> condition, Function<? super T,String> toMessage)
      Returns a given candidate if it meets the given condition. Otherwise, throws an exception with a message supplied by toMessage.
      Type Parameters:
      T - The type of candidate.
      Throws:
      IllegalArgumentException - if the candidate does not meet the condition.
    • proved

      public static <T, E extends Exception> T proved(T candidate, Predicate<? super T> condition, Function<? super T,String> toMessage, Function<? super String,E> toException) throws E
      Returns a given candidate if it meets the given condition. Otherwise, throws an exception provided by toException with a message supplied by toMessage.
      Type Parameters:
      T - The type of candidate.
      E - The type of exception.
      Throws:
      E - if the candidate does not meet the condition.
    • nonNull

      public static <T> T nonNull(T candidate)
      Returns a given candidate if it is not null. Otherwise, throws an exception with a default message.
      Type Parameters:
      T - The type of candidate.
      Throws:
      NullPointerException - if the candidate is null.
    • nonNull

      public static <T> T nonNull(T candidate, Function<? super T,String> toMessage)
      Returns a given candidate if it is not null. Otherwise, throws an exception with a message supplied by toMessage.
      Type Parameters:
      T - The type of candidate.
      Throws:
      NullPointerException - if the candidate is null.