From 37d40a97c65c078a03b71b98177be6551b3ea28a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Oct 2013 14:05:34 +0200 Subject: [PATCH] Simplify image builders. --- .../net/pterodactylus/sone/data/impl/AbstractImageBuilder.java | 9 +++++++++ .../java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) 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); } } -- 2.7.4