Bring in Lombok. · rpcyn/sample-java-project@60c4d2a · GitHub
Skip to content

Commit 60c4d2a

Browse files
committed
Bring in Lombok.
1 parent f0540f5 commit 60c4d2a

4 files changed

Lines changed: 43 additions & 35 deletions

File tree

build.xml

Lines changed: 10 additions & 2 deletions

ivy.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
conf="default->default"/>
1212
<dependency org="junit" name="junit" rev="4.10"
1313
conf="test->default"/>
14+
<dependency org="org.projectlombok" name="lombok" rev="0.10.4"
15+
conf="build->default"/>
1416
<dependency org="com.puppycrawl.tools" name="checkstyle" rev="5.5"
1517
conf="build->default"/>
1618
</dependencies>

src/sample/java/project/SampleJavaProject.java

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,34 @@
22

33
import java.util.Timer;
44
import java.util.TimerTask;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import lombok.NonNull;
9+
import lombok.Setter;
510
import org.apache.commons.cli.CommandLine;
611
import org.apache.commons.cli.GnuParser;
712
import org.apache.commons.cli.HelpFormatter;
813
import org.apache.commons.cli.Option;
914
import org.apache.commons.cli.Options;
1015

1116
/**
12-
* The main class.
13-
*
14-
* This is the main class of the application. It contains the main()
15-
* method, the first method called.
17+
* The main class of the application. It contains the main() method,
18+
* the first method called.
1619
*/
20+
@NoArgsConstructor
21+
@AllArgsConstructor
1722
public class SampleJavaProject extends TimerTask {
1823

1924
/** The delay between printed messages. */
2025
private static final long PRINT_DELAY = 1000L;
2126

2227
/** The name to printed in the output message. */
23-
private static String name = "world";
28+
@Getter @Setter @NonNull
29+
private String name = "world";
2430

2531
/**
26-
* The main class.
27-
*
2832
* Print the "Hello, world!" string.
29-
*
3033
* @param args application input arguments
3134
*/
3235
public static void main(final String[] args) {
@@ -44,37 +47,26 @@ public static void main(final String[] args) {
4447
}
4548

4649
/* Handle each argument. */
50+
SampleJavaProject sjp;
4751
if (line.hasOption("help")) {
4852
HelpFormatter formatter = new HelpFormatter();
4953
formatter.printHelp("SampleJavaProject [options]", options);
5054
System.exit(0);
5155
}
5256
if (line.hasOption("name")) {
53-
name = line.getOptionValue("name");
57+
sjp = new SampleJavaProject(line.getOptionValue("name"));
58+
} else {
59+
sjp = new SampleJavaProject();
5460
}
5561
if (line.hasOption("loop")) {
56-
new Timer().schedule(new SampleJavaProject(), 0L, PRINT_DELAY);
62+
new Timer().schedule(sjp, 0L, PRINT_DELAY);
5763
} else {
58-
new SampleJavaProject().run();
64+
sjp.run();
5965
}
6066
}
6167

6268
@Override
6369
public final void run() {
6470
System.out.printf("Hello, %s!\n", name);
6571
}
66-
67-
/**
68-
* Add two integers together.
69-
*
70-
* This is a dumb method that is here for the purposed of unit
71-
* testing.
72-
*
73-
* @param a first number
74-
* @param b second number
75-
* @return sum of the numbers
76-
*/
77-
public final int add(final int a, final int b) {
78-
return a + b;
79-
}
8072
}

test/sample/java/project/SampleJavaProjectTest.java

Lines changed: 14 additions & 8 deletions

0 commit comments

Comments
 (0)