Class OptionalAssertions

    • Method Detail

      • assertIsPresent

        public static <T> T assertIsPresent​(Optional<T> optional)
        Asserts that the supplied optional is not empty.
        Type Parameters:
        T - The optional value type.
        Parameters:
        optional - The optional to check.
        Returns:
        The optional's value.
      • assertIsPresent

        public static <T> T assertIsPresent​(Optional<T> optional,
                                            String message)
        Asserts that the supplied optional is not empty.
        Type Parameters:
        T - The optional value type.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static <T> T assertIsPresent​(Optional<T> optional,
                                            Supplier<String> messageSupplier)
        Asserts that the supplied optional is not empty.
        Type Parameters:
        T - The optional value type.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static int assertIsPresent​(OptionalInt optional)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        Returns:
        The optional's value.
      • assertIsPresent

        public static int assertIsPresent​(OptionalInt optional,
                                          String message)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static int assertIsPresent​(OptionalInt optional,
                                          Supplier<String> messageSupplier)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static long assertIsPresent​(OptionalLong optional)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        Returns:
        The optional's value.
      • assertIsPresent

        public static long assertIsPresent​(OptionalLong optional,
                                           String message)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static long assertIsPresent​(OptionalLong optional,
                                           Supplier<String> messageSupplier)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static double assertIsPresent​(OptionalDouble optional)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        Returns:
        The optional's value.
      • assertIsPresent

        public static double assertIsPresent​(OptionalDouble optional,
                                             String message)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
        Returns:
        The optional's value.
      • assertIsPresent

        public static double assertIsPresent​(OptionalDouble optional,
                                             Supplier<String> messageSupplier)
        Asserts that the supplied optional is not empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
        Returns:
        The optional's value.
      • assertIsEmpty

        public static void assertIsEmpty​(Optional<?> optional)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
      • assertIsEmpty

        public static void assertIsEmpty​(Optional<?> optional,
                                         String message)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(Optional<?> optional,
                                         Supplier<String> messageSupplier)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalInt optional)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalInt optional,
                                         String message)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalInt optional,
                                         Supplier<String> messageSupplier)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalLong optional)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalLong optional,
                                         String message)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalLong optional,
                                         Supplier<String> messageSupplier)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalDouble optional)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalDouble optional,
                                         String message)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        message - The failure message to fail with.
      • assertIsEmpty

        public static void assertIsEmpty​(OptionalDouble optional,
                                         Supplier<String> messageSupplier)
        Asserts that the supplied optional is empty.
        Parameters:
        optional - The optional to check.
        messageSupplier - The supplier for the failure message to fail with.