Skip to content

Commit 9a4cf96

Browse files
committed
Convert one-line methods (i.e. almost everything) to expression bodies, to be more idiomatic.
Also removed incorrect `@throws` from documentation
1 parent 0e27c24 commit 9a4cf96

File tree

3 files changed

+13
-42
lines changed

3 files changed

+13
-42
lines changed

DbSetup-kotlin/src/main/kotlin/com/ninja_squad/dbsetup_kotlin/DbSetup.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ import com.ninja_squad.dbsetup.DbSetupTracker
5050
*
5151
* @author JB Nizet
5252
*/
53-
fun DbSetup.launchWith(tracker: DbSetupTracker) {
54-
tracker.launchIfNecessary(this)
55-
}
53+
fun DbSetup.launchWith(tracker: DbSetupTracker) = tracker.launchIfNecessary(this)

DbSetup-kotlin/src/main/kotlin/com/ninja_squad/dbsetup_kotlin/DbSetupBuilder.kt

+11-36
Original file line numberDiff line numberDiff line change
@@ -70,90 +70,65 @@ class DbSetupBuilder(private val to: Destination, var binderConfiguration: Binde
7070
* Adds a DeleteAll operation to the DbSetup
7171
* @param table the table to delete from
7272
*/
73-
fun deleteAllFrom(table: String) {
74-
execute(Operations.deleteAllFrom(table))
75-
}
73+
fun deleteAllFrom(table: String) = execute(Operations.deleteAllFrom(table))
7674

7775
/**
7876
* Adds DeleteAll operations to the DbSetup
7977
* @param tables the tables to delete from
8078
*/
81-
fun deleteAllFrom(vararg tables: String) {
82-
execute(Operations.deleteAllFrom(*tables))
83-
}
79+
fun deleteAllFrom(vararg tables: String) = execute(Operations.deleteAllFrom(*tables))
8480

8581
/**
8682
* Adds DeleteAll operations to the DbSetup
8783
* @param tables the tables to delete from
8884
*/
89-
fun deleteAllFrom(tables: List<String>) {
90-
execute(Operations.deleteAllFrom(tables))
91-
}
85+
fun deleteAllFrom(tables: List<String>) = execute(Operations.deleteAllFrom(tables))
9286

9387
/**
9488
* Adds a Truncate operation to the DbSetup
9589
* @param table the table to truncate
9690
*/
97-
fun truncate(table: String) {
98-
execute(Operations.truncate(table))
99-
}
91+
fun truncate(table: String) = execute(Operations.truncate(table))
10092

10193
/**
10294
* Adds Truncate operations to the DbSetup
10395
* @param tables the tables to delete from
10496
*/
105-
fun truncate(vararg tables: String) {
106-
execute(Operations.truncate(*tables))
107-
}
97+
fun truncate(vararg tables: String) = execute(Operations.truncate(*tables))
10898

10999
/**
110100
* Adds Truncate operations to the DbSetup
111101
* @param tables the tables to truncate
112102
*/
113-
fun truncate(tables: List<String>) {
114-
execute(Operations.truncate(tables))
115-
}
103+
fun truncate(tables: List<String>) = execute(Operations.truncate(tables))
116104

117105
/**
118106
* Adds a SqlOperation to the DbSetup
119107
* @param statement the SQL statement to execute
120108
*/
121-
fun sql(statement: String) {
122-
execute(Operations.sql(statement))
123-
}
109+
fun sql(statement: String) = execute(Operations.sql(statement))
124110

125111
/**
126112
* Adds SqlOperations to the DbSetup
127113
* @param statements the SQL statements to execute
128114
*/
129-
fun sql(vararg statements: String) {
130-
execute(Operations.sql(*statements))
131-
}
115+
fun sql(vararg statements: String) = execute(Operations.sql(*statements))
132116

133117
/**
134118
* Adds SqlOperations to the DbSetup
135119
* @param statements the SQL statements to execute
136120
*/
137-
fun sql(statements: List<String>) {
138-
execute(Operations.sql(statements))
139-
}
121+
fun sql(statements: List<String>) = execute(Operations.sql(statements))
140122

141123
/**
142124
* Adds an operation to the DbSetup. Custom extension functions typically delegate to this method to
143125
* add the operation they want.
144126
* @param operation the operation to add
145127
*/
146-
fun execute(operation: Operation) {
147-
operations.add(operation)
148-
}
128+
fun execute(operation: Operation) = operations.add(operation)
149129

150130
/**
151131
* Builds the DbSetup. This method is called by the dbSetup function after the builder has been configured.
152-
* @throws IllegalStateException if the destination has not been set
153132
*/
154-
internal fun build(): DbSetup {
155-
return DbSetup(to,
156-
Operations.sequenceOf(operations),
157-
binderConfiguration)
158-
}
133+
internal fun build() = DbSetup(to, Operations.sequenceOf(operations), binderConfiguration)
159134
}

DbSetup-kotlin/src/main/kotlin/com/ninja_squad/dbsetup_kotlin/Insert.Builder.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,4 @@ fun Insert.Builder.mappedValues(vararg entries: Pair<String, Any?>): Insert.Buil
106106
*
107107
* @author JB Nizet
108108
*/
109-
fun Insert.Builder.repeatingMappedValues(vararg entries: Pair<String, Any?>): Insert.RowRepeater {
110-
return this.repeatingValues(mapOf(*entries))
111-
}
109+
fun Insert.Builder.repeatingMappedValues(vararg entries: Pair<String, Any?>) = this.repeatingValues(mapOf(*entries))

0 commit comments

Comments
 (0)