diff --git a/core/src/main/java/com/google/common/truth/IntStreamSubject.java b/core/src/main/java/com/google/common/truth/IntStreamSubject.java index bf534342f..51600affa 100644 --- a/core/src/main/java/com/google/common/truth/IntStreamSubject.java +++ b/core/src/main/java/com/google/common/truth/IntStreamSubject.java @@ -61,6 +61,11 @@ protected String actualCustomStringRepresentation() { return String.valueOf(actualList); } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(intStreams()).that(stream)....}. Now, you can perform assertions + * like that without the {@code about(...)} call. + */ public static Factory intStreams() { return IntStreamSubject::new; } diff --git a/core/src/main/java/com/google/common/truth/LongStreamSubject.java b/core/src/main/java/com/google/common/truth/LongStreamSubject.java index 85cbbd148..ac21e5709 100644 --- a/core/src/main/java/com/google/common/truth/LongStreamSubject.java +++ b/core/src/main/java/com/google/common/truth/LongStreamSubject.java @@ -61,6 +61,11 @@ protected String actualCustomStringRepresentation() { return String.valueOf(actualList); } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(longStreams()).that(stream)....}. Now, you can perform assertions + * like that without the {@code about(...)} call. + */ public static Factory longStreams() { return LongStreamSubject::new; } diff --git a/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java b/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java index 207a03a35..12ed140a4 100644 --- a/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java @@ -81,6 +81,11 @@ public void hasValue(double expected) { } } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(optionalDoubles()).that(optional)....}. Now, you can perform + * assertions like that without the {@code about(...)} call. + */ public static Subject.Factory optionalDoubles() { return (metadata, subject) -> new OptionalDoubleSubject(metadata, subject, "optionalDouble"); } diff --git a/core/src/main/java/com/google/common/truth/OptionalIntSubject.java b/core/src/main/java/com/google/common/truth/OptionalIntSubject.java index 63b8285ca..031f7517a 100644 --- a/core/src/main/java/com/google/common/truth/OptionalIntSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalIntSubject.java @@ -74,6 +74,11 @@ public void hasValue(int expected) { } } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(optionalInts()).that(optional)....}. Now, you can perform + * assertions like that without the {@code about(...)} call. + */ public static Subject.Factory optionalInts() { return (metadata, subject) -> new OptionalIntSubject(metadata, subject, "optionalInt"); } diff --git a/core/src/main/java/com/google/common/truth/OptionalLongSubject.java b/core/src/main/java/com/google/common/truth/OptionalLongSubject.java index 0e5c6a848..fae20a276 100644 --- a/core/src/main/java/com/google/common/truth/OptionalLongSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalLongSubject.java @@ -74,6 +74,11 @@ public void hasValue(long expected) { } } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(optionalLongs()).that(optional)....}. Now, you can perform + * assertions like that without the {@code about(...)} call. + */ public static Subject.Factory optionalLongs() { return (metadata, subject) -> new OptionalLongSubject(metadata, subject, "optionalLong"); } diff --git a/core/src/main/java/com/google/common/truth/OptionalSubject.java b/core/src/main/java/com/google/common/truth/OptionalSubject.java index c99932976..090fa1658 100644 --- a/core/src/main/java/com/google/common/truth/OptionalSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalSubject.java @@ -84,6 +84,11 @@ public void hasValue(@Nullable Object expected) { } } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(paths()).that(path)....}. Now, you can perform assertions like + * that without the {@code about(...)} call. + */ public static Subject.Factory> optionals() { return (metadata, subject) -> new OptionalSubject(metadata, subject, "optional"); } diff --git a/core/src/main/java/com/google/common/truth/PathSubject.java b/core/src/main/java/com/google/common/truth/PathSubject.java index 51699bf3b..6c9cd3293 100644 --- a/core/src/main/java/com/google/common/truth/PathSubject.java +++ b/core/src/main/java/com/google/common/truth/PathSubject.java @@ -32,6 +32,11 @@ public final class PathSubject extends Subject { super(failureMetadata, actual); } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(intStreams()).that(stream)....}. Now, you can perform assertions + * like that without the {@code about(...)} call. + */ public static Subject.Factory paths() { return PathSubject::new; } diff --git a/core/src/main/java/com/google/common/truth/StreamSubject.java b/core/src/main/java/com/google/common/truth/StreamSubject.java index 0ecf042f7..8e5a96ec4 100644 --- a/core/src/main/java/com/google/common/truth/StreamSubject.java +++ b/core/src/main/java/com/google/common/truth/StreamSubject.java @@ -88,6 +88,11 @@ protected String actualCustomStringRepresentation() { return String.valueOf(asList); } + /** + * Obsolete factory instance. This factory was previously necessary for assertions like {@code + * assertWithMessage(...).about(streams()).that(stream)....}. Now, you can perform assertions like + * that without the {@code about(...)} call. + */ public static Subject.Factory> streams() { return StreamSubject::new; } diff --git a/core/src/main/java/com/google/common/truth/Truth8.java b/core/src/main/java/com/google/common/truth/Truth8.java index c34a97513..6c49dc34c 100644 --- a/core/src/main/java/com/google/common/truth/Truth8.java +++ b/core/src/main/java/com/google/common/truth/Truth8.java @@ -30,19 +30,12 @@ import org.checkerframework.checker.nullness.qual.Nullable; /** - * The primary entry point for assertions about Java 8 types. + * The obsolete entry point for assertions about Java 8 types. * - *

To use {@link Truth#assertWithMessage} with a Java 8 type, use {@code - * assertWithMessage(...).about(}{@link OptionalSubject#optionals optionals()}{@code ).that(...)} - * (or similarly for the other types). - * - *

Likewise, to use different failure strategies like {@link Expect}, use {@code - * expect.about(}{@link OptionalSubject#optionals optionals()}{@code ).that(...)}. - * - *

For more information about combining different messages, failure strategies, and subjects, see - * How do I specify a custom message/failure - * behavior/{@code Subject} type? in the Truth FAQ. + * @deprecated Instead of this class's methods, use the identical methods declared in the main + * {@link Truth} class. */ +@Deprecated // The methods here are no more dangerous that wherever the user got the (e.g.) Stream. @SuppressWarnings("Java7ApiChecker") public final class Truth8 { @@ -75,10 +68,6 @@ public static LongStreamSubject assertThat(@Nullable LongStream target) { return assertAbout(LongStreamSubject.longStreams()).that(target); } - // TODO(b/64757353): Add support for DoubleStream? - - // Not actually a Java 8 feature, but for now this is the best option since core Truth still has - // to support Java environments without java.nio.file such as Android and J2CL. @GwtIncompatible @J2ObjCIncompatible @J2ktIncompatible