Allowing more visibility into what the OverrideFileEntryReader is doing
to assist in future debugging. Enable with `-vvvvvv` (6 `v`'s).
This commit is contained in:
parent
6468f3af46
commit
e7c10faf3b
|
@ -24,6 +24,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow programmatic control of what is in the results of the file entry.
|
* Allow programmatic control of what is in the results of the file entry.
|
||||||
|
@ -31,6 +32,8 @@ import java.util.Optional;
|
||||||
* It can also be used to layer in results and overrides.
|
* It can also be used to layer in results and overrides.
|
||||||
*/
|
*/
|
||||||
public class OverrideFileEntryReader implements FileEntryReader {
|
public class OverrideFileEntryReader implements FileEntryReader {
|
||||||
|
private static Logger LOG = Logger.getLogger(OverrideFileEntryReader.class.getName());
|
||||||
|
|
||||||
private Optional<FileEntryReader> parent = Optional.empty();
|
private Optional<FileEntryReader> parent = Optional.empty();
|
||||||
private Optional<String> filename = Optional.empty();
|
private Optional<String> filename = Optional.empty();
|
||||||
private Optional<String> prodosFiletype = Optional.empty();
|
private Optional<String> prodosFiletype = Optional.empty();
|
||||||
|
@ -109,97 +112,138 @@ public class OverrideFileEntryReader implements FileEntryReader {
|
||||||
|
|
||||||
public Builder filename(String filename) {
|
public Builder filename(String filename) {
|
||||||
Objects.requireNonNull(filename);
|
Objects.requireNonNull(filename);
|
||||||
|
LOG.finest(() -> String.format("Setting filename to '%s'", filename));
|
||||||
fileEntryReader.filename = Optional.of(filename);
|
fileEntryReader.filename = Optional.of(filename);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder filename(Optional<String> filename) {
|
public Builder filename(Optional<String> filename) {
|
||||||
Objects.requireNonNull(filename);
|
Objects.requireNonNull(filename);
|
||||||
|
filename.ifPresent(name -> {
|
||||||
|
LOG.finest(() -> String.format("Setting filename to '%s'", name));
|
||||||
|
});
|
||||||
fileEntryReader.filename = filename;
|
fileEntryReader.filename = filename;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder prodosFiletype(String filetype) {
|
public Builder prodosFiletype(String filetype) {
|
||||||
Objects.requireNonNull(filetype);
|
Objects.requireNonNull(filetype);
|
||||||
|
LOG.finest(() -> String.format("Setting file type to '%s'", filetype));
|
||||||
fileEntryReader.prodosFiletype = Optional.of(filetype);
|
fileEntryReader.prodosFiletype = Optional.of(filetype);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder prodosFiletype(Optional<String> filetype) {
|
public Builder prodosFiletype(Optional<String> filetype) {
|
||||||
Objects.requireNonNull(filetype);
|
Objects.requireNonNull(filetype);
|
||||||
|
filetype.ifPresent(type -> {
|
||||||
|
LOG.finest(() -> String.format("Setting file type to '%s'", type));
|
||||||
|
});
|
||||||
fileEntryReader.prodosFiletype = filetype;
|
fileEntryReader.prodosFiletype = filetype;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder locked(boolean locked) {
|
public Builder locked(boolean locked) {
|
||||||
|
LOG.finest(() -> String.format("Setting locked to '%b'", locked));
|
||||||
fileEntryReader.locked = Optional.of(locked);
|
fileEntryReader.locked = Optional.of(locked);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder locked(Optional<Boolean> locked) {
|
public Builder locked(Optional<Boolean> locked) {
|
||||||
|
locked.ifPresent(flag -> {
|
||||||
|
LOG.finest(() -> String.format("Setting locked to '%b'", flag));
|
||||||
|
});
|
||||||
Objects.requireNonNull(locked);
|
Objects.requireNonNull(locked);
|
||||||
fileEntryReader.locked = locked;
|
fileEntryReader.locked = locked;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder fileData(byte[] fileData) {
|
public Builder fileData(byte[] fileData) {
|
||||||
Objects.requireNonNull(fileData);
|
Objects.requireNonNull(fileData);
|
||||||
|
LOG.finest(() -> String.format("Setting data fork to %d bytes.", fileData.length));
|
||||||
fileEntryReader.fileData = Optional.of(fileData);
|
fileEntryReader.fileData = Optional.of(fileData);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder fileData(Optional<byte[]> fileData) {
|
public Builder fileData(Optional<byte[]> fileData) {
|
||||||
Objects.requireNonNull(fileData);
|
Objects.requireNonNull(fileData);
|
||||||
|
fileData.ifPresent(data -> {
|
||||||
|
LOG.finest(() -> String.format("Setting data fork to %d bytes.", data.length));
|
||||||
|
});
|
||||||
fileEntryReader.fileData = fileData;
|
fileEntryReader.fileData = fileData;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder resourceData(byte[] resourceData) {
|
public Builder resourceData(byte[] resourceData) {
|
||||||
Objects.requireNonNull(resourceData);
|
Objects.requireNonNull(resourceData);
|
||||||
|
LOG.finest(() -> String.format("Setting data fork to %d bytes.", resourceData.length));
|
||||||
fileEntryReader.resourceData = Optional.of(resourceData);
|
fileEntryReader.resourceData = Optional.of(resourceData);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder resourceData(Optional<byte[]> resourceData) {
|
public Builder resourceData(Optional<byte[]> resourceData) {
|
||||||
Objects.requireNonNull(resourceData);
|
Objects.requireNonNull(resourceData);
|
||||||
|
resourceData.ifPresent(data -> {
|
||||||
|
LOG.finest(() -> String.format("Setting resource fork to %d bytes.", data.length));
|
||||||
|
});
|
||||||
|
LOG.finest(() -> String.format("Setting file data to %d bytes.", resourceData.orElse(new byte[0]).length));
|
||||||
fileEntryReader.resourceData = resourceData;
|
fileEntryReader.resourceData = resourceData;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder binaryAddress(int binaryAddress) {
|
public Builder binaryAddress(int binaryAddress) {
|
||||||
fileEntryReader.binaryAddress = Optional.of(binaryAddress);
|
fileEntryReader.binaryAddress = Optional.of(binaryAddress);
|
||||||
|
LOG.finest(() -> String.format("Setting address to $%04xs.", binaryAddress));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder binaryAddress(Optional<Integer> binaryAddress) {
|
public Builder binaryAddress(Optional<Integer> binaryAddress) {
|
||||||
Objects.requireNonNull(binaryAddress);
|
Objects.requireNonNull(binaryAddress);
|
||||||
|
binaryAddress.ifPresent(addr -> {
|
||||||
|
LOG.finest(() -> String.format("Setting address to $%04xs.", addr));
|
||||||
|
});
|
||||||
fileEntryReader.binaryAddress = binaryAddress;
|
fileEntryReader.binaryAddress = binaryAddress;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder binaryLength(int binaryLength) {
|
public Builder binaryLength(int binaryLength) {
|
||||||
|
LOG.finest(() -> String.format("Setting binary length to %04x.", binaryLength));
|
||||||
fileEntryReader.binaryLength = Optional.of(binaryLength);
|
fileEntryReader.binaryLength = Optional.of(binaryLength);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder binaryLength(Optional<Integer> binaryLength) {
|
public Builder binaryLength(Optional<Integer> binaryLength) {
|
||||||
Objects.requireNonNull(binaryLength);
|
Objects.requireNonNull(binaryLength);
|
||||||
|
binaryLength.ifPresent(length -> {
|
||||||
|
LOG.finest(() -> String.format("Setting binary length to %04x.", length));
|
||||||
|
});
|
||||||
fileEntryReader.binaryLength = binaryLength;
|
fileEntryReader.binaryLength = binaryLength;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder auxiliaryType(int auxiliaryType) {
|
public Builder auxiliaryType(int auxiliaryType) {
|
||||||
|
LOG.finest(() -> String.format("Setting aux type to $%04x.", auxiliaryType));
|
||||||
fileEntryReader.auxiliaryType = Optional.of(auxiliaryType);
|
fileEntryReader.auxiliaryType = Optional.of(auxiliaryType);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder auxiliaryType(Optional<Integer> auxiliaryType) {
|
public Builder auxiliaryType(Optional<Integer> auxiliaryType) {
|
||||||
Objects.requireNonNull(auxiliaryType);
|
Objects.requireNonNull(auxiliaryType);
|
||||||
|
auxiliaryType.ifPresent(type -> {
|
||||||
|
LOG.finest(() -> String.format("Setting aux type to $%04x.", type));
|
||||||
|
});
|
||||||
fileEntryReader.auxiliaryType = auxiliaryType;
|
fileEntryReader.auxiliaryType = auxiliaryType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder creationDate(Date creationDate) {
|
public Builder creationDate(Date creationDate) {
|
||||||
Objects.requireNonNull(creationDate);
|
Objects.requireNonNull(creationDate);
|
||||||
|
LOG.finest(() -> String.format("Setting creation date to %s.", creationDate));
|
||||||
fileEntryReader.creationDate = Optional.of(creationDate);
|
fileEntryReader.creationDate = Optional.of(creationDate);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder creationDate(Optional<Date> creationDate) {
|
public Builder creationDate(Optional<Date> creationDate) {
|
||||||
Objects.requireNonNull(creationDate);
|
Objects.requireNonNull(creationDate);
|
||||||
|
creationDate.ifPresent(date -> {
|
||||||
|
LOG.finest(() -> String.format("Setting creation date to %s.", date));
|
||||||
|
});
|
||||||
fileEntryReader.creationDate = creationDate;
|
fileEntryReader.creationDate = creationDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder lastModificationDate(Date lastModificationDate) {
|
public Builder lastModificationDate(Date lastModificationDate) {
|
||||||
Objects.requireNonNull(lastModificationDate);
|
Objects.requireNonNull(lastModificationDate);
|
||||||
|
LOG.finest(() -> String.format("Setting last modification date to %s.", lastModificationDate));
|
||||||
fileEntryReader.lastModificationDate = Optional.of(lastModificationDate);
|
fileEntryReader.lastModificationDate = Optional.of(lastModificationDate);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Builder lastModificationDate(Optional<Date> lastModificationDate) {
|
public Builder lastModificationDate(Optional<Date> lastModificationDate) {
|
||||||
Objects.requireNonNull(lastModificationDate);
|
Objects.requireNonNull(lastModificationDate);
|
||||||
|
lastModificationDate.ifPresent(date -> {
|
||||||
|
LOG.finest(() -> String.format("Setting last modification date to %s.", date));
|
||||||
|
});
|
||||||
fileEntryReader.lastModificationDate = lastModificationDate;
|
fileEntryReader.lastModificationDate = lastModificationDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue