Class OptionalShouldContain

  • All Implemented Interfaces:
    ErrorMessageFactory

    public class OptionalShouldContain
    extends BasicErrorMessageFactory
    Build error message when an Optional, OptionalDouble, OptionalInt or OptionalLong should contain a specific value.
    • Field Detail

      • EXPECTING_TO_CONTAIN

        private static final java.lang.String EXPECTING_TO_CONTAIN
        See Also:
        Constant Field Values
      • EXPECTING_TO_CONTAIN_SAME

        private static final java.lang.String EXPECTING_TO_CONTAIN_SAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • OptionalShouldContain

        private OptionalShouldContain​(java.lang.String message,
                                      java.lang.Object actual,
                                      java.lang.Object expected)
      • OptionalShouldContain

        private OptionalShouldContain​(java.lang.Object expected)
    • Method Detail

      • shouldContain

        public static <VALUE> OptionalShouldContain shouldContain​(java.util.Optional<VALUE> optional,
                                                                  VALUE expectedValue)
        Indicates that the provided Optional does not contain the provided argument.
        Type Parameters:
        VALUE - the type of the value contained in the Optional.
        Parameters:
        optional - the Optional which contains a value.
        expectedValue - the value we expect to be in the provided Optional.
        Returns:
        a error message factory
      • shouldContain

        public static OptionalShouldContain shouldContain​(java.util.OptionalDouble optional,
                                                          double expectedValue)
        Indicates that the provided OptionalDouble does not contain the provided argument.
        Parameters:
        optional - the OptionalDouble which contains a value.
        expectedValue - the value we expect to be in the provided OptionalDouble.
        Returns:
        a error message factory
      • shouldContain

        public static OptionalShouldContain shouldContain​(java.util.OptionalInt optional,
                                                          int expectedValue)
        Indicates that the provided OptionalInt does not contain the provided argument.
        Parameters:
        optional - the OptionalInt which contains a value.
        expectedValue - the value we expect to be in the provided OptionalInt.
        Returns:
        a error message factory
      • shouldContain

        public static OptionalShouldContain shouldContain​(java.util.OptionalLong optional,
                                                          long expectedValue)
        Indicates that the provided OptionalLong does not contain the provided argument.
        Parameters:
        optional - the OptionalLong which contains a value.
        expectedValue - the value we expect to be in the provided OptionalLong.
        Returns:
        a error message factory
      • shouldContainSame

        public static <VALUE> OptionalShouldContain shouldContainSame​(java.util.Optional<VALUE> optional,
                                                                      VALUE expectedValue)
        Indicates that the provided Optional does not contain the provided argument (judging by reference equality).
        Type Parameters:
        VALUE - the type of the value contained in the Optional.
        Parameters:
        optional - the Optional which contains a value.
        expectedValue - the value we expect to be in the provided Optional.
        Returns:
        a error message factory
      • shouldContain

        public static OptionalShouldContain shouldContain​(java.lang.Object expectedValue)
        Indicates that an Optional is empty so it doesn't contain the expected value.
        Parameters:
        expectedValue - the value we expect to be in an Optional.
        Returns:
        a error message factory.