Skip to content

Commit

Permalink
Add MetadataParser#read helper methods that use the inbuilt Gson builder
Browse files Browse the repository at this point in the history
  • Loading branch information
dualspiral committed Sep 1, 2021
1 parent dc4e8f9 commit f388fd2
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ public static GsonBuilder gsonBuilder() {
;
}

/**
* Reads a {@link MetadataContainer container} from a given {@link Path path} using the default {@link Gson deserializer}
* (retrieved from {@link #gsonBuilder()}).
*
* @param path The path
* @return The container
* @throws IOException if the container fails to be read
*/
public static MetadataContainer read(final Path path) throws IOException {
return MetadataParser.read(path, MetadataParser.gsonBuilder().create());
}

/**
* Reads a {@link MetadataContainer container} from a given {@link Path path} with configured {@link Gson deserializer}.
* <p>
Expand All @@ -66,6 +78,18 @@ public static MetadataContainer read(final Path path, final Gson gson) throws IO
}
}

/**
* Reads a {@link MetadataContainer container} from a given {@link Reader reader} using the default {@link Gson deserializer}
* (retrieved from {@link #gsonBuilder()}).
*
* @param reader The reader
* @return The container
* @throws IOException if the container fails to be read
*/
public static MetadataContainer read(final Reader reader) throws IOException {
return MetadataParser.read(reader, MetadataParser.gsonBuilder().create());
}

/**
* Reads a {@link MetadataContainer container} from a given {@link Reader reader} with configured {@link Gson deserializer}.
* <p>
Expand Down

0 comments on commit f388fd2

Please sign in to comment.