diff options
author | Colin Decker <cgdecker@google.com> | 2013-10-18 14:37:49 -0400 |
---|---|---|
committer | Colin Decker <cgdecker@google.com> | 2013-10-18 14:37:49 -0400 |
commit | 40560ae2f2f04012c229aa5348e9b462a81a0e56 (patch) | |
tree | 9515d10f6090d0eac98b69812c44d24654c052fd /jimfs | |
parent | 00f243cb657c0bfb4829f839600c0a48c26c6585 (diff) | |
download | jimfs-40560ae2f2f04012c229aa5348e9b462a81a0e56.tar.gz |
Minor changes.
Diffstat (limited to 'jimfs')
3 files changed, 12 insertions, 7 deletions
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java b/jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java index 3ecec21..bbb1f98 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java @@ -16,10 +16,10 @@ package com.google.jimfs.internal; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.jimfs.internal.Name.PARENT; import static com.google.jimfs.internal.Name.SELF; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; @@ -136,7 +136,8 @@ final class DirectoryTable implements FileContent { /** * Returns the number of entries in this directory. */ - public int size() { + @VisibleForTesting + int entryCount() { return entries.size(); } @@ -161,7 +162,9 @@ final class DirectoryTable implements FileContent { } private DirectoryEntry linkInternal(Name name, File file) { - checkArgument(!entries.containsKey(name), "entry '%s' already exists", name); + if (entries.containsKey(name)) { + throw new IllegalArgumentException("entry '" + name + "' already exists"); + } DirectoryEntry entry = new DirectoryEntry(self(), name, file); entries.put(name, entry); file.incrementLinkCount(); @@ -219,7 +222,9 @@ final class DirectoryTable implements FileContent { } private static Name checkValidName(Name name, String action) { - checkArgument(!RESERVED_NAMES.contains(name), "cannot %s: %s", action, name); + if (RESERVED_NAMES.contains(name)) { + throw new IllegalArgumentException("cannot " + action + ": " + name); + } return name; } } diff --git a/jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java b/jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java index 9c114ca..9666eff 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java @@ -273,7 +273,7 @@ final class FileSystemView { * already exists at the given path, returns the key of that file. Otherwise, throws {@link * FileAlreadyExistsException}. */ - public File createFile(JimfsPath path, Supplier<File> fileSupplier, + private File createFile(JimfsPath path, Supplier<File> fileSupplier, boolean allowExisting, FileAttribute<?>... attrs) throws IOException { checkNotNull(path); checkNotNull(fileSupplier); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java b/jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java index 675a50c..41b9376 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java +++ b/jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java @@ -64,7 +64,7 @@ public class DirectoryTableTest { @SuppressWarnings("ConstantConditions") @Test public void testRootDirectory() { - ASSERT.that(root.size()).is(3); // two for parent/self, one for table + ASSERT.that(root.entryCount()).is(3); // two for parent/self, one for table ASSERT.that(root.isEmpty()).isFalse(); ASSERT.that(root.entry()).is(entry(rootFile, "/", rootFile)); ASSERT.that(root.name()).is(Name.simple("/")); @@ -74,7 +74,7 @@ public class DirectoryTableTest { @Test public void testEmptyDirectory() { - ASSERT.that(table.size()).is(2); + ASSERT.that(table.entryCount()).is(2); ASSERT.that(table.isEmpty()).isTrue(); assertParentAndSelf(table, rootFile, dirFile); |