All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kz.greetgo.logging.zookeeper.config.EventConfigFileFromStorage Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
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();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy