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

Commitea7752c

Browse files
committed
checkstyle errors removed
checkstyle errors removed
1 parent7ba6cb4 commitea7752c

File tree

7 files changed

+425
-499
lines changed

7 files changed

+425
-499
lines changed

‎module/etc/module.urm.puml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@startuml
2+
packagecom.iluwatar.module {
3+
classApp {
4+
+consoleLoggerModule : ConsoleLoggerModule {static}
5+
+fileLoggerModule : FileLoggerModule {static}
6+
-App()
7+
+execute(args : String[]) {static}
8+
+main(args : String[]) {static}
9+
+prepare() {static}
10+
+unprepare() {static}
11+
}
12+
classConsoleLoggerModule {
13+
-LOGGER : Logger {static}
14+
+error :PrintStream
15+
+output :PrintStream
16+
-singleton : ConsoleLoggerModule {static}
17+
-ConsoleLoggerModule()
18+
+getSingleton() : ConsoleLoggerModule {static}
19+
+prepare()
20+
+printErrorString(value : String)
21+
+printString(value : String)
22+
+unprepare()
23+
}
24+
classFileLoggerModule {
25+
-ERROR_FILE : String {static}
26+
-LOGGER : Logger {static}
27+
-OUTPUT_FILE : String {static}
28+
+error :PrintStream
29+
+output :PrintStream
30+
-singleton : FileLoggerModule {static}
31+
-FileLoggerModule()
32+
+getSingleton() : FileLoggerModule {static}
33+
+prepare()
34+
+printErrorString(value : String)
35+
+printString(value : String)
36+
+unprepare()
37+
}
38+
}
39+
FileLoggerModule--> "-singleton"FileLoggerModule
40+
App--> "-consoleLoggerModule"ConsoleLoggerModule
41+
ConsoleLoggerModule--> "-singleton"ConsoleLoggerModule
42+
App--> "-fileLoggerModule"FileLoggerModule
43+
@enduml

‎module/src/main/java/com/iluwatar/module/App.java

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,64 +21,75 @@
2121
importjava.io.FileNotFoundException;
2222

2323
/**
24-
* The Module pattern can be considered a Creational pattern and a Structural
25-
* pattern. It manages the creation and organization of other elements, and
26-
* groups them as the structural pattern does. An object that applies this
27-
* pattern can provide the equivalent of a namespace, providing the
28-
* initialization and finalization process of a static class or a class with
29-
* static members with cleaner, more concise syntax and semantics.
24+
* The Module pattern can be considered a Creational pattern and a Structural pattern. It manages
25+
* the creation and organization of other elements, and groups them as the structural pattern does.
26+
* An object that applies this pattern can provide the equivalent of a namespace, providing the
27+
* initialization and finalization process of a static class or a class with static members with
28+
* cleaner, more concise syntax and semantics.
3029
* <p>
31-
* The below example demonstrates a use case for testing two different modules:
32-
*File Logger andConsole Logger
30+
* The below example demonstrates a use case for testing two different modules: File Logger and
31+
* Console Logger
3332
*
3433
*/
3534
publicfinalclassApp {
3635

37-
publicstaticFileLoggerModulefileLoggerModule =null;
38-
publicstaticConsoleLoggerModuleconsoleLoggerModule =null;
36+
publicstaticFileLoggerModulefileLoggerModule =null;
37+
publicstaticConsoleLoggerModuleconsoleLoggerModule =null;
3938

40-
publicstaticvoidprepare()throwsFileNotFoundException {
39+
/**
40+
* Following method performs the initialization
41+
*
42+
* @throws FileNotFoundException if program is not able to find log files (output.txt and
43+
* error.txt)
44+
*/
45+
publicstaticvoidprepare()throwsFileNotFoundException {
4146

42-
fileLoggerModule =FileLoggerModule.getSingleton();
43-
consoleLoggerModule =ConsoleLoggerModule.getSingleton();
47+
fileLoggerModule =FileLoggerModule.getSingleton();
48+
consoleLoggerModule =ConsoleLoggerModule.getSingleton();
4449

45-
/* Prepare modules */
46-
fileLoggerModule.prepare();
47-
consoleLoggerModule.prepare();
48-
}
50+
/* Prepare modules */
51+
fileLoggerModule.prepare();
52+
consoleLoggerModule.prepare();
53+
}
4954

50-
publicstaticvoidunprepare() {
55+
/**
56+
* Following method performs the finalization
57+
*/
58+
publicstaticvoidunprepare() {
5159

52-
/* Close all resources */
53-
fileLoggerModule.unprepare();
54-
consoleLoggerModule.unprepare();
55-
}
60+
/* Close all resources */
61+
fileLoggerModule.unprepare();
62+
consoleLoggerModule.unprepare();
63+
}
5664

57-
publicstaticfinalvoidexecute(finalString...args) {
65+
/**
66+
* Following method is main executor
67+
*
68+
* @param args for providing default program arguments
69+
*/
70+
publicstaticvoidexecute(finalString...args) {
5871

59-
/* Send logs on file system */
60-
fileLoggerModule.printString("Message");
61-
fileLoggerModule.printErrorString("Error");
72+
/* Send logs on file system */
73+
fileLoggerModule.printString("Message");
74+
fileLoggerModule.printErrorString("Error");
6275

63-
/* Send logs on console */
64-
consoleLoggerModule.printString("Message");
65-
consoleLoggerModule.printErrorString("Error");
66-
}
76+
/* Send logs on console */
77+
consoleLoggerModule.printString("Message");
78+
consoleLoggerModule.printErrorString("Error");
79+
}
6780

68-
/**
69-
* Program entry point.
70-
*
71-
* @param args
72-
* command line args.
73-
* @throws FileNotFoundException
74-
*/
75-
publicstaticfinalvoidmain(finalString...args)
76-
throwsFileNotFoundException {
77-
prepare();
78-
execute(args);
79-
unprepare();
80-
}
81+
/**
82+
* Program entry point.
83+
*
84+
* @param args command line args.
85+
* @throws FileNotFoundException if program is not able to find log files (output.txt and
86+
* error.txt)
87+
*/
88+
publicstaticvoidmain(finalString...args)throwsFileNotFoundException {
89+
prepare();
90+
execute(args);
91+
unprepare();
92+
}
8193

82-
privateApp() {
83-
}
94+
privateApp() {}
8495
}

‎module/src/main/java/com/iluwatar/module/ConsoleLoggerModule.java

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,89 +18,91 @@
1818
*/
1919
packagecom.iluwatar.module;
2020

21-
importjava.io.FileNotFoundException;
2221
importjava.io.PrintStream;
2322

2423
importorg.apache.log4j.Logger;
2524

2625
/**
27-
* The Module pattern can be considered a Creational pattern and a Structural
28-
* pattern. It manages the creation and organization of other elements, and
29-
* groups them as the structural pattern does. An object that applies this
30-
* pattern can provide the equivalent of a namespace, providing the
31-
* initialization and finalization process of a static class or a class with
32-
* static members with cleaner, more concise syntax and semantics.
26+
* The Module pattern can be considered a Creational pattern and a Structural pattern. It manages
27+
* the creation and organization of other elements, and groups them as the structural pattern does.
28+
* An object that applies this pattern can provide the equivalent of a namespace, providing the
29+
* initialization and finalization process of a static class or a class with static members with
30+
* cleaner, more concise syntax and semantics.
3331
* <p>
34-
* The below example demonstrates a Console logger module, which can print
35-
*simple and error messagesin two designated formats
32+
* The below example demonstrates a Console logger module, which can print simple and error messages
33+
* in two designated formats
3634
*/
37-
publicclassConsoleLoggerModule {
35+
publicfinalclassConsoleLoggerModule {
3836

39-
privatestaticfinalLoggerlogger =Logger
40-
.getLogger(ConsoleLoggerModule.class);
37+
privatestaticfinalLoggerLOGGER =Logger.getLogger(ConsoleLoggerModule.class);
4138

42-
privatestaticConsoleLoggerModulesingleton =null;
39+
privatestaticConsoleLoggerModulesingleton =null;
4340

44-
publicPrintStreamoutput =null;
45-
publicPrintStreamerror =null;
41+
publicPrintStreamoutput =null;
42+
publicPrintStreamerror =null;
4643

47-
privateConsoleLoggerModule() {
48-
}
44+
privateConsoleLoggerModule() {}
4945

50-
publicstaticfinalConsoleLoggerModulegetSingleton() {
46+
/**
47+
* Static method to get single instance of class
48+
*
49+
* @return singleton instance of ConsoleLoggerModule
50+
*/
51+
publicstaticConsoleLoggerModulegetSingleton() {
5152

52-
if (ConsoleLoggerModule.singleton ==null) {
53-
ConsoleLoggerModule.singleton =newConsoleLoggerModule();
54-
}
53+
if (ConsoleLoggerModule.singleton ==null) {
54+
ConsoleLoggerModule.singleton =newConsoleLoggerModule();
55+
}
5556

56-
returnConsoleLoggerModule.singleton;
57-
}
57+
returnConsoleLoggerModule.singleton;
58+
}
5859

59-
/**
60-
*
61-
* @throws FileNotFoundException
62-
*/
63-
publicfinalvoidprepare() {
60+
/**
61+
* Following method performs the initialization
62+
*/
63+
publicvoidprepare() {
6464

65-
logger.debug("ConsoleLoggerModule::prepare();");
65+
LOGGER.debug("ConsoleLoggerModule::prepare();");
6666

67-
this.output =newPrintStream(System.out);
68-
this.error =newPrintStream(System.err);
69-
}
67+
this.output =newPrintStream(System.out);
68+
this.error =newPrintStream(System.err);
69+
}
7070

71-
/**
72-
*
73-
*/
74-
publicfinalvoidunprepare() {
71+
/**
72+
* Following method performs the finalization
73+
*/
74+
publicvoidunprepare() {
7575

76-
if (this.output !=null) {
76+
if (this.output !=null) {
7777

78-
this.output.flush();
79-
this.output.close();
80-
}
78+
this.output.flush();
79+
this.output.close();
80+
}
8181

82-
if (this.error !=null) {
82+
if (this.error !=null) {
8383

84-
this.error.flush();
85-
this.error.close();
86-
}
84+
this.error.flush();
85+
this.error.close();
86+
}
8787

88-
logger.debug("ConsoleLoggerModule::unprepare();");
89-
}
88+
LOGGER.debug("ConsoleLoggerModule::unprepare();");
89+
}
9090

91-
/**
92-
*
93-
* @param value
94-
*/
95-
publicfinalvoidprintString(finalStringvalue) {
96-
this.output.println(value);
97-
}
91+
/**
92+
* Used to print a message
93+
*
94+
* @param value will be printed on console
95+
*/
96+
publicvoidprintString(finalStringvalue) {
97+
this.output.println(value);
98+
}
9899

99-
/**
100-
*
101-
* @param value
102-
*/
103-
publicfinalvoidprintErrorString(finalStringvalue) {
104-
this.error.println(value);
105-
}
100+
/**
101+
* Used to print a error message
102+
*
103+
* @param value will be printed on error console
104+
*/
105+
publicvoidprintErrorString(finalStringvalue) {
106+
this.error.println(value);
107+
}
106108
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp