package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.data.Image;
+
/**
* Combines an {@link ImageProvider}, an {@link ImageBuilderFactory}, and an
* {@link ImageStore} into an image database.
*/
public interface ImageDatabase extends ImageProvider, ImageStore {
- /* nothing here. */
+ void moveUp(Image image);
+ void moveDown(Image image);
}
}
}
+ @Override
+ public void moveUp(Image image) {
+ lock.writeLock().lock();
+ try {
+ List<String> images = albumImages.get(image.getAlbum().getId());
+ int currentIndex = images.indexOf(image.getId());
+ if (currentIndex == 0) {
+ return;
+ }
+ images.remove(image.getId());
+ images.add(currentIndex - 1, image.getId());
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public void moveDown(Image image) {
+ lock.writeLock().lock();
+ try {
+ List<String> images = albumChildren.get(image.getAlbum().getId());
+ int currentIndex = images.indexOf(image.getId());
+ if (currentIndex == (images.size() - 1)) {
+ return;
+ }
+ images.remove(image.getId());
+ images.add(currentIndex + 1, image.getId());
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
//
// IMAGESTORE METHODS
//
}
}
- void moveUp(Image image) {
- lock.writeLock().lock();
- try {
- List<String> images = albumImages.get(image.getAlbum().getId());
- int currentIndex = images.indexOf(image.getId());
- if (currentIndex == 0) {
- return;
- }
- images.remove(image.getId());
- images.add(currentIndex - 1, image.getId());
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- void moveDown(Image image) {
- lock.writeLock().lock();
- try {
- List<String> images = albumChildren.get(image.getAlbum().getId());
- int currentIndex = images.indexOf(image.getId());
- if (currentIndex == (images.size() - 1)) {
- return;
- }
- images.remove(image.getId());
- images.add(currentIndex + 1, image.getId());
- } finally {
- lock.writeLock().unlock();
- }
- }
-
//
// PRIVATE METHODS
//