From 0ea3d92cc0dc179e4236a9933b88e6899a1cac65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Sun, 12 May 2024 23:48:53 +0200 Subject: [PATCH] NOTICKET: Finish Javadoc for de.hitec.nhplus.datastorage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- .../java/de/hitec/nhplus/datastorage/Dao.java | 7 ++- .../hitec/nhplus/datastorage/DaoFactory.java | 2 +- .../de/hitec/nhplus/datastorage/DaoImp.java | 55 ++++++++++++++++--- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/hitec/nhplus/datastorage/Dao.java b/src/main/java/de/hitec/nhplus/datastorage/Dao.java index 8f70e87..2b855e5 100644 --- a/src/main/java/de/hitec/nhplus/datastorage/Dao.java +++ b/src/main/java/de/hitec/nhplus/datastorage/Dao.java @@ -18,7 +18,7 @@ public interface Dao { /** * Create a Database Entry from a Model object. * - * @param t The Model instance. + * @param t The Model-Instance. */ void create(T t) throws SQLException; @@ -26,18 +26,19 @@ public interface Dao { * Read a Database Entry to a Model object. * * @param id The ID of the Element in the Database. + * @return a Model-Instance of {@link T}. */ T read(int id) throws SQLException; /** - * @return All Database Entries as a {@link List} of Model instances + * @return All Database Entries as a {@link List} of Model-Instances. */ List readAll() throws SQLException; /** * Update the Database according to the Values of the Model object. * - * @param t The Model instance. + * @param t The Model-Instance. */ void update(T t) throws SQLException; diff --git a/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java b/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java index 1bdbab9..7242a8a 100644 --- a/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java +++ b/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java @@ -23,7 +23,7 @@ public class DaoFactory { } /** - * @return The Singleton Instance. + * @return The Singleton Instance of {@link DaoFactory}. */ public static DaoFactory getInstance() { if (DaoFactory.instance == null) { diff --git a/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java b/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java index 0d3af03..32a3b56 100644 --- a/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java +++ b/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java @@ -20,8 +20,8 @@ public abstract class DaoImp implements Dao { protected final Connection connection; /** - * @param connection The Database Connection to use - * @implSpec The Connection should be Received from the {@link ConnectionBuilder}. + * @param connection The Database {@link Connection} to use. + * @implSpec The {@link Connection} should be Received from the {@link ConnectionBuilder}. */ public DaoImp(Connection connection) { this.connection = connection; @@ -30,7 +30,7 @@ public abstract class DaoImp implements Dao { /** * Creates a new Database Entry from a Model object. * - * @param t The Model instance. + * @param t The Model-Instance. */ @Override public void create(T t) throws SQLException { @@ -41,6 +41,7 @@ public abstract class DaoImp implements Dao { * Read a Database Entry to a Model object. * * @param id The ID of the Element in the Database. + * @return the Model-Instance of type {@link T}, which was read. */ @Override public T read(int id) throws SQLException { @@ -54,6 +55,8 @@ public abstract class DaoImp implements Dao { /** * Read all Database Entries to a {@link List} of Model objects. + * + * @return a {@link List} of Type {@link T} holding all Database Entries as Model-Instances. */ @Override public List readAll() throws SQLException { @@ -63,7 +66,7 @@ public abstract class DaoImp implements Dao { /** * Update the Database according to the Values of the Model object. * - * @param t The Model instance. + * @param t The Model-Instance. */ @Override public void update(T t) throws SQLException { @@ -80,17 +83,53 @@ public abstract class DaoImp implements Dao { getDeleteStatement(id).executeUpdate(); } + /** + * @param result The {@link ResultSet} from execution of the Statement received from {@link #getReadByIDStatement}. + * @return The Model-Instance of Type {@link T}. + * @implSpec This will be called in {@link #read}. + */ protected abstract T getInstanceFromResultSet(ResultSet result) throws SQLException; - protected abstract List getListFromResultSet(ResultSet result) throws SQLException; - - protected abstract PreparedStatement getCreateStatement(T t) throws SQLException; - + /** + * @param id The ID of the Database Entry to read. + * @return A {@link PreparedStatement} to read a Specific Entry by its ID. + * @implSpec This will be called in {@link #read}. + * The Output of the Execution will be used in {@link #getInstanceFromResultSet}. + */ protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException; + /** + * @param result The {@link ResultSet} from execution of the Statement received from {@link #getReadAllStatement}. + * @return A {@link List} of Type {@link T} Holding All Database Entries as Model-Instances. + * @implSpec This will be called in {@link #readAll}. + */ + protected abstract List getListFromResultSet(ResultSet result) throws SQLException; + + /** + * @return A {@link PreparedStatement} to read all Entries of this Model. + * @implSpec This will be called in {@link #readAll}. + * The Output of the Execution will be used in {@link #getListFromResultSet}. + */ protected abstract PreparedStatement getReadAllStatement() throws SQLException; + /** + * @param t The Model-Instance of Type {@link T} for which an Entry should be created. + * @return a {@link PreparedStatement} which can be used to create a new Database Entry for the Model-Instance. + * @implSpec This will be called in {@link #create}. + */ + protected abstract PreparedStatement getCreateStatement(T t) throws SQLException; + + /** + * @param t The Model-Instance of Type {@link T} for which the Entry should be updated. + * @return a {@link PreparedStatement} which can be used to update the Database Entry for the Model-Instance. + * @implSpec This will be called in {@link #update}. + */ protected abstract PreparedStatement getUpdateStatement(T t) throws SQLException; + /** + * @param id The ID of the Database Entry which should be Deleted. + * @return a {@link PreparedStatement} which can be used to delete the Database Entry. + * @implSpec This will be called in {@link #delete}. + */ protected abstract PreparedStatement getDeleteStatement(int id) throws SQLException; }