Class StandardSubjectBuilder

  • Direct Known Subclasses:
    Expect

    public class StandardSubjectBuilder
    extends java.lang.Object
    In a fluent assertion chain, an object with which you can do any of the following:

    For more information about the methods in this class, see this FAQ entry.

    For people extending Truth

    You won't extend this type. When you write a custom subject, see our doc on extensions.

    • Method Detail

      • forCustomFailureStrategy

        public static StandardSubjectBuilder forCustomFailureStrategy​(FailureStrategy failureStrategy)
        Returns a new instance that invokes the given FailureStrategy when a check fails. Most users should not need this. If you think you do, see the documentation on FailureStrategy.
      • that

        public final <ComparableT extends java.lang.Comparable<?>> ComparableSubject<ComparableT> that​(@Nullable ComparableT actual)
      • that

        public final BigDecimalSubject that​(@Nullable java.math.BigDecimal actual)
      • that

        public final Subject that​(@Nullable java.lang.Object actual)
      • that

        public final ThrowableSubject that​(@Nullable java.lang.Throwable actual)
      • that

        public final LongSubject that​(@Nullable java.lang.Long actual)
      • that

        public final DoubleSubject that​(@Nullable java.lang.Double actual)
      • that

        public final FloatSubject that​(@Nullable java.lang.Float actual)
      • that

        public final IntegerSubject that​(@Nullable java.lang.Integer actual)
      • that

        public final BooleanSubject that​(@Nullable java.lang.Boolean actual)
      • that

        public final StringSubject that​(@Nullable java.lang.String actual)
      • that

        public final IterableSubject that​(@Nullable java.lang.Iterable<?> actual)
      • that

        public final <T extends @Nullable java.lang.Object> ObjectArraySubject<T> that​(T @Nullable [] actual)
      • that

        public final MapSubject that​(@Nullable java.util.Map<?,​?> actual)
      • that

        public final OptionalSubject that​(@Nullable java.util.Optional<?> actual)
        Since:
        1.3.0 (with access to OptionalSubject previously part of truth-java8-extension)
      • that

        public final StreamSubject that​(@Nullable java.util.stream.Stream<?> actual)
        Since:
        1.3.0 (with access to StreamSubject previously part of truth-java8-extension)
      • that

        public final IntStreamSubject that​(@Nullable java.util.stream.IntStream actual)
        Since:
        1.4.0 (with access to IntStreamSubject previously part of truth-java8-extension)
      • that

        public final LongStreamSubject that​(@Nullable java.util.stream.LongStream actual)
        Since:
        1.4.0 (with access to LongStreamSubject previously part of truth-java8-extension)
      • that

        @GwtIncompatible
        @J2ObjCIncompatible
        public final PathSubject that​(@Nullable java.nio.file.Path actual)
        Since:
        1.4.0 (with access to PathSubject previously part of truth-java8-extension)
      • withMessage

        public final StandardSubjectBuilder withMessage​(@Nullable java.lang.String messageToPrepend)
        Returns a new instance that will output the given message before the main failure message. If this method is called multiple times, the messages will appear in the order that they were specified.
      • withMessage

        public final StandardSubjectBuilder withMessage​(java.lang.String format,
                                                        @Nullable java.lang.Object... args)
        Returns a new instance that will output the given message before the main failure message. If this method is called multiple times, the messages will appear in the order that they were specified.

        Note: the arguments will be substituted into the format template using Strings.lenientFormat. Note this only supports the %s specifier.

        Throws:
        java.lang.IllegalArgumentException - if the number of placeholders in the format string does not equal the number of given arguments
      • about

        public final <S extends Subject,​A> SimpleSubjectBuilder<S,​A> about​(Subject.Factory<S,​A> factory)
        Given a factory for some Subject class, returns a builder whose that(actual) method creates instances of that class. Created subjects use the previously set failure strategy and any previously set failure message.