Skip to content

Commit

Permalink
validate data resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute committed Feb 4, 2022
1 parent ee05cdc commit af92be8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/dev/katsute/onemta/DataResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public abstract class DataResource {
* @since 1.0.0
*/
public static DataResource create(final DataResourceType type, final File file){
Objects.requireNonNull(type, "DataResourceType must not be null");
Objects.requireNonNull(file, "File must not be null");
if(!file.exists())
throw new NullPointerException("Failed to find file " + file.getPath());
else if(!file.getName().endsWith(".zip"))
throw new UnsupportedOperationException("DataResource must be a zip (.zip) file");

return new DataResource(){

private final DataResourceType datatype = type;
Expand Down

0 comments on commit af92be8

Please sign in to comment.