From: David ‘Bombe’ Roden Date: Sat, 12 Oct 2013 12:05:34 +0000 (+0200) Subject: Simplify image builders. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=37d40a97c65c078a03b71b98177be6551b3ea28a;p=Sone.git Simplify image builders. --- diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java index 209ef0f..0803084 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.data.impl; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import static java.util.UUID.randomUUID; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Sone; @@ -96,6 +97,14 @@ public abstract class AbstractImageBuilder implements ImageBuilder { // PROTECTED METHODS // + protected String getId() { + return randomId ? randomUUID().toString() : id; + } + + protected long getCreationTime() { + return createdNow ? System.currentTimeMillis() : creationTime; + } + /** * Validates the state of this image builder. * diff --git a/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java index 8135736..d3f060d 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java @@ -17,8 +17,6 @@ package net.pterodactylus.sone.data.impl; -import static java.util.UUID.randomUUID; - import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.ImageImpl; @@ -38,9 +36,7 @@ public class ImageBuilderImpl extends AbstractImageBuilder { @Override public Image build() throws IllegalStateException { validate(); - String id = randomId ? randomUUID().toString() : this.id; - long creationTime = createdNow ? System.currentTimeMillis() : this.creationTime; - return new ImageImpl(id, sone, album, key, creationTime, width, height); + return new ImageImpl(getId(), sone, album, key, getCreationTime(), width, height); } }