mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
Recordify tree metadata
This commit is contained in:
@@ -6,12 +6,7 @@ import com.usatiuk.objects.JObjectKey;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class JKleppmannTreeNodeMetaDirectory extends JKleppmannTreeNodeMeta {
|
||||
public JKleppmannTreeNodeMetaDirectory(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public record JKleppmannTreeNodeMetaDirectory(String name) implements JKleppmannTreeNodeMeta {
|
||||
public JKleppmannTreeNodeMeta withName(String name) {
|
||||
return new JKleppmannTreeNodeMetaDirectory(name);
|
||||
}
|
||||
|
||||
@@ -5,49 +5,15 @@ import com.usatiuk.objects.JObjectKey;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class JKleppmannTreeNodeMetaFile extends JKleppmannTreeNodeMeta {
|
||||
private final JObjectKey _fileIno;
|
||||
|
||||
public JKleppmannTreeNodeMetaFile(String name, JObjectKey fileIno) {
|
||||
super(name);
|
||||
_fileIno = fileIno;
|
||||
}
|
||||
|
||||
public JObjectKey getFileIno() {
|
||||
return _fileIno;
|
||||
}
|
||||
|
||||
public record JKleppmannTreeNodeMetaFile(String name, JObjectKey fileIno) implements JKleppmannTreeNodeMeta {
|
||||
@Override
|
||||
public JKleppmannTreeNodeMeta withName(String name) {
|
||||
return new JKleppmannTreeNodeMetaFile(name, _fileIno);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
JKleppmannTreeNodeMetaFile that = (JKleppmannTreeNodeMetaFile) o;
|
||||
return Objects.equals(_fileIno, that._fileIno);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), _fileIno);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JKleppmannTreeNodeMetaFile{" +
|
||||
"_name=" + getName() + ", " +
|
||||
"_fileIno=" + _fileIno +
|
||||
'}';
|
||||
return new JKleppmannTreeNodeMetaFile(name, fileIno);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<JObjectKey> collectRefsTo() {
|
||||
return List.of(_fileIno);
|
||||
return List.of(fileIno);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
||||
try {
|
||||
var ret = getDirEntryR(name);
|
||||
return switch (ret.meta()) {
|
||||
case JKleppmannTreeNodeMetaFile f -> Optional.of(f.getFileIno());
|
||||
case JKleppmannTreeNodeMetaFile f -> Optional.of(f.fileIno());
|
||||
case JKleppmannTreeNodeMetaDirectory f -> Optional.of(ret.key());
|
||||
default -> Optional.empty();
|
||||
};
|
||||
@@ -189,7 +189,7 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
||||
return jObjectTxManager.executeTx(() -> {
|
||||
return getTreeW().findParent(w -> {
|
||||
if (w.meta() instanceof JKleppmannTreeNodeMetaFile f)
|
||||
return f.getFileIno().equals(ino);
|
||||
return f.fileIno().equals(ino);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user