From b3fbbedee12b8de3ee27078ef6a82b3e2fc069db Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 12 Oct 2011 07:43:51 +0200 Subject: [PATCH] Add interface for Sone database. --- .../pterodactylus/sone/database/SoneDatabase.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/net/pterodactylus/sone/database/SoneDatabase.java diff --git a/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java b/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java new file mode 100644 index 0000000..f2c2fbc --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/SoneDatabase.java @@ -0,0 +1,61 @@ +/* + * Sone - SoneDatabase.java - Copyright © 2011 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.database; + +import net.pterodactylus.sone.data.Sone; + +/** + * Interface for the Sone database. + * + * @author David ‘Bombe’ Roden + */ +public interface SoneDatabase { + + /** + * Returns the Sone with the given ID, creating a new Sone if a Sone with + * the given ID does not exist and {@code create} is {@code true}. + * + * @param id + * The ID of the new Sone + * @param create + * {@code true} to create a new Sone if a Sone with the given ID + * does not exist, {@code false} to return {@code null} if a Sone + * with the given ID does not exist + * @return The created Sone + * @throws IllegalArgumentException + * if {@code id} is {@code null} + * @throws DatabaseException + * if a database error occurs + */ + public Sone getSone(String id, boolean create) throws DatabaseException; + + /** + * Stores the given Sone. The given Sone has to be an object that was + * returned by a previous call to {@link #getSone(String, boolean)}. + * + * @param sone + * The Sone to store + * @throws IllegalArgumentException + * if {@code sone} is {@code null}, or the Sone was not + * retrieved by a call to {@link #getSone(String, boolean)} + * @throws DatabaseException + * if a database error occurs + */ + public void saveSone(Sone sone) throws DatabaseException; + +} -- 2.7.4