@Test void getTypeFromFile() { assertEquals(JsonTools.YAML, jsonTools.getTypeFromFile(new File("test.yml"))); assertEquals(JsonTools.JSON, jsonTools.getTypeFromFile(new File("test.json"))); assertThrows(JsonToolsException.class, () -> jsonTools.getTypeFromFile(new File("test.txt"))); }
@NotNull public String getTypeFromFile(File file) { String type = getTypeFromExtension(getExtension(file.getName())); if(type == null) { throw new JsonToolsException("Invalid file: " + file.getName() + ". Expecting json or yaml file formats."); } return type; }
JsonTools { @NotNull public String getTypeFromFile(File file) { String type = getTypeFromExtension(getExtension(file.getName())); if(type == null) { throw new JsonToolsException("Invalid file: " + file.getName() + ". Expecting json or yaml file formats."); } return type; } }
JsonTools { @NotNull public String getTypeFromFile(File file) { String type = getTypeFromExtension(getExtension(file.getName())); if(type == null) { throw new JsonToolsException("Invalid file: " + file.getName() + ". Expecting json or yaml file formats."); } return type; } JsonTools(FileUtils fileUtils); }
JsonTools { @NotNull public String getTypeFromFile(File file) { String type = getTypeFromExtension(getExtension(file.getName())); if(type == null) { throw new JsonToolsException("Invalid file: " + file.getName() + ". Expecting json or yaml file formats."); } return type; } JsonTools(FileUtils fileUtils); ObjectMapper getObjectMapper(); ObjectWriter getObjectWriter(); ObjectWriter getObjectWriter(String outputType); ObjectMapper getObjectMapper(final String type); File getDocumentFile(final File rootDir, final String fileName); T readDocumentFile(final File file, final JavaType entityMapType); T readStream(final InputStream stream, final String type, final JavaType entityMapType); @NotNull String getTypeFromFile(File file); @Nullable String getTypeFromExtension(String extension); void setOutputType(String outputType); String getFileExtension(); void writeObject(final Object object, OutputStream outputStream); }
JsonTools { @NotNull public String getTypeFromFile(File file) { String type = getTypeFromExtension(getExtension(file.getName())); if(type == null) { throw new JsonToolsException("Invalid file: " + file.getName() + ". Expecting json or yaml file formats."); } return type; } JsonTools(FileUtils fileUtils); ObjectMapper getObjectMapper(); ObjectWriter getObjectWriter(); ObjectWriter getObjectWriter(String outputType); ObjectMapper getObjectMapper(final String type); File getDocumentFile(final File rootDir, final String fileName); T readDocumentFile(final File file, final JavaType entityMapType); T readStream(final InputStream stream, final String type, final JavaType entityMapType); @NotNull String getTypeFromFile(File file); @Nullable String getTypeFromExtension(String extension); void setOutputType(String outputType); String getFileExtension(); void writeObject(final Object object, OutputStream outputStream); static final JsonTools INSTANCE; static final String JSON; static final String YAML; static final String JSON_EXTENSION; static final String YML_EXTENSION; static final String YAML_EXTENSION; }