kz.greetgo.logging.zookeeper.config.EventConfigFileFromStorage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greetgo-logging-zookeeper Show documentation
Show all versions of greetgo-logging-zookeeper Show documentation
Logging mechanism using in greetgo!
package kz.greetgo.logging.zookeeper.config;
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
public class EventConfigFileFromStorage implements EventConfigFile {
private final String path;
private final EventConfigStorage storage;
public EventConfigFileFromStorage(String path, EventConfigStorage storage) {
this.path = path;
this.storage = storage;
}
@Override
public EventRegistration addEventHandler(EventFileHandler eventFileHandler) {
return storage.addEventHandler((pathArg, type) -> {
if (Objects.equals(pathArg, path)) {
eventFileHandler.eventHappened(type);
}
});
}
@Override
public void ensureLookingFor() {
storage.ensureLookingFor(path);
}
@Override
public Optional createdAt() {
return storage.createdAt(path);
}
@Override
public Optional lastModifiedAt() {
return storage.lastModifiedAt(path);
}
@Override
public byte[] readContent() {
return storage.readContent(path);
}
@Override
public void writeContent(byte[] content) {
storage.writeContent(path, content);
}
@Override
public void close() {
storage.close();
}
}