Skip to content

Commit eb0426e

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Move truth-java8-extension classes into the main truth artifact.
While there, make some minor changes to prepare for moving the `Truth8` methods into `Truth`. This is the first step of #746. RELNOTES=Moved the `truth-java8-extension` classes into the main `truth` artifact. There is no longer any need to depend on `truth-java8-extension`, which is now empty. (We've also removed the `Truth8` [GWT](https://www.gwtproject.org/) module.) PiperOrigin-RevId: 597243015
1 parent e47ee27 commit eb0426e

File tree

16 files changed

+80
-47
lines changed

16 files changed

+80
-47
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2019 Google, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.common.truth;
18+
19+
import static java.lang.annotation.ElementType.CONSTRUCTOR;
20+
import static java.lang.annotation.ElementType.METHOD;
21+
import static java.lang.annotation.ElementType.TYPE;
22+
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* Disables Animal Sniffer's checking of compatibility with older versions of Java/Android.
27+
*/
28+
@Target({METHOD, CONSTRUCTOR, TYPE})
29+
@interface IgnoreJRERequirement {}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040
*
4141
* @author Kurt Alfred Kluever
4242
*/
43-
@SuppressWarnings("deprecation") // TODO(b/134064106): design an alternative to no-arg check()
43+
@SuppressWarnings({
44+
"deprecation", // TODO(b/134064106): design an alternative to no-arg check()
45+
"Java7ApiChecker", // used only from APIs with Java 8 in their signatures
46+
})
47+
@IgnoreJRERequirement
4448
public final class IntStreamSubject extends Subject {
4549

4650
private final List<?> actualList;
4751

48-
private IntStreamSubject(FailureMetadata failureMetadata, @Nullable IntStream stream) {
52+
IntStreamSubject(FailureMetadata failureMetadata, @Nullable IntStream stream) {
4953
super(failureMetadata, stream);
5054
this.actualList =
5155
(stream == null) ? null : stream.boxed().collect(toCollection(ArrayList::new));
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040
*
4141
* @author Kurt Alfred Kluever
4242
*/
43-
@SuppressWarnings("deprecation") // TODO(b/134064106): design an alternative to no-arg check()
43+
@SuppressWarnings({
44+
"deprecation", // TODO(b/134064106): design an alternative to no-arg check()
45+
"Java7ApiChecker", // used only from APIs with Java 8 in their signatures
46+
})
47+
@IgnoreJRERequirement
4448
public final class LongStreamSubject extends Subject {
4549

4650
private final List<?> actualList;
4751

48-
private LongStreamSubject(FailureMetadata failureMetadata, @Nullable LongStream stream) {
52+
LongStreamSubject(FailureMetadata failureMetadata, @Nullable LongStream stream) {
4953
super(failureMetadata, stream);
5054
this.actualList =
5155
(stream == null) ? null : stream.boxed().collect(toCollection(ArrayList::new));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*
2727
* @author Ben Douglass
2828
*/
29+
@SuppressWarnings("Java7ApiChecker") // used only from APIs with Java 8 in their signatures
30+
@IgnoreJRERequirement
2931
public final class OptionalDoubleSubject extends Subject {
3032

3133
private final OptionalDouble actual;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*
2727
* @author Ben Douglass
2828
*/
29+
@SuppressWarnings("Java7ApiChecker") // used only from APIs with Java 8 in their signatures
30+
@IgnoreJRERequirement
2931
public final class OptionalIntSubject extends Subject {
3032
private final OptionalInt actual;
3133

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*
2727
* @author Ben Douglass
2828
*/
29+
@SuppressWarnings("Java7ApiChecker") // used only from APIs with Java 8 in their signatures
30+
@IgnoreJRERequirement
2931
public final class OptionalLongSubject extends Subject {
3032
private final OptionalLong actual;
3133

extensions/java8/src/main/java/com/google/common/truth/OptionalSubject.java renamed to core/src/main/java/com/google/common/truth/OptionalSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*
2727
* @author Christian Gruber
2828
*/
29+
@SuppressWarnings("Java7ApiChecker") // used only from APIs with Java 8 in their signatures
30+
@IgnoreJRERequirement
2931
public final class OptionalSubject extends Subject {
3032
private final @Nullable Optional<?> actual;
3133

extensions/java8/src/main/java/com/google/common/truth/PathSubject.java renamed to core/src/main/java/com/google/common/truth/PathSubject.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
/** Assertions for {@link Path} instances. */
2323
@GwtIncompatible
2424
@J2ObjCIncompatible
25+
@J2ktIncompatible
2526
public final class PathSubject extends Subject {
26-
private PathSubject(FailureMetadata failureMetadata, Path actual) {
27+
PathSubject(FailureMetadata failureMetadata, Path actual) {
2728
super(failureMetadata, actual);
2829
}
2930

core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static com.google.common.base.Preconditions.checkNotNull;
1919

2020
import com.google.common.annotations.GwtIncompatible;
21-
import com.google.common.base.Optional;
2221
import com.google.common.collect.ImmutableList;
2322
import com.google.common.collect.Multimap;
2423
import com.google.common.collect.Multiset;
@@ -149,7 +148,7 @@ public final PrimitiveDoubleArraySubject that(double @Nullable [] actual) {
149148
return new PrimitiveDoubleArraySubject(metadata(), actual, "array");
150149
}
151150

152-
public final GuavaOptionalSubject that(@Nullable Optional<?> actual) {
151+
public final GuavaOptionalSubject that(com.google.common.base.@Nullable Optional<?> actual) {
153152
return new GuavaOptionalSubject(metadata(), actual, "optional");
154153
}
155154

extensions/java8/src/main/java/com/google/common/truth/StreamSubject.java renamed to core/src/main/java/com/google/common/truth/StreamSubject.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040
*
4141
* @author Kurt Alfred Kluever
4242
*/
43-
@SuppressWarnings("deprecation") // TODO(b/134064106): design an alternative to no-arg check()
43+
@SuppressWarnings({
44+
"deprecation", // TODO(b/134064106): design an alternative to no-arg check()
45+
"Java7ApiChecker", // used only from APIs with Java 8 in their signatures
46+
})
47+
@IgnoreJRERequirement
4448
public final class StreamSubject extends Subject {
4549

4650
private final List<?> actualList;
4751

48-
private StreamSubject(FailureMetadata failureMetadata, @Nullable Stream<?> stream) {
52+
StreamSubject(FailureMetadata failureMetadata, @Nullable Stream<?> stream) {
4953
super(failureMetadata, stream);
5054
this.actualList = (stream == null) ? null : stream.collect(toCollection(ArrayList::new));
5155
}

0 commit comments

Comments
 (0)