Skip to content

Commit 7c4fbd0

Browse files
author
ct
committed
keep the code style consistent with Maves in BaseBuilder
1 parent c3e1543 commit 7c4fbd0

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

src/main/java/org/apache/ibatis/builder/BaseBuilder.java

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,56 +64,41 @@ protected Set<String> stringSetValueOf(String value, String defaultValue) {
6464
}
6565

6666
protected JdbcType resolveJdbcType(String alias) {
67-
if (alias == null) {
68-
return null;
69-
}
7067
try {
71-
return JdbcType.valueOf(alias);
68+
return alias == null ? null : JdbcType.valueOf(alias);
7269
} catch (IllegalArgumentException e) {
7370
throw new BuilderException("Error resolving JdbcType. Cause: " + e, e);
7471
}
7572
}
7673

7774
protected ResultSetType resolveResultSetType(String alias) {
78-
if (alias == null) {
79-
return null;
80-
}
8175
try {
82-
return ResultSetType.valueOf(alias);
76+
return alias == null ? null : ResultSetType.valueOf(alias);
8377
} catch (IllegalArgumentException e) {
8478
throw new BuilderException("Error resolving ResultSetType. Cause: " + e, e);
8579
}
8680
}
8781

8882
protected ParameterMode resolveParameterMode(String alias) {
89-
if (alias == null) {
90-
return null;
91-
}
9283
try {
93-
return ParameterMode.valueOf(alias);
84+
return alias == null ? null : ParameterMode.valueOf(alias);
9485
} catch (IllegalArgumentException e) {
9586
throw new BuilderException("Error resolving ParameterMode. Cause: " + e, e);
9687
}
9788
}
9889

9990
protected Object createInstance(String alias) {
10091
Class<?> clazz = resolveClass(alias);
101-
if (clazz == null) {
102-
return null;
103-
}
10492
try {
105-
return clazz.getDeclaredConstructor().newInstance();
93+
return clazz == null ? null : clazz.getDeclaredConstructor().newInstance();
10694
} catch (Exception e) {
10795
throw new BuilderException("Error creating instance. Cause: " + e, e);
10896
}
10997
}
11098

11199
protected <T> Class<? extends T> resolveClass(String alias) {
112-
if (alias == null) {
113-
return null;
114-
}
115100
try {
116-
return resolveAlias(alias);
101+
return alias == null ? null : resolveAlias(alias);
117102
} catch (Exception e) {
118103
throw new BuilderException("Error resolving class. Cause: " + e, e);
119104
}
@@ -139,11 +124,8 @@ protected TypeHandler<?> resolveTypeHandler(Class<?> javaType, Class<? extends T
139124
}
140125
// javaType ignored for injected handlers see issue #746 for full detail
141126
TypeHandler<?> handler = typeHandlerRegistry.getMappingTypeHandler(typeHandlerType);
142-
if (handler == null) {
143-
// not in registry, create a new one
144-
handler = typeHandlerRegistry.getInstance(javaType, typeHandlerType);
145-
}
146-
return handler;
127+
// if handler not in registry, create a new one, otherwise return directly
128+
return handler == null ? typeHandlerRegistry.getInstance(javaType, typeHandlerType) : handler;
147129
}
148130

149131
protected <T> Class<? extends T> resolveAlias(String alias) {

src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private Properties settingsAsProperties(XNode context) {
152152

153153
private void loadCustomVfs(Properties props) throws ClassNotFoundException {
154154
String value = props.getProperty("vfsImpl");
155-
if(value == null) {
155+
if (value == null) {
156156
return;
157157
}
158158
String[] clazzes = value.split(",");
@@ -171,7 +171,7 @@ private void loadCustomLogImpl(Properties props) {
171171
}
172172

173173
private void typeAliasesElement(XNode context) {
174-
if(context == null) {
174+
if (context == null) {
175175
return;
176176
}
177177
for (XNode child : context.getChildren()) {
@@ -200,7 +200,8 @@ private void pluginElement(XNode context) throws Exception {
200200
for (XNode child : context.getChildren()) {
201201
String interceptor = child.getStringAttribute("interceptor");
202202
Properties properties = child.getChildrenAsProperties();
203-
Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).getDeclaredConstructor().newInstance();
203+
Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).getDeclaredConstructor()
204+
.newInstance();
204205
interceptorInstance.setProperties(properties);
205206
configuration.addInterceptor(interceptorInstance);
206207
}
@@ -234,7 +235,7 @@ private void reflectorFactoryElement(XNode context) throws Exception {
234235
}
235236

236237
private void propertiesElement(XNode context) throws Exception {
237-
if(context == null) {
238+
if (context == null) {
238239
return;
239240
}
240241
Properties defaults = context.getChildrenAsProperties();

0 commit comments

Comments
 (0)