- /**
- * Returns the image with the given ID, creating it if necessary.
- *
- * @param imageId
- * The ID of the image
- * @return The image with the given ID
- */
- public Image getImage(String imageId) {
- return getImage(imageId, true);
- }
-
- /**
- * Returns the image with the given ID, optionally creating it if it does
- * not exist.
- *
- * @param imageId
- * The ID of the image
- * @param create
- * {@code true} to create an image if none exists with the given
- * ID
- * @return The image with the given ID, or {@code null} if none exists and
- * none was created
- */
- public Image getImage(String imageId, boolean create) {
- Optional<Image> image = database.getImage(imageId);
- if (image.isPresent()) {
- return image.get();
- }
- if (!create) {
- return null;
- }
- Image newImage = database.newImageBuilder().withId(imageId).build();
- database.storeImage(newImage);
- return newImage;