import java.util.UUID;
import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.database.PostBuilder;
-import net.pterodactylus.sone.database.SoneProvider;
/**
* {@link PostBuilder} implementation that creates {@link PostImpl} objects.
*/
public class DefaultPostBuilder extends AbstractPostBuilder {
- private final SoneProvider soneProvider;
+ private final Database database;
/**
* Creates a new post builder.
*
- * @param soneProvider
- * The Sone provider
+ * @param database
*/
- public DefaultPostBuilder(SoneProvider soneProvider) {
- this.soneProvider = soneProvider;
+ public DefaultPostBuilder(Database database) {
+ this.database = database;
}
/** {@inheritDoc} */
@Override
public Post build() {
validate();
- return new PostImpl(soneProvider, randomId ? UUID.randomUUID().toString() : id, senderId, recipientId, currentTime ? System.currentTimeMillis() : time, text);
+ return new PostImpl(database, randomId ? UUID.randomUUID().toString() : id, senderId, recipientId, currentTime ? System.currentTimeMillis() : time, text);
}
}
package net.pterodactylus.sone.data.impl;
+import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.database.PostBuilderFactory;
-import net.pterodactylus.sone.database.SoneProvider;
import com.google.inject.Inject;
/**
- * {@link PostBuilderFactory} implementation that creates
- * {@link DefaultPostBuilder}s.
+ * {@link PostBuilderFactory} implementation that creates {@link
+ * DefaultPostBuilder}s.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultPostBuilderFactory implements PostBuilderFactory {
- /** The Sone provider. */
- private final SoneProvider soneProvider;
+ private final Database database;
/**
* Creates a new default post builder factory.
*
- * @param soneProvider
- * The Sone provider
+ * @param database
+ * The database
*/
@Inject
- public DefaultPostBuilderFactory(SoneProvider soneProvider) {
- this.soneProvider = soneProvider;
+ public DefaultPostBuilderFactory(Database database) {
+ this.database = database;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public PostBuilder newPostBuilder() {
- return new DefaultPostBuilder(soneProvider);
+ return new DefaultPostBuilder(database);
}
}
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.database.SoneProvider;
+import net.pterodactylus.sone.database.Database;
import com.google.common.base.Optional;
*/
public class PostImpl implements Post {
- /** The Sone provider. */
- private final SoneProvider soneProvider;
+ private final Database database;
/** The GUID of the post. */
private final UUID id;
/**
* Creates a new post.
*
- * @param soneProvider
- * The Sone provider
+ * @param database
+ * The database
* @param id
* The ID of the post
* @param soneId
* @param text
* The text of the post
*/
- public PostImpl(SoneProvider soneProvider, String id, String soneId, String recipientId, long time, String text) {
- this.soneProvider = soneProvider;
+ public PostImpl(Database database, String id, String soneId, String recipientId, long time, String text) {
+ this.database = database;
this.id = UUID.fromString(id);
this.soneId = soneId;
this.recipientId = recipientId;
*/
@Override
public Sone getSone() {
- return soneProvider.getSone(soneId).get();
+ return database.getSone(soneId).get();
}
/**
*/
@Override
public Optional<Sone> getRecipient() {
- return soneProvider.getSone(recipientId);
+ return database.getSone(recipientId);
}
/**