class JsonTemplateMapper {

  public static <T extends JsonTemplate> T readJsonFromFileWithLock(
      Path jsonFile, Class<T> templateClass) throws IOException {
    // channel is closed by inputStream.close()
    FileChannel channel = FileChannel.open(jsonFile, StandardOpenOption.READ);
    channel.lock(0, Long.MAX_VALUE, true); // shared lock, released by channel close
    try (InputStream inputStream = Channels.newInputStream(channel)) {
      return objectMapper.readValue(inputStream, templateClass);
    }
  }

  private  JsonTemplateMapper();

}