@Test public void nullOnNullPathValue() throws Exception { JsonNode model = new ObjectMapper().readTree("{\"partitionPath\":null}"); @SuppressWarnings("resource") Supplier<Path> pathSupplier = new PartitionPathSupplier(() -> model); assertThat(pathSupplier.get(), is(nullValue())); }
@Override public Path get() { return Optional .of(roadModelSupplier.get().path("partitionPath")) .filter(path -> !path.isMissingNode()) .filter(path -> !path.isNull()) .map(JsonNode::asText) .filter(text -> !text.isEmpty()) .map(KeyPathParser::parse) .orElse(null); }
PartitionPathSupplier implements Supplier<Path>, AutoCloseable { @Override public Path get() { return Optional .of(roadModelSupplier.get().path("partitionPath")) .filter(path -> !path.isMissingNode()) .filter(path -> !path.isNull()) .map(JsonNode::asText) .filter(text -> !text.isEmpty()) .map(KeyPathParser::parse) .orElse(null); } }
PartitionPathSupplier implements Supplier<Path>, AutoCloseable { @Override public Path get() { return Optional .of(roadModelSupplier.get().path("partitionPath")) .filter(path -> !path.isMissingNode()) .filter(path -> !path.isNull()) .map(JsonNode::asText) .filter(text -> !text.isEmpty()) .map(KeyPathParser::parse) .orElse(null); }  }
PartitionPathSupplier implements Supplier<Path>, AutoCloseable { @Override public Path get() { return Optional .of(roadModelSupplier.get().path("partitionPath")) .filter(path -> !path.isMissingNode()) .filter(path -> !path.isNull()) .map(JsonNode::asText) .filter(text -> !text.isEmpty()) .map(KeyPathParser::parse) .orElse(null); }  @Override Path get(); @Override void close(); }
PartitionPathSupplier implements Supplier<Path>, AutoCloseable { @Override public Path get() { return Optional .of(roadModelSupplier.get().path("partitionPath")) .filter(path -> !path.isMissingNode()) .filter(path -> !path.isNull()) .map(JsonNode::asText) .filter(text -> !text.isEmpty()) .map(KeyPathParser::parse) .orElse(null); }  @Override Path get(); @Override void close();  }