Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc007ca9

Browse files
authored
Merge pull request#59 from Pazus/feature/cleanup
Cleanup base on IDEA Code Inspector and small refactoring
2 parents9c7f855 +141215a commitc007ca9

File tree

33 files changed

+161
-206
lines changed

33 files changed

+161
-206
lines changed

‎src/main/java/org/utplsql/api/DBHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
packageorg.utplsql.api;
22

33
importoracle.jdbc.OracleTypes;
4-
importorg.utplsql.api.exception.DatabaseNotCompatibleException;
54
importorg.utplsql.api.exception.UtPLSQLNotInstalledException;
65

76
importjava.sql.*;

‎src/main/java/org/utplsql/api/EnvironmentVariableUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
publicclassEnvironmentVariableUtil {
2020

21+
privateEnvironmentVariableUtil() {}
22+
2123
/**
2224
* Returns the value for a given key from environment (see class description)
2325
*
@@ -43,4 +45,6 @@ public static String getEnvValue(String key, String defaultValue) {
4345

4446
returnval;
4547
}
48+
49+
4650
}

‎src/main/java/org/utplsql/api/FileMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static Array buildFileMappingArray(
2020
Connectionconn,FileMapperOptionsmapperOptions)throwsSQLException {
2121
OracleConnectionoraConn =conn.unwrap(OracleConnection.class);
2222

23-
MaptypeMap =conn.getTypeMap();
23+
Map<String,Class<?>>typeMap =conn.getTypeMap();
2424
typeMap.put(CustomTypes.UT_FILE_MAPPING,FileMapping.class);
2525
typeMap.put(CustomTypes.UT_KEY_VALUE_PAIR,KeyValuePair.class);
2626
conn.setTypeMap(typeMap);

‎src/main/java/org/utplsql/api/FileMapping.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,42 @@ public class FileMapping implements SQLData {
1717

1818
publicFileMapping() {}
1919

20+
publicFileMapping(StringfileName,StringobjectOwner,StringobjectName,StringobjectType) {
21+
this.fileName =fileName;
22+
this.objectOwner =objectOwner;
23+
this.objectName =objectName;
24+
this.objectType =objectType;
25+
}
26+
2027
publicStringgetFileName() {
2128
returnfileName;
2229
}
2330

24-
publicvoidsetFileName(StringfileName) {
31+
privatevoidsetFileName(StringfileName) {
2532
this.fileName =fileName;
2633
}
2734

2835
publicStringgetObjectOwner() {
2936
returnobjectOwner;
3037
}
3138

32-
publicvoidsetObjectOwner(StringobjectOwner) {
39+
privatevoidsetObjectOwner(StringobjectOwner) {
3340
this.objectOwner =objectOwner;
3441
}
3542

3643
publicStringgetObjectName() {
3744
returnobjectName;
3845
}
3946

40-
publicvoidsetObjectName(StringobjectName) {
47+
privatevoidsetObjectName(StringobjectName) {
4148
this.objectName =objectName;
4249
}
4350

4451
publicStringgetObjectType() {
4552
returnobjectType;
4653
}
4754

48-
publicvoidsetObjectType(StringobjectType) {
55+
privatevoidsetObjectType(StringobjectType) {
4956
this.objectType =objectType;
5057
}
5158

‎src/main/java/org/utplsql/api/JavaApiVersionInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
publicclassJavaApiVersionInfo {
99

10+
privateJavaApiVersionInfo() { }
11+
1012
privatestaticfinalStringBUILD_NO ="123";
1113
privatestaticfinalStringMAVEN_PROJECT_NAME ="utPLSQL-java-api";
1214
privatestaticfinalStringMAVEN_PROJECT_VERSION ="3.1.1-SNAPSHOT";

‎src/main/java/org/utplsql/api/KeyValuePair.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,30 @@ public String getKey() {
2222
returnkey;
2323
}
2424

25-
publicvoidsetKey(Stringkey) {
26-
this.key =key;
27-
}
28-
2925
publicStringgetValue() {
3026
returnvalue;
3127
}
3228

33-
publicvoidsetValue(Stringvalue) {
34-
this.value =value;
35-
}
36-
3729
@Override
3830
publicStringgetSQLTypeName()throwsSQLException {
3931
returnCustomTypes.UT_KEY_VALUE_PAIR;
4032
}
4133

4234
@Override
4335
publicvoidreadSQL(SQLInputstream,StringtypeName)throwsSQLException {
44-
setKey(stream.readString());
45-
setValue(stream.readString());
36+
key =stream.readString();
37+
value =stream.readString();
4638
}
4739

4840
@Override
4941
publicvoidwriteSQL(SQLOutputstream)throwsSQLException {
50-
stream.writeString(getKey());
51-
stream.writeString(getValue());
42+
stream.writeString(key);
43+
stream.writeString(value);
5244
}
5345

5446
@Override
5547
publicStringtoString() {
56-
returnString.format("%s => %s",getKey(),getValue());
48+
returnString.format("%s => %s",key,value);
5749
}
5850

5951
}

‎src/main/java/org/utplsql/api/ResourceUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
publicclassResourceUtil {
2323

24+
privateResourceUtil() {}
25+
2426
/**
2527
* Returns the Path to a resource so it is walkable no matter if it's inside a jar or on the file system
2628
*

‎src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
packageorg.utplsql.api;
22

3-
importoracle.jdbc.OracleConnection;
43
importorg.utplsql.api.compatibility.CompatibilityProxy;
54
importorg.utplsql.api.exception.DatabaseNotCompatibleException;
65
importorg.utplsql.api.exception.SomeTestsFailedException;
@@ -10,7 +9,6 @@
109
importorg.utplsql.api.reporter.ReporterFactory;
1110
importorg.utplsql.api.testRunner.TestRunnerStatement;
1211

13-
importjava.sql.CallableStatement;
1412
importjava.sql.Connection;
1513
importjava.sql.SQLException;
1614
importjava.util.ArrayList;
@@ -24,18 +22,18 @@
2422
*/
2523
publicclassTestRunner {
2624

27-
privateTestRunnerOptionsoptions =newTestRunnerOptions();
25+
privatefinalTestRunnerOptionsoptions =newTestRunnerOptions();
2826
privateCompatibilityProxycompatibilityProxy;
2927
privateReporterFactoryreporterFactory;
30-
privateList<String>reporterNames =newArrayList<>();
28+
privatefinalList<String>reporterNames =newArrayList<>();
3129

3230
publicTestRunneraddPath(Stringpath) {
3331
options.pathList.add(path);
3432
returnthis;
3533
}
3634

3735
publicTestRunneraddPathList(List<String>paths) {
38-
if (options.pathList !=null)options.pathList.addAll(paths);
36+
options.pathList.addAll(paths);
3937
returnthis;
4038
}
4139

@@ -115,7 +113,7 @@ public TestRunner setReporterFactory( ReporterFactory reporterFactory ) {
115113

116114
privatevoiddelayedAddReporters() {
117115
if (reporterFactory !=null )
118-
reporterNames.stream().forEach(this::addReporter );
116+
reporterNames.forEach(this::addReporter );
119117
else
120118
thrownewIllegalStateException("ReporterFactory must be set to add delayed Reporters!");
121119
}
@@ -142,13 +140,8 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException,
142140
options.reporterList.add(newDocumentationReporter().init(conn));
143141
}
144142

145-
TestRunnerStatementtestRunnerStatement =null;
146-
147-
try {
148-
DBHelper.enableDBMSOutput(conn);
149-
150-
testRunnerStatement =compatibilityProxy.getTestRunnerStatement(options,conn);
151-
143+
DBHelper.enableDBMSOutput(conn);
144+
try(TestRunnerStatementtestRunnerStatement =compatibilityProxy.getTestRunnerStatement(options,conn)) {
152145
testRunnerStatement.execute();
153146
}catch (SQLExceptione) {
154147
if (e.getErrorCode() ==SomeTestsFailedException.ERROR_CODE) {
@@ -161,10 +154,6 @@ else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
161154
throwe;
162155
}
163156
}finally {
164-
if (testRunnerStatement !=null) {
165-
testRunnerStatement.close();
166-
}
167-
168157
DBHelper.disableDBMSOutput(conn);
169158
}
170159
}

‎src/main/java/org/utplsql/api/TestRunnerOptions.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
importorg.utplsql.api.reporter.Reporter;
44

55
importjava.nio.charset.Charset;
6-
importjava.nio.charset.StandardCharsets;
76
importjava.util.ArrayList;
87
importjava.util.List;
98

@@ -12,14 +11,14 @@
1211
* @author pesse
1312
*/
1413
publicclassTestRunnerOptions {
15-
publicList<String>pathList =newArrayList<>();
16-
publicList<Reporter>reporterList =newArrayList<>();
14+
publicfinalList<String>pathList =newArrayList<>();
15+
publicfinalList<Reporter>reporterList =newArrayList<>();
1716
publicbooleancolorConsole =false;
18-
publicList<String>coverageSchemes =newArrayList<>();
19-
publicList<String>sourceFiles =newArrayList<>();
20-
publicList<String>testFiles =newArrayList<>();
21-
publicList<String>includeObjects =newArrayList<>();
22-
publicList<String>excludeObjects =newArrayList<>();
17+
publicfinalList<String>coverageSchemes =newArrayList<>();
18+
publicfinalList<String>sourceFiles =newArrayList<>();
19+
publicfinalList<String>testFiles =newArrayList<>();
20+
publicfinalList<String>includeObjects =newArrayList<>();
21+
publicfinalList<String>excludeObjects =newArrayList<>();
2322
publicFileMapperOptionssourceMappingOptions;
2423
publicFileMapperOptionstestMappingOptions;
2524
publicbooleanfailOnErrors =false;

‎src/main/java/org/utplsql/api/Version.java

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,52 @@
1010
* @author pesse
1111
*/
1212
publicclassVersionimplementsComparable<Version> {
13-
privateStringorigString;
14-
privateIntegermajor;
15-
privateIntegerminor;
16-
privateIntegerbugfix;
17-
privateIntegerbuild;
18-
privatebooleanvalid =false;
13+
privatefinalStringorigString;
14+
privatefinalIntegermajor;
15+
privatefinalIntegerminor;
16+
privatefinalIntegerbugfix;
17+
privatefinalIntegerbuild;
18+
privatefinalbooleanvalid;
1919

2020
publicVersion(StringversionString ) {
2121
assertversionString !=null;
22-
this.origString =versionString;
23-
parseVersionString();
24-
}
22+
this.origString =versionString.trim();
2523

26-
privatevoidparseVersionString()
27-
{
2824
Patternp =Pattern.compile("([0-9]+)\\.?([0-9]+)?\\.?([0-9]+)?\\.?([0-9]+)?");
2925

3026
Matcherm =p.matcher(origString);
3127

28+
Integermajor =null;
29+
Integerminor =null;
30+
Integerbugfix =null;
31+
Integerbuild =null;
32+
booleanvalid =false;
33+
3234
try {
3335
if (m.find()) {
34-
if (m.group(1) !=null )
36+
if (m.group(1) !=null )
3537
major =Integer.valueOf(m.group(1));
36-
if (m.group(2) !=null )
38+
if (m.group(2) !=null )
3739
minor =Integer.valueOf(m.group(2));
38-
if (m.group(3) !=null )
40+
if (m.group(3) !=null )
3941
bugfix =Integer.valueOf(m.group(3));
40-
if (m.group(4) !=null )
42+
if (m.group(4) !=null )
4143
build =Integer.valueOf(m.group(4));
4244

43-
if (major !=null )// We need a valid major version as minimum requirement for a Version object to be valid
44-
valid =true;
45+
// We need a valid major version as minimum requirement for a Version object to be valid
46+
valid =major !=null;
4547
}
4648
}
4749
catch (NumberFormatExceptione )
4850
{
4951
valid =false;
5052
}
53+
54+
this.major =major;
55+
this.minor =minor;
56+
this.bugfix =bugfix;
57+
this.build =build;
58+
this.valid =valid;
5159
}
5260

5361
@Override
@@ -85,11 +93,11 @@ public String getNormalizedString()
8593
StringBuildersb =newStringBuilder();
8694
sb.append(String.valueOf(major));
8795
if (minor !=null )
88-
sb.append("." +String.valueOf(minor));
96+
sb.append(".").append(String.valueOf(minor));
8997
if (bugfix !=null )
90-
sb.append("." +String.valueOf(bugfix));
98+
sb.append(".").append(String.valueOf(bugfix));
9199
if (build !=null )
92-
sb.append("." +String.valueOf(build));
100+
sb.append(".").append(String.valueOf(build));
93101

94102
returnsb.toString();
95103
}
@@ -152,41 +160,29 @@ public boolean isGreaterOrEqualThan( Version v ) throws InvalidVersionException
152160

153161
versionsAreValid(v);
154162

155-
if (compareTo(v) >=0 )
156-
returntrue;
157-
else
158-
returnfalse;
163+
returncompareTo(v) >=0;
159164
}
160165

161166

162167
publicbooleanisGreaterThan(Versionv)throwsInvalidVersionException
163168
{
164169
versionsAreValid(v);
165170

166-
if (compareTo(v) >0 )
167-
returntrue;
168-
else
169-
returnfalse;
171+
returncompareTo(v) >0;
170172
}
171173

172174
publicbooleanisLessOrEqualThan(Versionv )throwsInvalidVersionException
173175
{
174176

175177
versionsAreValid(v);
176178

177-
if (compareTo(v) <=0 )
178-
returntrue;
179-
else
180-
returnfalse;
179+
returncompareTo(v) <=0;
181180
}
182181

183182
publicbooleanisLessThan(Versionv)throwsInvalidVersionException
184183
{
185184
versionsAreValid(v);
186185

187-
if (compareTo(v) <0 )
188-
returntrue;
189-
else
190-
returnfalse;
186+
returncompareTo(v) <0;
191187
}
192188
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp