use of com.willwinder.ugs.nbp.designer.io.ugsd.common.UgsDesign in project Universal-G-Code-Sender by winder.
the class UgsDesignReader method read.
@Override
public Optional<Design> read(InputStream resourceAsStream) {
try {
String designFileContent = IOUtils.toString(resourceAsStream, StandardCharsets.UTF_8);
if (StringUtils.isEmpty(designFileContent)) {
return Optional.empty();
}
Gson gson = new GsonBuilder().create();
UgsDesign design = gson.fromJson(designFileContent, UgsDesign.class);
if (DesignV1.VERSION.equals(design.getVersion())) {
return parseV1(designFileContent);
}
throw new RuntimeException("Unknown version " + design.getVersion());
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Couldn't load stream", e);
throw new RuntimeException("Couldn't read from stream", e);
}
}
Aggregations