Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dca3927

Browse files
committedMay 12, 2024·
add javadoc
1 parent 30caa3b commit dca3927

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎active-record/src/main/java/com/iluwatar/activerecord/base/RecordBase.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ protected static Connection getConnection() {
101101
/**
102102
* Find all the records for a corresponding domain model.
103103
*
104+
* @param clazz the record class.
105+
* @param <T> the record type.
104106
* @return all the domain model related records.
105107
*/
106108
public static <T extends RecordBase> List<T> findAll(Class<T> clazz) {
@@ -126,7 +128,9 @@ public static <T extends RecordBase> List<T> findAll(Class<T> clazz) {
126128
/**
127129
* Find a domain model by its ID.
128130
*
129-
* @param id domain model identifier.
131+
* @param id domain model identifier.
132+
* @param clazz the record class.
133+
* @param <T> the record type.
130134
* @return the domain model.
131135
*/
132136
public static <T extends RecordBase> Optional<T> findById(Long id, Class<T> clazz) {
@@ -151,6 +155,13 @@ public static <T extends RecordBase> Optional<T> findById(Long id, Class<T> claz
151155
}
152156
}
153157

158+
/**
159+
* Delete the record by its unique identifier.
160+
*
161+
* @param id the record identifier.
162+
* @param clazz the record class.
163+
* @param <T> the record type.
164+
*/
154165
public static <T extends RecordBase> void delete(Long id, Class<T> clazz) {
155166
String deleteStatement = Query
156167
.deleteFrom(getDeclaredClassInstance(clazz).getTableName())
@@ -168,6 +179,9 @@ public static <T extends RecordBase> void delete(Long id, Class<T> clazz) {
168179

169180
/**
170181
* Save the record.
182+
*
183+
* @param clazz the record class.
184+
* @param <T> the record type.
171185
*/
172186
public <T extends RecordBase> void save(Class<T> clazz) {
173187
try (Connection connection = getConnection();
@@ -184,6 +198,13 @@ public <T extends RecordBase> void save(Class<T> clazz) {
184198

185199
protected abstract void setPreparedStatementParams(PreparedStatement pstmt) throws SQLException;
186200

201+
/**
202+
* Constructs an insertion query based on the descending type's fields.
203+
*
204+
* @param clazz the record class.
205+
* @param <T> the record type.
206+
* @return a full insert query.
207+
*/
187208
protected static <T extends RecordBase> String constructInsertionQuery(Class<T> clazz) {
188209
List<Object> arguments = new ArrayList<>();
189210
try {

0 commit comments

Comments
 (0)
Please sign in to comment.