From: Andrey Loskutov Date: Sun, 9 Aug 2015 22:18:48 +0000 (+0200) Subject: Cleanup Attributes and remove obsoleted Java7BasicAttributes class X-Git-Tag: v4.1.0.201509280440-r~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F51%2F53451%2F2;p=jgit.git Cleanup Attributes and remove obsoleted Java7BasicAttributes class After jgit moved to Java 7 there is no need in an extra Java7BasicAttributes class. Also all fields of Attributes can be made final now. Change-Id: I0be6daf7758189b0eecc4e26294bd278ed8bf7a0 Signed-off-by: Andrey Loskutov --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 12dfe96b05..47c747e80d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -1067,28 +1067,28 @@ public abstract class FS { return lastModifiedTime; } - private boolean isDirectory; + private final boolean isDirectory; - private boolean isSymbolicLink; + private final boolean isSymbolicLink; - private boolean isRegularFile; + private final boolean isRegularFile; - private long creationTime; + private final long creationTime; - private long lastModifiedTime; + private final long lastModifiedTime; - private boolean isExecutable; + private final boolean isExecutable; - private File file; + private final File file; - private boolean exists; + private final boolean exists; /** * file length */ protected long length = -1; - FS fs; + final FS fs; Attributes(FS fs, File file, boolean exists, boolean isDirectory, boolean isExecutable, boolean isSymbolicLink, @@ -1107,14 +1107,14 @@ public abstract class FS { } /** - * Constructor when there are issues with reading + * Constructor when there are issues with reading. All attributes except + * given will be set to the default values. * * @param fs * @param path */ public Attributes(File path, FS fs) { - this.file = path; - this.fs = fs; + this(fs, path, false, false, false, false, false, 0L, 0L, 0L); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java index f5babedd06..109b2df5f2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java @@ -47,7 +47,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.LinkOption; -import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; @@ -66,17 +65,6 @@ import org.eclipse.jgit.util.FS.Attributes; */ public class FileUtil { - static class Java7BasicAttributes extends Attributes { - - Java7BasicAttributes(FS fs, File fPath, boolean exists, - boolean isDirectory, boolean isExecutable, - boolean isSymbolicLink, boolean isRegularFile, - long creationTime, long lastModifiedTime, long length) { - super(fs, fPath, exists, isDirectory, isExecutable, isSymbolicLink, - isRegularFile, creationTime, lastModifiedTime, length); - } - } - /** * @param path * @return target path of the symlink @@ -230,7 +218,7 @@ public class FileUtil { .getFileAttributeView(nioPath, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); - Attributes attributes = new FileUtil.Java7BasicAttributes(fs, path, + Attributes attributes = new Attributes(fs, path, true, readAttributes.isDirectory(), fs.supportsExecute() ? path.canExecute() : false, @@ -242,9 +230,6 @@ public class FileUtil { .encode(FileUtils.readSymLink(path)).length : readAttributes.size()); return attributes; - } catch (NoSuchFileException e) { - return new FileUtil.Java7BasicAttributes(fs, path, false, false, - false, false, false, 0L, 0L, 0L); } catch (IOException e) { return new Attributes(path, fs); } @@ -264,7 +249,7 @@ public class FileUtil { .getFileAttributeView(nioPath, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); - Attributes attributes = new FileUtil.Java7BasicAttributes( + Attributes attributes = new Attributes( fs, path, true, // @@ -277,9 +262,6 @@ public class FileUtil { readAttributes.lastModifiedTime().toMillis(), readAttributes.size()); return attributes; - } catch (NoSuchFileException e) { - return new FileUtil.Java7BasicAttributes(fs, path, false, false, - false, false, false, 0L, 0L, 0L); } catch (IOException e) { return new Attributes(path, fs); }