Recordify tree metadata

This commit is contained in:
2025-04-25 13:35:54 +02:00
parent e5be1e6164
commit 16ba692019
12 changed files with 23 additions and 116 deletions

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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;
});
});