-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #419 from Ladicek/add-canonical-constructor
add ClassInfo.canonicalConstructor()
- Loading branch information
Showing
11 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test-data/src/main/java/test/RecordWithCompactCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package test; | ||
|
||
public record RecordWithCompactCanonicalCtor(int foo, String bar) { | ||
public RecordWithCompactCanonicalCtor { | ||
if (foo < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
if (bar == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test-data/src/main/java/test/RecordWithCustomCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package test; | ||
|
||
public record RecordWithCustomCanonicalCtor(int foo, String bar) { | ||
public RecordWithCustomCanonicalCtor(int foo, String bar) { | ||
if (foo < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
if (bar == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
this.foo = foo; | ||
this.bar = bar; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
test-data/src/main/java/test/RecordWithDefaultCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package test; | ||
|
||
public record RecordWithDefaultCanonicalCtor(int foo, String bar) { | ||
} |
24 changes: 24 additions & 0 deletions
24
test-data/src/main/java/test/RecordWithMultipleCtorsAndCompactCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package test; | ||
|
||
public record RecordWithMultipleCtorsAndCompactCanonicalCtor(int foo, String bar) { | ||
public RecordWithMultipleCtorsAndCompactCanonicalCtor { | ||
if (foo < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
if (bar == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
} | ||
|
||
public RecordWithMultipleCtorsAndCompactCanonicalCtor(int foo) { | ||
this(foo, ""); | ||
} | ||
|
||
public RecordWithMultipleCtorsAndCompactCanonicalCtor(String bar) { | ||
this(0, bar); | ||
} | ||
|
||
public RecordWithMultipleCtorsAndCompactCanonicalCtor(String bar, int foo) { | ||
this(foo, bar); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
test-data/src/main/java/test/RecordWithMultipleCtorsAndCustomCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package test; | ||
|
||
public record RecordWithMultipleCtorsAndCustomCanonicalCtor(int foo, String bar) { | ||
public RecordWithMultipleCtorsAndCustomCanonicalCtor(int foo, String bar) { | ||
if (foo < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
if (bar == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
this.foo = foo; | ||
this.bar = bar; | ||
} | ||
|
||
public RecordWithMultipleCtorsAndCustomCanonicalCtor(int foo) { | ||
this(foo, ""); | ||
} | ||
|
||
public RecordWithMultipleCtorsAndCustomCanonicalCtor(String bar) { | ||
this(0, bar); | ||
} | ||
|
||
public RecordWithMultipleCtorsAndCustomCanonicalCtor(String bar, int foo) { | ||
this(foo, bar); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test-data/src/main/java/test/RecordWithMultipleCtorsAndDefaultCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package test; | ||
|
||
public record RecordWithMultipleCtorsAndDefaultCanonicalCtor(int foo, String bar) { | ||
RecordWithMultipleCtorsAndDefaultCanonicalCtor(int foo) { | ||
this(foo, ""); | ||
} | ||
|
||
public RecordWithMultipleCtorsAndDefaultCanonicalCtor(String bar) { | ||
this(0, bar); | ||
} | ||
|
||
public RecordWithMultipleCtorsAndDefaultCanonicalCtor(String bar, int foo) { | ||
this(foo, bar); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
test-data/src/main/java/test/RecordWithNoComponentsAndCompactCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package test; | ||
|
||
public record RecordWithNoComponentsAndCompactCanonicalCtor() { | ||
public RecordWithNoComponentsAndCompactCanonicalCtor { | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
test-data/src/main/java/test/RecordWithNoComponentsAndCustomCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package test; | ||
|
||
public record RecordWithNoComponentsAndCustomCanonicalCtor() { | ||
public RecordWithNoComponentsAndCustomCanonicalCtor() { | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
test-data/src/main/java/test/RecordWithNoComponentsAndDefaultCanonicalCtor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package test; | ||
|
||
public record RecordWithNoComponentsAndDefaultCanonicalCtor() { | ||
} |