diff --git a/android/guava-tests/test/com/google/common/io/FileTreeTraverserTest.java b/android/guava-tests/test/com/google/common/io/FileTreeTraverserTest.java deleted file mode 100644 index 5be9b859fca6..000000000000 --- a/android/guava-tests/test/com/google/common/io/FileTreeTraverserTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2012 The Guava Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.common.io; - -import com.google.common.collect.ImmutableSet; -import java.io.File; -import java.io.IOException; -import junit.framework.TestCase; - -/** - * Tests for {@link Files#fileTreeViewer}. - * - * @author Colin Decker - */ - -public class FileTreeTraverserTest extends TestCase { - - private File dir; - - @Override - public void setUp() throws IOException { - dir = Files.createTempDir(); - } - - @Override - public void tearDown() throws IOException { - File[] files = dir.listFiles(); - if (files == null) { - return; - } - - // we aren't creating any files in subdirs - for (File file : files) { - file.delete(); - } - - dir.delete(); - } - - public void testFileTreeViewer_emptyDir() throws IOException { - assertDirChildren(); - } - - public void testFileTreeViewer_singleFile() throws IOException { - File file = newFile("test"); - assertDirChildren(file); - } - - public void testFileTreeViewer_singleDir() throws IOException { - File file = newDir("test"); - assertDirChildren(file); - } - - public void testFileTreeViewer_multipleFiles() throws IOException { - File a = newFile("a"); - File b = newDir("b"); - File c = newFile("c"); - File d = newDir("d"); - assertDirChildren(a, b, c, d); - } - - private File newDir(String name) throws IOException { - File file = new File(dir, name); - file.mkdir(); - return file; - } - - private File newFile(String name) throws IOException { - File file = new File(dir, name); - file.createNewFile(); - return file; - } - - private void assertDirChildren(File... files) { - assertEquals( - ImmutableSet.copyOf(files), ImmutableSet.copyOf(Files.fileTreeTraverser().children(dir))); - } -} diff --git a/android/guava-tests/test/com/google/common/io/FilesTest.java b/android/guava-tests/test/com/google/common/io/FilesTest.java index 64f27758639e..e987f600a146 100644 --- a/android/guava-tests/test/com/google/common/io/FilesTest.java +++ b/android/guava-tests/test/com/google/common/io/FilesTest.java @@ -43,8 +43,7 @@ /** * Unit test for {@link Files}. * - *

Note: {@link Files#fileTreeTraverser()} is tested in {@link FileTreeTraverserTest} and {@link - * Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}. + *

Note: {@link Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}. * * @author Chris Nokleberg */ diff --git a/android/guava/src/com/google/common/io/Files.java b/android/guava/src/com/google/common/io/Files.java index c988120b9eed..6a763f96c298 100644 --- a/android/guava/src/com/google/common/io/Files.java +++ b/android/guava/src/com/google/common/io/Files.java @@ -802,11 +802,10 @@ public static String getNameWithoutExtension(String file) { * * @since 15.0 * @deprecated The returned {@link TreeTraverser} type is deprecated. Use the replacement method - * {@link #fileTraverser()} instead with the same semantics as this method. This method is - * scheduled to be removed in April 2018. + * {@link #fileTraverser()} instead with the same semantics as this method. */ @Deprecated - public static TreeTraverser fileTreeTraverser() { + static TreeTraverser fileTreeTraverser() { return FILE_TREE_TRAVERSER; } diff --git a/guava-tests/test/com/google/common/io/FileTreeTraverserTest.java b/guava-tests/test/com/google/common/io/FileTreeTraverserTest.java deleted file mode 100644 index 5be9b859fca6..000000000000 --- a/guava-tests/test/com/google/common/io/FileTreeTraverserTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2012 The Guava Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.common.io; - -import com.google.common.collect.ImmutableSet; -import java.io.File; -import java.io.IOException; -import junit.framework.TestCase; - -/** - * Tests for {@link Files#fileTreeViewer}. - * - * @author Colin Decker - */ - -public class FileTreeTraverserTest extends TestCase { - - private File dir; - - @Override - public void setUp() throws IOException { - dir = Files.createTempDir(); - } - - @Override - public void tearDown() throws IOException { - File[] files = dir.listFiles(); - if (files == null) { - return; - } - - // we aren't creating any files in subdirs - for (File file : files) { - file.delete(); - } - - dir.delete(); - } - - public void testFileTreeViewer_emptyDir() throws IOException { - assertDirChildren(); - } - - public void testFileTreeViewer_singleFile() throws IOException { - File file = newFile("test"); - assertDirChildren(file); - } - - public void testFileTreeViewer_singleDir() throws IOException { - File file = newDir("test"); - assertDirChildren(file); - } - - public void testFileTreeViewer_multipleFiles() throws IOException { - File a = newFile("a"); - File b = newDir("b"); - File c = newFile("c"); - File d = newDir("d"); - assertDirChildren(a, b, c, d); - } - - private File newDir(String name) throws IOException { - File file = new File(dir, name); - file.mkdir(); - return file; - } - - private File newFile(String name) throws IOException { - File file = new File(dir, name); - file.createNewFile(); - return file; - } - - private void assertDirChildren(File... files) { - assertEquals( - ImmutableSet.copyOf(files), ImmutableSet.copyOf(Files.fileTreeTraverser().children(dir))); - } -} diff --git a/guava-tests/test/com/google/common/io/FilesTest.java b/guava-tests/test/com/google/common/io/FilesTest.java index 64f27758639e..e987f600a146 100644 --- a/guava-tests/test/com/google/common/io/FilesTest.java +++ b/guava-tests/test/com/google/common/io/FilesTest.java @@ -43,8 +43,7 @@ /** * Unit test for {@link Files}. * - *

Note: {@link Files#fileTreeTraverser()} is tested in {@link FileTreeTraverserTest} and {@link - * Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}. + *

Note: {@link Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}. * * @author Chris Nokleberg */ diff --git a/guava/src/com/google/common/io/Files.java b/guava/src/com/google/common/io/Files.java index c988120b9eed..6a763f96c298 100644 --- a/guava/src/com/google/common/io/Files.java +++ b/guava/src/com/google/common/io/Files.java @@ -802,11 +802,10 @@ public static String getNameWithoutExtension(String file) { * * @since 15.0 * @deprecated The returned {@link TreeTraverser} type is deprecated. Use the replacement method - * {@link #fileTraverser()} instead with the same semantics as this method. This method is - * scheduled to be removed in April 2018. + * {@link #fileTraverser()} instead with the same semantics as this method. */ @Deprecated - public static TreeTraverser fileTreeTraverser() { + static TreeTraverser fileTreeTraverser() { return FILE_TREE_TRAVERSER; } diff --git a/guava/src/com/google/common/io/MoreFiles.java b/guava/src/com/google/common/io/MoreFiles.java index b9b35e6a6419..022455e5e95b 100644 --- a/guava/src/com/google/common/io/MoreFiles.java +++ b/guava/src/com/google/common/io/MoreFiles.java @@ -24,7 +24,6 @@ import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; -import com.google.common.collect.TreeTraverser; import com.google.common.graph.SuccessorsFunction; import com.google.common.graph.Traverser; import com.google.common.io.ByteSource.AsCharSource; @@ -267,40 +266,6 @@ public static ImmutableList listFiles(Path dir) throws IOException { } } - /** - * Returns a {@link TreeTraverser} for traversing a directory tree. The returned traverser - * attempts to avoid following symbolic links to directories. However, the traverser cannot - * guarantee that it will not follow symbolic links to directories as it is possible for a - * directory to be replaced with a symbolic link between checking if the file is a directory and - * actually reading the contents of that directory. - * - *

Note that if the {@link Path} passed to one of the traversal methods does not exist, no - * exception will be thrown and the returned {@link Iterable} will contain a single element: that - * path. - * - *

{@link DirectoryIteratorException} may be thrown when iterating {@link Iterable} instances - * created by this traverser if an {@link IOException} is thrown by a call to {@link - * #listFiles(Path)}. - * - * @deprecated The returned {@link TreeTraverser} type is deprecated. Use the replacement method - * {@link #fileTraverser()} instead with the same semantics as this method. This method is - * scheduled to be removed in April 2018. - */ - @Deprecated - public static TreeTraverser directoryTreeTraverser() { - return DirectoryTreeTraverser.INSTANCE; - } - - private static final class DirectoryTreeTraverser extends TreeTraverser { - - private static final DirectoryTreeTraverser INSTANCE = new DirectoryTreeTraverser(); - - @Override - public Iterable children(Path dir) { - return fileTreeChildren(dir); - } - } - /** * Returns a {@link Traverser} instance for the file and directory tree. The returned traverser * starts from a {@link Path} and will return all files and directories it encounters.