Skip to content

Commit 152d35c

Browse files
committed
[>] Create domain model (records)
1 parent 9de210e commit 152d35c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
# Modern Java in Action
22

33
A repository for my live-coding talk [Modern Java in Action](https://nipafx.dev/talk-java-action).
4+
5+
## Next
6+
7+
Records:
8+
* `record ExternalPage(URI url, String content)`
9+
* compact constructor checks all arguments
10+
* `equals` with `instanceof`
11+
* `record GitHubPrPage(URI url, String content, Set<URI> links, int prNumber)`
12+
* compact constructor checks all arguments
13+
* additional constructor without `links`
14+
* `equals` with `instanceof`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package dev.nipafx.demo.modern;
2+
3+
import java.net.URI;
4+
import java.net.URISyntaxException;
5+
6+
public class GitHubCrawl {
7+
8+
/**
9+
* @param args 0: path to GitHub issue or PR page
10+
* 1: depth of tree that will be built
11+
*/
12+
public static void main(String[] args) throws Exception {
13+
var config = Configuration.parse(args);
14+
15+
}
16+
17+
private record Configuration(URI seedUrl, int depth) {
18+
19+
static Configuration parse(String[] args) throws URISyntaxException {
20+
if (args.length < 2)
21+
throw new IllegalArgumentException("Please specify the seed URL and depth.");
22+
var seedUrl = new URI(args[0]);
23+
var depth = Integer.parseInt(args[1]);
24+
return new Configuration(seedUrl, depth);
25+
}
26+
27+
}
28+
29+
}

src/main/java/module-info.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module gh.crawler {
2+
}

0 commit comments

Comments
 (0)