Skip to content

Commit 828d9ee

Browse files
netdpbGoogle Java Core Libraries
authored andcommitted
Remove @Beta from APIs in Files. Add @InlineMe where we can.
Fixes google#3285. RELNOTES=`io`: Remove `@Beta` from APIs in `Files`. PiperOrigin-RevId: 420062384
1 parent 2331170 commit 828d9ee

File tree

4 files changed

+64
-86
lines changed

4 files changed

+64
-86
lines changed

android/guava/src/com/google/common/io/Files.java

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.common.hash.HashCode;
3333
import com.google.common.hash.HashFunction;
3434
import com.google.errorprone.annotations.CanIgnoreReturnValue;
35+
import com.google.errorprone.annotations.InlineMe;
3536
import java.io.BufferedReader;
3637
import java.io.BufferedWriter;
3738
import java.io.File;
@@ -85,7 +86,6 @@ private Files() {}
8586
* helpful predefined constants
8687
* @return the buffered reader
8788
*/
88-
@Beta
8989
public static BufferedReader newReader(File file, Charset charset) throws FileNotFoundException {
9090
checkNotNull(file);
9191
checkNotNull(charset);
@@ -104,7 +104,6 @@ public static BufferedReader newReader(File file, Charset charset) throws FileNo
104104
* helpful predefined constants
105105
* @return the buffered writer
106106
*/
107-
@Beta
108107
public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException {
109108
checkNotNull(file);
110109
checkNotNull(charset);
@@ -235,7 +234,6 @@ public static CharSink asCharSink(File file, Charset charset, FileWriteMode... m
235234
* (2^31 - 1)
236235
* @throws IOException if an I/O error occurs
237236
*/
238-
@Beta
239237
public static byte[] toByteArray(File file) throws IOException {
240238
return asByteSource(file).read();
241239
}
@@ -248,11 +246,12 @@ public static byte[] toByteArray(File file) throws IOException {
248246
* helpful predefined constants
249247
* @return a string containing all the characters from the file
250248
* @throws IOException if an I/O error occurs
251-
* @deprecated Prefer {@code asCharSource(file, charset).read()}. This method is scheduled to be
252-
* removed in October 2019.
249+
* @deprecated Prefer {@code asCharSource(file, charset).read()}.
253250
*/
254-
@Beta
255251
@Deprecated
252+
@InlineMe(
253+
replacement = "Files.asCharSource(file, charset).read()",
254+
imports = "com.google.common.io.Files")
256255
public static String toString(File file, Charset charset) throws IOException {
257256
return asCharSource(file, charset).read();
258257
}
@@ -267,7 +266,6 @@ public static String toString(File file, Charset charset) throws IOException {
267266
* @param to the destination file
268267
* @throws IOException if an I/O error occurs
269268
*/
270-
@Beta
271269
public static void write(byte[] from, File to) throws IOException {
272270
asByteSink(to).write(from);
273271
}
@@ -280,11 +278,12 @@ public static void write(byte[] from, File to) throws IOException {
280278
* @param charset the charset used to encode the output stream; see {@link StandardCharsets} for
281279
* helpful predefined constants
282280
* @throws IOException if an I/O error occurs
283-
* @deprecated Prefer {@code asCharSink(to, charset).write(from)}. This method is scheduled to be
284-
* removed in October 2019.
281+
* @deprecated Prefer {@code asCharSink(to, charset).write(from)}.
285282
*/
286-
@Beta
287283
@Deprecated
284+
@InlineMe(
285+
replacement = "Files.asCharSink(to, charset).write(from)",
286+
imports = "com.google.common.io.Files")
288287
public static void write(CharSequence from, File to, Charset charset) throws IOException {
289288
asCharSink(to, charset).write(from);
290289
}
@@ -299,7 +298,6 @@ public static void write(CharSequence from, File to, Charset charset) throws IOE
299298
* @param to the output stream
300299
* @throws IOException if an I/O error occurs
301300
*/
302-
@Beta
303301
public static void copy(File from, OutputStream to) throws IOException {
304302
asByteSource(from).copyTo(to);
305303
}
@@ -323,7 +321,6 @@ public static void copy(File from, OutputStream to) throws IOException {
323321
* @throws IOException if an I/O error occurs
324322
* @throws IllegalArgumentException if {@code from.equals(to)}
325323
*/
326-
@Beta
327324
public static void copy(File from, File to) throws IOException {
328325
checkArgument(!from.equals(to), "Source %s and destination %s must be different", from, to);
329326
asByteSource(from).copyTo(asByteSink(to));
@@ -337,11 +334,12 @@ public static void copy(File from, File to) throws IOException {
337334
* helpful predefined constants
338335
* @param to the appendable object
339336
* @throws IOException if an I/O error occurs
340-
* @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}. This method is scheduled to
341-
* be removed in October 2019.
337+
* @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}.
342338
*/
343-
@Beta
344339
@Deprecated
340+
@InlineMe(
341+
replacement = "Files.asCharSource(from, charset).copyTo(to)",
342+
imports = "com.google.common.io.Files")
345343
public
346344
static void copy(File from, Charset charset, Appendable to) throws IOException {
347345
asCharSource(from, charset).copyTo(to);
@@ -358,8 +356,10 @@ static void copy(File from, Charset charset, Appendable to) throws IOException {
358356
* @deprecated Prefer {@code asCharSink(to, charset, FileWriteMode.APPEND).write(from)}. This
359357
* method is scheduled to be removed in October 2019.
360358
*/
361-
@Beta
362359
@Deprecated
360+
@InlineMe(
361+
replacement = "Files.asCharSink(to, charset, FileWriteMode.APPEND).write(from)",
362+
imports = {"com.google.common.io.FileWriteMode", "com.google.common.io.Files"})
363363
public
364364
static void append(CharSequence from, File to, Charset charset) throws IOException {
365365
asCharSink(to, charset, FileWriteMode.APPEND).write(from);
@@ -370,7 +370,6 @@ static void append(CharSequence from, File to, Charset charset) throws IOExcepti
370370
*
371371
* @throws IOException if an I/O error occurs
372372
*/
373-
@Beta
374373
public static boolean equal(File file1, File file2) throws IOException {
375374
checkNotNull(file1);
376375
checkNotNull(file2);
@@ -452,7 +451,6 @@ public static File createTempDir() {
452451
* @param file the file to create or update
453452
* @throws IOException if an I/O error occurs
454453
*/
455-
@Beta
456454
@SuppressWarnings("GoodTime") // reading system time without TimeSource
457455
public static void touch(File file) throws IOException {
458456
checkNotNull(file);
@@ -470,7 +468,6 @@ public static void touch(File file) throws IOException {
470468
* directories of the specified file could not be created.
471469
* @since 4.0
472470
*/
473-
@Beta
474471
public static void createParentDirs(File file) throws IOException {
475472
checkNotNull(file);
476473
File parent = file.getCanonicalFile().getParentFile();
@@ -501,7 +498,6 @@ public static void createParentDirs(File file) throws IOException {
501498
* @throws IOException if an I/O error occurs
502499
* @throws IllegalArgumentException if {@code from.equals(to)}
503500
*/
504-
@Beta
505501
public static void move(File from, File to) throws IOException {
506502
checkNotNull(from);
507503
checkNotNull(to);
@@ -527,11 +523,12 @@ public static void move(File from, File to) throws IOException {
527523
* helpful predefined constants
528524
* @return the first line, or null if the file is empty
529525
* @throws IOException if an I/O error occurs
530-
* @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}. This method is
531-
* scheduled to be removed in October 2019.
526+
* @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}.
532527
*/
533-
@Beta
534528
@Deprecated
529+
@InlineMe(
530+
replacement = "Files.asCharSource(file, charset).readFirstLine()",
531+
imports = "com.google.common.io.Files")
535532
@CheckForNull
536533
public
537534
static String readFirstLine(File file, Charset charset) throws IOException {
@@ -554,7 +551,6 @@ static String readFirstLine(File file, Charset charset) throws IOException {
554551
* @return a mutable {@link List} containing all the lines
555552
* @throws IOException if an I/O error occurs
556553
*/
557-
@Beta
558554
public static List<String> readLines(File file, Charset charset) throws IOException {
559555
// don't use asCharSource(file, charset).readLines() because that returns
560556
// an immutable list, which would change the behavior of this method
@@ -586,11 +582,12 @@ public List<String> getResult() {
586582
* @param callback the {@link LineProcessor} to use to handle the lines
587583
* @return the output of processing the lines
588584
* @throws IOException if an I/O error occurs
589-
* @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}. This method is
590-
* scheduled to be removed in October 2019.
585+
* @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}.
591586
*/
592-
@Beta
593587
@Deprecated
588+
@InlineMe(
589+
replacement = "Files.asCharSource(file, charset).readLines(callback)",
590+
imports = "com.google.common.io.Files")
594591
@CanIgnoreReturnValue // some processors won't return a useful result
595592
@ParametricNullness
596593
public
@@ -608,11 +605,12 @@ public List<String> getResult() {
608605
* @param processor the object to which the bytes of the file are passed.
609606
* @return the result of the byte processor
610607
* @throws IOException if an I/O error occurs
611-
* @deprecated Prefer {@code asByteSource(file).read(processor)}. This method is scheduled to be
612-
* removed in October 2019.
608+
* @deprecated Prefer {@code asByteSource(file).read(processor)}.
613609
*/
614-
@Beta
615610
@Deprecated
611+
@InlineMe(
612+
replacement = "Files.asByteSource(file).read(processor)",
613+
imports = "com.google.common.io.Files")
616614
@CanIgnoreReturnValue // some processors won't return a useful result
617615
@ParametricNullness
618616
public
@@ -629,11 +627,12 @@ public List<String> getResult() {
629627
* @return the {@link HashCode} of all of the bytes in the file
630628
* @throws IOException if an I/O error occurs
631629
* @since 12.0
632-
* @deprecated Prefer {@code asByteSource(file).hash(hashFunction)}. This method is scheduled to
633-
* be removed in October 2019.
630+
* @deprecated Prefer {@code asByteSource(file).hash(hashFunction)}.
634631
*/
635-
@Beta
636632
@Deprecated
633+
@InlineMe(
634+
replacement = "Files.asByteSource(file).hash(hashFunction)",
635+
imports = "com.google.common.io.Files")
637636
public
638637
static HashCode hash(File file, HashFunction hashFunction) throws IOException {
639638
return asByteSource(file).hash(hashFunction);
@@ -654,7 +653,6 @@ static HashCode hash(File file, HashFunction hashFunction) throws IOException {
654653
* @see FileChannel#map(MapMode, long, long)
655654
* @since 2.0
656655
*/
657-
@Beta
658656
public static MappedByteBuffer map(File file) throws IOException {
659657
checkNotNull(file);
660658
return map(file, MapMode.READ_ONLY);
@@ -677,7 +675,6 @@ public static MappedByteBuffer map(File file) throws IOException {
677675
* @see FileChannel#map(MapMode, long, long)
678676
* @since 2.0
679677
*/
680-
@Beta
681678
public static MappedByteBuffer map(File file, MapMode mode) throws IOException {
682679
return mapInternal(file, mode, -1);
683680
}
@@ -701,7 +698,6 @@ public static MappedByteBuffer map(File file, MapMode mode) throws IOException {
701698
* @see FileChannel#map(MapMode, long, long)
702699
* @since 2.0
703700
*/
704-
@Beta
705701
public static MappedByteBuffer map(File file, MapMode mode, long size) throws IOException {
706702
checkArgument(size >= 0, "size (%s) may not be negative", size);
707703
return mapInternal(file, mode, size);
@@ -745,7 +741,6 @@ private static MappedByteBuffer mapInternal(File file, MapMode mode, long size)
745741
*
746742
* @since 11.0
747743
*/
748-
@Beta
749744
public static String simplifyPath(String pathname) {
750745
checkNotNull(pathname);
751746
if (pathname.length() == 0) {
@@ -806,7 +801,6 @@ public static String simplifyPath(String pathname) {
806801
*
807802
* @since 11.0
808803
*/
809-
@Beta
810804
public static String getFileExtension(String fullName) {
811805
checkNotNull(fullName);
812806
String fileName = new File(fullName).getName();
@@ -824,7 +818,6 @@ public static String getFileExtension(String fullName) {
824818
* @return The file name without its path or extension.
825819
* @since 14.0
826820
*/
827-
@Beta
828821
public static String getNameWithoutExtension(String file) {
829822
checkNotNull(file);
830823
String fileName = new File(file).getName();
@@ -880,7 +873,6 @@ public Iterable<File> successors(File file) {
880873
*
881874
* @since 15.0
882875
*/
883-
@Beta
884876
public static Predicate<File> isDirectory() {
885877
return FilePredicate.IS_DIRECTORY;
886878
}
@@ -890,7 +882,6 @@ public static Predicate<File> isDirectory() {
890882
*
891883
* @since 15.0
892884
*/
893-
@Beta
894885
public static Predicate<File> isFile() {
895886
return FilePredicate.IS_FILE;
896887
}

android/guava/src/com/google/common/io/Resources.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static com.google.common.base.Preconditions.checkArgument;
1818
import static com.google.common.base.Preconditions.checkNotNull;
1919

20-
import com.google.common.annotations.Beta;
2120
import com.google.common.annotations.GwtIncompatible;
2221
import com.google.common.base.Charsets;
2322
import com.google.common.base.MoreObjects;
@@ -41,7 +40,6 @@
4140
* @author Colin Decker
4241
* @since 1.0
4342
*/
44-
@Beta
4543
@GwtIncompatible
4644
@ElementTypesAreNonnullByDefault
4745
public final class Resources {

0 commit comments

Comments
 (0)