Skip to content

Commit 9d5bb76

Browse files
authored
Merge pull request #10 from nmalygin-com/9
#9: implemented time arguments
2 parents 022350b + 741cfae commit 9d5bb76

File tree

6 files changed

+220
-2
lines changed

6 files changed

+220
-2
lines changed

pmd-ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</description>
88
<rule ref="category/java/bestpractices.xml">
99
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
10+
<exclude name="ImplicitFunctionalInterface"/>
1011
</rule>
1112
<rule ref="category/java/codestyle.xml">
1213
<exclude name="CommentDefaultAccessModifier"/>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SOFTWARE.
2929

3030
<groupId>com.nmalygin</groupId>
3131
<artifactId>superb-jdbc</artifactId>
32-
<version>0.0.6-SNAPSHOT</version>
32+
<version>0.0.6</version>
3333
<packaging>jar</packaging>
3434

3535
<name>Superb JDBC</name>
@@ -117,7 +117,7 @@ SOFTWARE.
117117
<plugin>
118118
<groupId>org.apache.maven.plugins</groupId>
119119
<artifactId>maven-pmd-plugin</artifactId>
120-
<version>3.24.0</version>
120+
<version>3.27.0</version>
121121
<executions>
122122
<execution>
123123
<phase>package</phase>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2025 Nikolai Malygin
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
package com.nmalygin.superb.jdbc.api.arguments;
26+
27+
import com.nmalygin.superb.jdbc.api.Argument;
28+
29+
import java.sql.Date;
30+
import java.sql.PreparedStatement;
31+
import java.sql.SQLException;
32+
import java.time.LocalDate;
33+
34+
/**
35+
* A date argument
36+
*
37+
* @author Nikolai Malygin
38+
*/
39+
public final class DateArgument implements Argument {
40+
41+
private final Date value;
42+
43+
/**
44+
* @param value LocalDate value
45+
*/
46+
public DateArgument(final LocalDate value) {
47+
if (value == null) {
48+
this.value = null;
49+
} else {
50+
this.value = Date.valueOf(value);
51+
}
52+
}
53+
54+
@Override
55+
public void pass(final PreparedStatement preparedStatement, final int position) throws SQLException {
56+
preparedStatement.setDate(position, value);
57+
}
58+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2025 Nikolai Malygin
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
package com.nmalygin.superb.jdbc.api.arguments;
26+
27+
import com.nmalygin.superb.jdbc.api.Argument;
28+
29+
import java.sql.PreparedStatement;
30+
import java.sql.SQLException;
31+
32+
/**
33+
* The null argument
34+
*
35+
* @author Nikolai Malygin
36+
*/
37+
@SuppressWarnings("PMD.AtLeastOneConstructor")
38+
public final class NullArgument implements Argument {
39+
@Override
40+
public void pass(final PreparedStatement preparedStatement, final int position) throws SQLException {
41+
preparedStatement.setNull(position, java.sql.Types.NULL);
42+
}
43+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2025 Nikolai Malygin
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
package com.nmalygin.superb.jdbc.api.arguments;
26+
27+
import com.nmalygin.superb.jdbc.api.Argument;
28+
29+
import java.sql.PreparedStatement;
30+
import java.sql.SQLException;
31+
import java.sql.Time;
32+
import java.time.LocalTime;
33+
34+
/**
35+
* A time argument
36+
*
37+
* @author Nikolai Malygin
38+
*/
39+
public final class TimeArgument implements Argument {
40+
41+
private final Time value;
42+
43+
/**
44+
* @param value LocalTime value
45+
*/
46+
public TimeArgument(final LocalTime value) {
47+
if (value == null) {
48+
this.value = null;
49+
} else {
50+
this.value = Time.valueOf(value);
51+
}
52+
}
53+
54+
@Override
55+
public void pass(final PreparedStatement preparedStatement, final int position) throws SQLException {
56+
preparedStatement.setTime(position, value);
57+
}
58+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2025 Nikolai Malygin
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
package com.nmalygin.superb.jdbc.api.arguments;
26+
27+
import com.nmalygin.superb.jdbc.api.Argument;
28+
29+
import java.sql.PreparedStatement;
30+
import java.sql.SQLException;
31+
import java.sql.Timestamp;
32+
import java.time.Instant;
33+
34+
/**
35+
* A timestamp argument
36+
*
37+
* @author Nikolai Malygin
38+
*/
39+
public final class TimestampArgument implements Argument {
40+
41+
private final Timestamp value;
42+
43+
/**
44+
* @param value Instant value
45+
*/
46+
public TimestampArgument(final Instant value) {
47+
if (value == null) {
48+
this.value = null;
49+
} else {
50+
this.value = Timestamp.from(value);
51+
}
52+
}
53+
54+
@Override
55+
public void pass(final PreparedStatement preparedStatement, final int position) throws SQLException {
56+
preparedStatement.setTimestamp(position, value);
57+
}
58+
}

0 commit comments

Comments
 (0)