Class OWLAPIPreconditions

java.lang.Object
org.semanticweb.owlapi.util.OWLAPIPreconditions

public final class OWLAPIPreconditions extends Object
A set of personalized preconditions.
  • Method Details

    • verifyNotNull

      public static <T> T verifyNotNull(@Nullable T object)
      Check that the argument is not null; if the argument is null, throw an IllegalStateException. This method is meant to be used to verify conditions on member variables rather than input parameters.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      Returns:
      the input reference if not null
      Throws:
      IllegalStateException - if object is null
    • verifyNotNull

      public static <T> T verifyNotNull(@Nullable T object, String message)
      Check that the argument is not null; if the argument is null, throw an IllegalStateException. This method is meant to be used to verify conditions on member variables rather than input parameters.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      message - message to use for the error
      Returns:
      the input reference if not null
      Throws:
      IllegalStateException - if object is null
    • verifyNotNull

      public static <T> T verifyNotNull(@Nullable T object, Supplier<String> message)
      Check that the argument is not null; if the argument is null, throw an IllegalStateException. This method is meant to be used to verify conditions on member variables rather than input parameters.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      message - message to use for the error
      Returns:
      the input reference if not null
      Throws:
      IllegalStateException - if object is null
    • checkNotNull

      public static <T> T checkNotNull(@Nullable T object)
      Check for null and throw NullPointerException if null.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      Returns:
      the input reference if not null
      Throws:
      NullPointerException - if object is null
    • checkNotNull

      public static <T> T checkNotNull(@Nullable T object, String message)
      Check for null and throw NullPointerException if null.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      message - message for the illegal argument exception
      Returns:
      the input reference if not null
      Throws:
      NullPointerException - if object is null
    • checkValidForNAryExpressions

      public static <Q, T extends Collection<Q>> T checkValidForNAryExpressions(@Nullable T object, String message)
      Check for null or empty and throw NullPointerException if null or empty.
      Type Parameters:
      T - collection type
      Q - reference type
      Parameters:
      object - reference to check
      message - message for the illegal argument exception
      Returns:
      the input reference if not null
      Throws:
      NullPointerException - if object is null
    • checkNotNull

      public static <T> T checkNotNull(@Nullable T object, Supplier<String> message)
      Check for null and throw NullPointerException if null.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      message - message for the illegal argument exception
      Returns:
      the input reference if not null
      Throws:
      NullPointerException - if object is null
    • checkNotNegative

      public static void checkNotNegative(@Nonnegative long object)
      Check for negative value and throw IllegalArgumentException if negative.
      Parameters:
      object - value to check
      Throws:
      IllegalArgumentException - if object is negative
    • checkNotNegative

      public static void checkNotNegative(@Nonnegative long object, String message)
      Check for negative value and throw IllegalArgumentException if negative.
      Parameters:
      object - value to check
      message - message for the illegal argument exception
      Throws:
      IllegalArgumentException - if object is negative
    • checkNotNegative

      public static void checkNotNegative(@Nonnegative long object, Supplier<String> message)
      Check for negative value and throw IllegalArgumentException if negative.
      Parameters:
      object - value to check
      message - message for the illegal argument exception
      Throws:
      IllegalArgumentException - if object is negative
    • checkNotNull

      @Deprecated public static <T> T checkNotNull(@Nullable Optional<T> object, String message)
      Check for absent and throw IllegalArgumentException if null or absent.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      message - message for the illegal argument exception
      Returns:
      the input reference if not null
      Throws:
      IllegalArgumentException - if object is null
    • checkNotNull

      public static <T> T checkNotNull(@Nullable Optional<T> object, Supplier<String> message)
      Check for absent and throw IllegalArgumentException if null or absent.
      Type Parameters:
      T - reference type
      Parameters:
      object - reference to check
      message - message for the illegal argument exception
      Returns:
      the input reference if not null
      Throws:
      IllegalArgumentException - if object is null
    • checkIterableNotNull

      public static void checkIterableNotNull(@Nullable Collection<?> o, String name, boolean emptyAllowed)
      Parameters:
      o - collection to check for nullness and null elements, and optionally for emptiness
      name - message for error
      emptyAllowed - true if the input can be empty
    • checkIterableNotNull

      public static void checkIterableNotNull(Object[] o, String name, boolean emptyAllowed)
      Parameters:
      o - array to check for nullness and null elements, and optionally for emptiness
      name - message for error
      emptyAllowed - true if the input can be empty
    • emptyOptional

      public static <T> Optional<T> emptyOptional()
      Wrapper to allow non null annotations.
      Type Parameters:
      T - type
      Returns:
      empty optional instance
    • emptyOptional

      public static <T> Optional<T> emptyOptional(Class<T> t)
      Wrapper to allow non null annotations.
      Type Parameters:
      T - type
      Parameters:
      t - type for the returned optional
      Returns:
      empty optional instance
    • optional

      public static <T> Optional<T> optional(@Nullable T t)
      Wrapper to allow non null annotations.
      Type Parameters:
      T - type
      Parameters:
      t - instance to wrap. Can be null (the result will be Optional.empty())
      Returns:
      optional instance (content can be absent)