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 <loskutov@gmx.de>
This commit is contained in:
Andrey Loskutov 2015-08-10 00:18:48 +02:00
parent f5a5fa28d2
commit bfc3e1262c
2 changed files with 14 additions and 32 deletions

View File

@ -1067,28 +1067,28 @@ public long getLastModifiedTime() {
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 long getLastModifiedTime() {
}
/**
* 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);
}
/**

View File

@ -47,7 +47,6 @@
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 @@
*/
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 @@ static Attributes getFileAttributesBasic(FS fs, File path) {
.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 @@ static Attributes getFileAttributesBasic(FS fs, File path) {
.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 static Attributes getFileAttributesPosix(FS fs, File path) {
.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 static Attributes getFileAttributesPosix(FS fs, File path) {
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);
}