]> source.dussan.org Git - jgit.git/commitdiff
Cleanup Attributes and remove obsoleted Java7BasicAttributes class 51/53451/2
authorAndrey Loskutov <loskutov@gmx.de>
Sun, 9 Aug 2015 22:18:48 +0000 (00:18 +0200)
committerAndrey Loskutov <loskutov@gmx.de>
Thu, 13 Aug 2015 19:12:05 +0000 (15:12 -0400)
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 <loskutov@gmx.de>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java

index 12dfe96b05a3ac4270d562166a44ec8d6500fd2d..47c747e80dd242b0e18b54986ada8f306a3b2833 100644 (file)
@@ -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);
                }
 
                /**
index f5babedd06f2e515e6e1d4613eccf26fa38b0ebb..109b2df5f2541d7fe1b0e2b815eed6e618b7cacd 100644 (file)
@@ -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);
                }