Skip to content

Commit 81e0953

Browse files
committed
Reformatting
1 parent 1a984ff commit 81e0953

26 files changed

+246
-209
lines changed

Diff for: src/main/java/org/utplsql/cli/Cli.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void main(String[] args) {
1515
System.exit(exitCode);
1616
}
1717

18-
static int runPicocliWithExitCode( String[] args ) {
18+
static int runPicocliWithExitCode(String[] args) {
1919

2020
LoggerConfiguration.configure(LoggerConfiguration.ConfigLevel.NONE);
2121
LocaleInitializer.initLocale();
@@ -30,25 +30,24 @@ static int runPicocliWithExitCode( String[] args ) {
3030
List<CommandLine> parsedLines = commandLine.parse(args);
3131

3232
boolean commandWasRun = false;
33-
for ( CommandLine parsedLine : parsedLines ) {
33+
for (CommandLine parsedLine : parsedLines) {
3434
if (parsedLine.isUsageHelpRequested()) {
3535
parsedLine.usage(System.out);
3636
return 0;
37-
}
38-
else if (parsedLine.isVersionHelpRequested()) {
37+
} else if (parsedLine.isVersionHelpRequested()) {
3938
parsedLine.printVersionHelp(System.out);
4039
return 0;
4140
}
4241

4342
Object command = parsedLine.getCommand();
44-
if ( command instanceof ICommand ) {
45-
exitCode = ((ICommand)command).run();
43+
if (command instanceof ICommand) {
44+
exitCode = ((ICommand) command).run();
4645
commandWasRun = true;
4746
break;
4847
}
4948
}
5049

51-
if ( !commandWasRun ) {
50+
if (!commandWasRun) {
5251
commandLine.usage(System.out);
5352
}
5453
} catch (CommandLine.ParameterException e) {

Diff for: src/main/java/org/utplsql/cli/CliVersionInfo.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import java.io.InputStream;
88
import java.io.InputStreamReader;
99

10-
/** This class is getting updated automatically by the build process.
10+
/**
11+
* This class is getting updated automatically by the build process.
1112
* Please do not update its constants manually cause they will be overwritten.
1213
*
1314
* @author pesse
@@ -19,18 +20,22 @@ public class CliVersionInfo {
1920

2021
static {
2122
try {
22-
try ( InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-cli.version");
23-
BufferedReader reader = new BufferedReader(new InputStreamReader(in)) ) {
23+
try (InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-cli.version");
24+
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
2425
MAVEN_PROJECT_VERSION = reader.readLine();
2526
}
26-
}
27-
catch ( IOException e ) {
27+
} catch (IOException e) {
2828
System.out.println("WARNING: Could not get Version information!");
2929
}
3030
}
3131

32-
public static String getVersion() { return MAVEN_PROJECT_VERSION; }
33-
public static String getInfo() { return MAVEN_PROJECT_NAME + " " + getVersion(); }
32+
public static String getVersion() {
33+
return MAVEN_PROJECT_VERSION;
34+
}
35+
36+
public static String getInfo() {
37+
return MAVEN_PROJECT_NAME + " " + getVersion();
38+
}
3439

3540

3641
}

Diff for: src/main/java/org/utplsql/cli/ConnectionConfig.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ public class ConnectionConfig {
99
private final String password;
1010
private final String connect;
1111

12-
public ConnectionConfig( String connectString ) {
12+
public ConnectionConfig(String connectString) {
1313
Matcher m = Pattern.compile("^(\".+\"|[^/]+)/(\".+\"|[^@]+)@(.*)$").matcher(connectString);
14-
if ( m.find() ) {
14+
if (m.find()) {
1515
user = stripEnclosingQuotes(m.group(1));
1616
password = stripEnclosingQuotes(m.group(2));
1717
connect = m.group(3);
18-
}
19-
else
18+
} else {
2019
throw new IllegalArgumentException("Not a valid connectString: '" + connectString + "'");
20+
}
2121
}
2222

23-
private String stripEnclosingQuotes( String value ) {
24-
if ( value.length() > 1
23+
private String stripEnclosingQuotes(String value) {
24+
if (value.length() > 1
2525
&& value.startsWith("\"")
2626
&& value.endsWith("\"")) {
27-
return value.substring(1, value.length()-1);
27+
return value.substring(1, value.length() - 1);
2828
} else {
2929
return value;
3030
}
@@ -49,6 +49,6 @@ public String getConnectString() {
4949
public boolean isSysDba() {
5050
return user != null &&
5151
(user.toLowerCase().endsWith(" as sysdba")
52-
|| user.toLowerCase().endsWith(" as sysoper"));
52+
|| user.toLowerCase().endsWith(" as sysoper"));
5353
}
5454
}

Diff for: src/main/java/org/utplsql/cli/DataSourceProvider.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import java.io.File;
77
import java.sql.SQLException;
88

9-
/** Helper class to give you a ready-to-use datasource
9+
/**
10+
* Helper class to give you a ready-to-use datasource
1011
*
1112
* @author pesse
1213
*/
@@ -20,7 +21,7 @@ public class DataSourceProvider {
2021
}
2122
}
2223

23-
public static DataSource getDataSource(String connectString, int maxConnections ) throws SQLException {
24+
public static DataSource getDataSource(String connectString, int maxConnections) throws SQLException {
2425

2526
requireOjdbc();
2627

@@ -31,8 +32,7 @@ public static DataSource getDataSource(String connectString, int maxConnections
3132
}
3233

3334
private static void requireOjdbc() {
34-
if ( !OracleLibraryChecker.checkOjdbcExists() )
35-
{
35+
if (!OracleLibraryChecker.checkOjdbcExists()) {
3636
System.out.println("Could not find Oracle JDBC driver in classpath. Please download the jar from Oracle website" +
3737
" and copy it to the 'lib' folder of your utPLSQL-cli installation.");
3838
System.out.println("Download from http://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html");
@@ -42,7 +42,7 @@ private static void requireOjdbc() {
4242
}
4343

4444
private static void warnIfSysDba(ConnectionConfig config) {
45-
if ( config.isSysDba() ) {
45+
if (config.isSysDba()) {
4646
System.out.println("WARNING: You are connecting to the database as SYSDBA or SYSOPER, which is NOT RECOMMENDED and can put your database at risk!");
4747
}
4848
}

Diff for: src/main/java/org/utplsql/cli/FileWalker.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public List<String> getFileList(File baseDir, String inspectPath) {
1616
public List<String> getFileList(File baseDir, String inspectPath, boolean relative) {
1717
File inspectDir = new File(baseDir, inspectPath);
1818

19-
if (!inspectDir.isDirectory())
19+
if (!inspectDir.isDirectory()) {
2020
throw new IllegalArgumentException(inspectPath + " is not a directory.");
21+
}
2122

2223
List<String> fileList = new ArrayList<>();
2324
listDirFiles(baseDir, inspectDir, fileList, relative);
@@ -28,15 +29,17 @@ public List<String> getFileList(File baseDir, String inspectPath, boolean relati
2829
private void listDirFiles(File baseDir, File directory, List<String> fileList, boolean relative) {
2930
File[] directoryFiles = directory.listFiles();
3031

31-
if (directoryFiles == null)
32+
if (directoryFiles == null) {
3233
return;
34+
}
3335

3436
for (File file : directoryFiles) {
3537
if (file.isFile()) {
3638
String absolutePath = file.getAbsolutePath();
3739

38-
if (relative)
40+
if (relative) {
3941
absolutePath = absolutePath.substring(baseDir.getAbsolutePath().length() + 1);
42+
}
4043

4144
fileList.add(absolutePath);
4245
} else {

Diff for: src/main/java/org/utplsql/cli/ICommand.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.utplsql.cli;
22

3-
/** This is the very basic interface that should be implemented by all utPLSQL cli commands
3+
/**
4+
* This is the very basic interface that should be implemented by all utPLSQL cli commands
45
*
56
* @author pesse
67
*/
78
public interface ICommand {
89

9-
/** We expect the command to handle all eventually occurring exceptions
10+
/**
11+
* We expect the command to handle all eventually occurring exceptions
1012
* and return an exit code
1113
*
1214
* @return exit code integer

Diff for: src/main/java/org/utplsql/cli/LocaleInitializer.java

+19-15
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,58 @@
66
import java.util.regex.Matcher;
77
import java.util.regex.Pattern;
88

9-
/** This class makes sure the java locale is set according to the environment variables LC_ALL and LANG
9+
/**
10+
* This class makes sure the java locale is set according to the environment variables LC_ALL and LANG
1011
* We experienced that, in some cases, the locale was not set as expected, therefore this class implements some clear
1112
* rules:
12-
* 1. If environment variable LC_ALL is set, we try to parse its content and set locale according to its value if valid
13-
* 2. If environment variable LANG is set, we try to parse its content and set locale according to its value if valid
14-
* 3. Otherwise we use default locale
13+
* 1. If environment variable LC_ALL is set, we try to parse its content and set locale according to its value if valid
14+
* 2. If environment variable LANG is set, we try to parse its content and set locale according to its value if valid
15+
* 3. Otherwise we use default locale
1516
*
16-
* @author pesse
17+
* @author pesse
1718
*/
1819
class LocaleInitializer {
1920

2021
private static final Pattern REGEX_LOCALE = Pattern.compile("^([a-zA-Z]+)[_-]([a-zA-Z]+)"); // We only need the very first part and are pretty forgiving in parsing
2122

22-
/** Sets the default locale according to the rules described above
23-
*
23+
/**
24+
* Sets the default locale according to the rules described above
2425
*/
2526
static void initLocale() {
2627

2728
boolean localeChanged = setDefaultLocale(EnvironmentVariableUtil.getEnvValue("LC_ALL"));
28-
if ( !localeChanged )
29+
if (!localeChanged) {
2930
setDefaultLocale(EnvironmentVariableUtil.getEnvValue("LANG"));
31+
}
3032
}
3133

32-
/** Set the default locale from a given string like LC_ALL or LANG environment variable
34+
/**
35+
* Set the default locale from a given string like LC_ALL or LANG environment variable
3336
*
3437
* @param localeString Locale-string from LC_ALL or LANG, e.g "en_US.utf-8"
3538
* @return true if successful, false if not
3639
*/
37-
private static boolean setDefaultLocale( String localeString ) {
38-
if ( localeString == null || localeString.isEmpty() )
40+
private static boolean setDefaultLocale(String localeString) {
41+
if (localeString == null || localeString.isEmpty()) {
3942
return false;
43+
}
4044

4145
try {
4246
Matcher m = REGEX_LOCALE.matcher(localeString);
4347
if (m.find()) {
4448
StringBuilder sb = new StringBuilder();
4549
sb.append(m.group(1));
46-
if (m.group(2) != null)
50+
if (m.group(2) != null) {
4751
sb.append("-").append(m.group(2));
52+
}
4853

4954
Locale l = new Locale.Builder().setLanguageTag(sb.toString()).build();
50-
if ( l != null ) {
55+
if (l != null) {
5156
Locale.setDefault(l);
5257
return true;
5358
}
5459
}
55-
}
56-
catch ( Exception e ) {
60+
} catch (Exception e) {
5761
System.out.println("Could not get locale from " + localeString);
5862
}
5963

Diff for: src/main/java/org/utplsql/cli/LoggerConfiguration.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public enum ConfigLevel {
1616
}
1717

1818
private LoggerConfiguration() {
19-
throw new UnsupportedOperationException();
19+
throw new UnsupportedOperationException();
2020
}
2121

2222
static void configure(ConfigLevel level) {
23-
switch ( level ) {
23+
switch (level) {
2424
case BASIC:
2525
configureInfo();
2626
break;
@@ -48,17 +48,17 @@ private static void configureDebug() {
4848
setSingleConsoleAppenderWithLayout("%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n");
4949
}
5050

51-
private static void setRootLoggerLevel( Level level ) {
52-
Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
51+
private static void setRootLoggerLevel(Level level) {
52+
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
5353
root.setLevel(level);
5454
}
5555

5656
private static void muteHikariLogger() {
5757
((Logger) LoggerFactory.getLogger(HikariDataSource.class)).setLevel(Level.OFF);
5858
}
5959

60-
private static void setSingleConsoleAppenderWithLayout( String patternLayout ) {
61-
Logger logger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
60+
private static void setSingleConsoleAppenderWithLayout(String patternLayout) {
61+
Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
6262
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
6363

6464
PatternLayoutEncoder ple = new PatternLayoutEncoder();

Diff for: src/main/java/org/utplsql/cli/OracleLibraryChecker.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package org.utplsql.cli;
22

3-
/** Simple class to check whether needed Oracle libraries are on classpath or not
3+
/**
4+
* Simple class to check whether needed Oracle libraries are on classpath or not
45
*
56
* @author pesse
67
*/
78
class OracleLibraryChecker {
89

9-
private static boolean classExists( String classFullName ){
10-
try
11-
{
10+
private static boolean classExists(String classFullName) {
11+
try {
1212
Class.forName(classFullName);
1313

1414
return true;
15-
}
16-
catch ( ClassNotFoundException e )
17-
{
15+
} catch (ClassNotFoundException e) {
1816
return false;
1917
}
2018
}
2119

22-
/** Checks if OJDBC library is on the classpath by searching for oracle.jdbc.OracleDriver class
20+
/**
21+
* Checks if OJDBC library is on the classpath by searching for oracle.jdbc.OracleDriver class
2322
*
2423
* @return true or false
2524
*/
2625
public static boolean checkOjdbcExists() {
2726
return classExists("oracle.jdbc.OracleDriver");
2827
}
2928

30-
/** Checks if Orai18n library is on the classpath by searching for oracle.i18n.text.OraCharset
29+
/**
30+
* Checks if Orai18n library is on the classpath by searching for oracle.i18n.text.OraCharset
3131
*
3232
* @return true or false
3333
*/

Diff for: src/main/java/org/utplsql/cli/ReporterFactoryProvider.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
import java.sql.Connection;
99
import java.sql.SQLException;
1010

11-
/** A simple class to provide a ReporterFactory for the RunCommand
11+
/**
12+
* A simple class to provide a ReporterFactory for the RunCommand
1213
*
1314
* @author pesse
1415
*/
1516
class ReporterFactoryProvider {
1617

17-
public static ReporterFactory createReporterFactory(CompatibilityProxy proxy ) {
18+
public static ReporterFactory createReporterFactory(CompatibilityProxy proxy) {
1819
ReporterFactory reporterFactory = ReporterFactory.createDefault(proxy);
1920
reporterFactory.registerReporterFactoryMethod(CoreReporters.UT_COVERAGE_HTML_REPORTER.name(), LocalAssetsCoverageHTMLReporter::new, "Will copy all necessary assets to a folder named after the Output-File");
2021

2122
return reporterFactory;
2223
}
2324

24-
public static ReporterFactory createReporterFactory(Connection con ) throws SQLException {
25+
public static ReporterFactory createReporterFactory(Connection con) throws SQLException {
2526
return createReporterFactory(new CompatibilityProxy(con));
2627
}
2728
}

0 commit comments

Comments
 (0)