Skip to content

Commit acd7507

Browse files
author
zhangrongfan
committed
Try to fix
1 parent 22c8a24 commit acd7507

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

mybatis-boost-core/src/main/java/cn/mybatisboost/support/Property.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package cn.mybatisboost.support;
22

3-
import java.util.NoSuchElementException;
43
import java.util.Objects;
54
import java.util.function.Consumer;
65
import java.util.function.Supplier;
76

87
public class Property<T> {
98

10-
private static final Property<?> EMPTY = new Property<>();
119
private final T value;
1210

1311
private Property() {
@@ -18,23 +16,11 @@ private Property(T value) {
1816
this.value = Objects.requireNonNull(value);
1917
}
2018

21-
@SuppressWarnings("unchecked")
22-
public static <T> Property<T> empty() {
23-
return (Property<T>) EMPTY;
24-
}
25-
2619
public static <T> Property<T> of(T value) {
2720
return new Property<>(value);
2821
}
2922

30-
public static <T> Property<T> ofNullable(T value) {
31-
return value == null ? empty() : of(value);
32-
}
33-
3423
public T get() {
35-
if (value == null) {
36-
throw new NoSuchElementException("No value present");
37-
}
3824
return value;
3925
}
4026

mybatis-boost-test/src/test/java/cn/mybatisboost/test/CrudMapperTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.mybatisboost.test;
22

3-
import cn.mybatisboost.support.Property;
43
import cn.mybatisboost.util.SafeProperty;
54
import org.apache.ibatis.session.RowBounds;
65
import org.junit.After;
@@ -126,7 +125,7 @@ public void selectNullable() {
126125
public void insert() {
127126
try {
128127
assertEquals(1, mapper.insert(new Project(null, "mybatis-boost",
129-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty())));
128+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null)));
130129
fail();
131130
} catch (Exception ignored) {
132131
// normally, exception would happen because "group_id" column is declared NOT NULL
@@ -138,7 +137,7 @@ public void batchInsert() {
138137
try {
139138
assertEquals(1, mapper.batchInsert(Collections.singletonList(
140139
new Project(null, "mybatis-boost",
141-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty()))));
140+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null))));
142141
fail();
143142
} catch (Exception ignored) {
144143
// normally, exception would happen because "group_id" column is declared NOT NULL
@@ -148,7 +147,7 @@ public void batchInsert() {
148147
@Test
149148
public void insertSelective() {
150149
assertEquals(1, mapper.insertSelective(new Project("cn.mybatisboost", "mybatis-boost",
151-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty())));
150+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null)));
152151
jdbcTemplate.query("select * from project", resultSet -> {
153152
assertEquals(1, resultSet.getRow());
154153
});
@@ -158,7 +157,7 @@ public void insertSelective() {
158157
public void batchInsertSelective() {
159158
assertEquals(1, mapper.batchInsertSelective(Collections.singletonList(
160159
new Project("cn.mybatisboost", "mybatis-boost",
161-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty()))));
160+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null))));
162161
jdbcTemplate.query("select * from project", resultSet -> {
163162
assertEquals(1, resultSet.getRow());
164163
});

mybatis-boost-test/src/test/java/cn/mybatisboost/test/EnhancementTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.mybatisboost.test;
22

3-
import cn.mybatisboost.support.Property;
43
import org.junit.After;
54
import org.junit.Test;
65
import org.junit.runner.RunWith;
@@ -61,7 +60,7 @@ public void selectOneFromT() {
6160
public void insertSome() {
6261
assertEquals(1, mapper.insertSome(Collections.singletonList(new Project(
6362
"cn.mybatisboost", "mybatis-boost",
64-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty()))));
63+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null))));
6564
jdbcTemplate.query("select * from project", resultSet -> {
6665
assertEquals(1, resultSet.getRow());
6766
assertEquals("cn.mybatisboost", resultSet.getString("group_id"));
@@ -72,7 +71,7 @@ public void insertSome() {
7271
@Test
7372
public void insertOne1() {
7473
assertEquals(1, mapper.insertOne1(new Project("cn.mybatisboost", "mybatis-boost",
75-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty())));
74+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null)));
7675
jdbcTemplate.query("select * from project", resultSet -> {
7776
assertEquals(1, resultSet.getRow());
7877
assertEquals("cn.mybatisboost", resultSet.getString("group_id"));
@@ -83,7 +82,7 @@ public void insertOne1() {
8382
@Test
8483
public void insertOne2() {
8584
assertEquals(1, mapper.insertOne2(new Project("cn.mybatisboost", "mybatis-boost",
86-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty())));
85+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null)));
8786
jdbcTemplate.query("select * from project", resultSet -> {
8887
assertEquals(1, resultSet.getRow());
8988
assertEquals("cn.mybatisboost", resultSet.getString("group_id"));
@@ -106,7 +105,7 @@ public void updateGroupId() {
106105
public void updateNotGroupId() {
107106
jdbcTemplate.execute("insert into project (group_id) values ('cn.mybatisboost1')");
108107
assertEquals(1, mapper.updateNotGroupId(new Project("cn.mybatisboost", "mybatis-boost",
109-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty())));
108+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null)));
110109
jdbcTemplate.query("select * from project", resultSet -> {
111110
assertEquals(1, resultSet.getRow());
112111
assertEquals("cn.mybatisboost1", resultSet.getString("group_id"));
@@ -121,7 +120,7 @@ public void updateNotGroupId() {
121120
public void updateAll() {
122121
jdbcTemplate.execute("insert into project (group_id) values ('cn.mybatisboost1')");
123122
assertEquals(1, mapper.updateAll(new Project("cn.mybatisboost", "mybatis-boost",
124-
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", Property.empty())));
123+
"MIT", "https://github.com/zhang-rf/mybatis-boost", "zhangrongfan", null)));
125124
jdbcTemplate.query("select * from project", resultSet -> {
126125
assertEquals(1, resultSet.getRow());
127126
assertEquals("cn.mybatisboost", resultSet.getString("group_id"));

0 commit comments

Comments
 (0)