projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add post reply provider interface.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
data
/
Image.java
diff --git
a/src/main/java/net/pterodactylus/sone/data/Image.java
b/src/main/java/net/pterodactylus/sone/data/Image.java
index
6c37633
..
e50405f
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Image.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Image.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - Image.java - Copyright © 2011 David Roden
+ * Sone - Image.java - Copyright © 2011
–2013
David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-17,9
+17,11
@@
package net.pterodactylus.sone.data;
package net.pterodactylus.sone.data;
-import java.util.UUID;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
-import
net.pterodactylus.util.validation.Validation
;
+import
java.util.UUID
;
/**
* Container for image metadata.
/**
* Container for image metadata.
@@
-70,8
+72,7
@@
public class Image implements Fingerprintable {
* The ID of the image
*/
public Image(String id) {
* The ID of the image
*/
public Image(String id) {
- Validation.begin().isNotNull("Image ID", id).check();
- this.id = id;
+ this.id = checkNotNull(id, "id must not be null");
}
//
}
//
@@
-105,7
+106,8
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setSone(Sone sone) {
* @return This image
*/
public Image setSone(Sone sone) {
- Validation.begin().isNotNull("New Image Owner", sone);
+ checkNotNull(sone, "sone must not be null");
+ checkArgument((this.sone == null) || this.sone.equals(sone), "sone must not already be set to another sone");
this.sone = sone;
return this;
}
this.sone = sone;
return this;
}
@@
-128,7
+130,8
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setAlbum(Album album) {
* @return This image
*/
public Image setAlbum(Album album) {
- Validation.begin().isNotNull("New Album", album).check().isEqual("Album Owner and Image Owner", album.getSone(), getSone()).check();
+ checkNotNull(album, "album must not be null");
+ checkNotNull(album.getSone().equals(getSone()), "album must belong to the same Sone as this image");
this.album = album;
return this;
}
this.album = album;
return this;
}
@@
-151,7
+154,8
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setKey(String key) {
* @return This image
*/
public Image setKey(String key) {
- Validation.begin().isNotNull("New Image Key", key).check();
+ checkNotNull(key, "key must not be null");
+ checkState((this.key == null) || this.key.equals(key), "key must not be already set to another key");
this.key = key;
return this;
}
this.key = key;
return this;
}
@@
-187,7
+191,8
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setCreationTime(long creationTime) {
* @return This image
*/
public Image setCreationTime(long creationTime) {
- Validation.begin().isGreater("New Image Creation Time", creationTime, 0).check();
+ checkArgument(creationTime > 0, "creationTime must be > 0");
+ checkState((this.creationTime == 0) || (this.creationTime == creationTime), "creationTime must not already be set");
this.creationTime = creationTime;
return this;
}
this.creationTime = creationTime;
return this;
}
@@
-210,7
+215,8
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setWidth(int width) {
* @return This image
*/
public Image setWidth(int width) {
- Validation.begin().isGreater("New Image Width", width, 0).check();
+ checkArgument(width > 0, "width must be > 0");
+ checkState((this.width == 0) || (this.width == width), "width must not already be set to another width");
this.width = width;
return this;
}
this.width = width;
return this;
}
@@
-233,7
+239,8
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setHeight(int height) {
* @return This image
*/
public Image setHeight(int height) {
- Validation.begin().isGreater("New Image Height", height, 0);
+ checkArgument(height > 0, "height must be > 0");
+ checkState((this.height == 0) || (this.height == height), "height must not already be set to another height");
this.height = height;
return this;
}
this.height = height;
return this;
}
@@
-255,8
+262,7
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setTitle(String title) {
* @return This image
*/
public Image setTitle(String title) {
- Validation.begin().isNotNull("Image Title", title).check();
- this.title = title;
+ this.title = checkNotNull(title, "title must not be null");
return this;
}
return this;
}
@@
-277,8
+283,7
@@
public class Image implements Fingerprintable {
* @return This image
*/
public Image setDescription(String description) {
* @return This image
*/
public Image setDescription(String description) {
- Validation.begin().isNotNull("Image Description", description).check();
- this.description = description;
+ this.description = checkNotNull(description, "description must not be null");
return this;
}
return this;
}