Skip to content

Commit

Permalink
split.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Jun 25, 2024
1 parent 0670242 commit 8eda643
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions generator/src/main/java/net/infumia/pack/PackGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ public static PackGeneratedContext generate(
final PackWriterSettings writerSettings,
final Pack base
) throws IOException {
final PackReader reader = new PackReader(readerSettings, base);
final PackWriter writer = new PackWriter(writerSettings);
final PackGeneratorContext context = reader.read();
final PackGeneratorContext parsed = PackParser.parse(context);
return writer.write(parsed);
return PackGenerator.write(
writerSettings,
PackParser.parse(PackGenerator.read(readerSettings, base))
);
}

/**
Expand All @@ -43,6 +42,35 @@ public static PackGeneratedContext generate(
return PackGenerator.generate(readerSettings, writerSettings, Packs.create());
}

/**
* Reads the pack based on the provided settings and base pack.
*
* @param readerSettings the pack reader settings. Cannot be null.
* @param base the base pack. Cannot be null.
* @return the pack generation context.
* @throws IOException if an I/O error is thrown when accessing the starting file.
*/
public static PackGeneratorContext read(
final PackReaderSettings readerSettings,
final Pack base
) throws IOException {
return new PackReader(readerSettings, base).read();
}

/**
* Writes the pack based on the provided settings and context.
*
* @param writerSettings the pack writer settings. Cannot be null.
* @param context the pack generator context. Cannot be null.
* @return the generated pack context.
*/
public static PackGeneratedContext write(
final PackWriterSettings writerSettings,
final PackGeneratorContext context
) {
return new PackWriter(writerSettings).write(context);
}

private PackGenerator() {
throw new IllegalStateException("Utility class");
}
Expand Down

0 comments on commit 8eda643

Please sign in to comment.