-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support @GeneratePojobuilder on records
- Loading branch information
michi
committed
Jan 16, 2022
1 parent
bee5537
commit cdaf7bf
Showing
11 changed files
with
465 additions
and
2 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
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
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,74 @@ | ||
package samples; | ||
|
||
import javax.annotation.processing.Generated; | ||
import net.karneim.pojobuilder.GwtIncompatible; | ||
|
||
@Generated("PojoBuilder") | ||
public class BarBuilder | ||
implements Cloneable { | ||
protected BarBuilder self; | ||
protected RecordsInUmbrellaClass.Foo value$foo$samples$RecordsInUmbrellaClass$Foo; | ||
protected boolean isSet$foo$samples$RecordsInUmbrellaClass$Foo; | ||
|
||
/** | ||
* Creates a new {@link BarBuilder}. | ||
*/ | ||
public BarBuilder() { | ||
self = (BarBuilder)this; | ||
} | ||
|
||
/** | ||
* Sets the default value for the foo property. | ||
* | ||
* @param value the default value | ||
* @return this builder | ||
*/ | ||
public BarBuilder withFoo(RecordsInUmbrellaClass.Foo value) { | ||
this.value$foo$samples$RecordsInUmbrellaClass$Foo = value; | ||
this.isSet$foo$samples$RecordsInUmbrellaClass$Foo = true; | ||
return self; | ||
} | ||
|
||
/** | ||
* Returns a clone of this builder. | ||
* | ||
* @return the clone | ||
*/ | ||
@Override | ||
@GwtIncompatible | ||
public Object clone() { | ||
try { | ||
BarBuilder result = (BarBuilder)super.clone(); | ||
result.self = result; | ||
return result; | ||
} catch (CloneNotSupportedException e) { | ||
throw new InternalError(e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Returns a clone of this builder. | ||
* | ||
* @return the clone | ||
*/ | ||
@GwtIncompatible | ||
public BarBuilder but() { | ||
return (BarBuilder)clone(); | ||
} | ||
|
||
/** | ||
* Creates a new {@link RecordsInUmbrellaClass.Bar} based on this builder's settings. | ||
* | ||
* @return the created RecordsInUmbrellaClass.Bar | ||
*/ | ||
public RecordsInUmbrellaClass.Bar build() { | ||
try { | ||
RecordsInUmbrellaClass.Bar result = new RecordsInUmbrellaClass.Bar(value$foo$samples$RecordsInUmbrellaClass$Foo); | ||
return result; | ||
} catch (RuntimeException ex) { | ||
throw ex; | ||
} catch (Exception ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
} |
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,74 @@ | ||
package samples; | ||
|
||
import javax.annotation.processing.Generated; | ||
import net.karneim.pojobuilder.GwtIncompatible; | ||
|
||
@Generated("PojoBuilder") | ||
public class FooBuilder | ||
implements Cloneable { | ||
protected FooBuilder self; | ||
protected int value$foo$int; | ||
protected boolean isSet$foo$int; | ||
|
||
/** | ||
* Creates a new {@link FooBuilder}. | ||
*/ | ||
public FooBuilder() { | ||
self = (FooBuilder)this; | ||
} | ||
|
||
/** | ||
* Sets the default value for the foo property. | ||
* | ||
* @param value the default value | ||
* @return this builder | ||
*/ | ||
public FooBuilder withFoo(int value) { | ||
this.value$foo$int = value; | ||
this.isSet$foo$int = true; | ||
return self; | ||
} | ||
|
||
/** | ||
* Returns a clone of this builder. | ||
* | ||
* @return the clone | ||
*/ | ||
@Override | ||
@GwtIncompatible | ||
public Object clone() { | ||
try { | ||
FooBuilder result = (FooBuilder)super.clone(); | ||
result.self = result; | ||
return result; | ||
} catch (CloneNotSupportedException e) { | ||
throw new InternalError(e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Returns a clone of this builder. | ||
* | ||
* @return the clone | ||
*/ | ||
@GwtIncompatible | ||
public FooBuilder but() { | ||
return (FooBuilder)clone(); | ||
} | ||
|
||
/** | ||
* Creates a new {@link RecordsInUmbrellaClass.Foo} based on this builder's settings. | ||
* | ||
* @return the created RecordsInUmbrellaClass.Foo | ||
*/ | ||
public RecordsInUmbrellaClass.Foo build() { | ||
try { | ||
RecordsInUmbrellaClass.Foo result = new RecordsInUmbrellaClass.Foo(value$foo$int); | ||
return result; | ||
} catch (RuntimeException ex) { | ||
throw ex; | ||
} catch (Exception ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
} |
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 samples; | ||
|
||
import net.karneim.pojobuilder.GeneratePojoBuilder; | ||
|
||
@GeneratePojoBuilder | ||
public record Record(String name, User assignee, String description) {} |
102 changes: 102 additions & 0 deletions
102
src/testdata-java16/resources/samples/RecordBuilder.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,102 @@ | ||
package samples; | ||
|
||
import javax.annotation.processing.Generated; | ||
import net.karneim.pojobuilder.GwtIncompatible; | ||
|
||
@Generated("PojoBuilder") | ||
public class RecordBuilder | ||
implements Cloneable { | ||
protected RecordBuilder self; | ||
protected String value$name$java$lang$String; | ||
protected boolean isSet$name$java$lang$String; | ||
protected User value$assignee$samples$User; | ||
protected boolean isSet$assignee$samples$User; | ||
protected String value$description$java$lang$String; | ||
protected boolean isSet$description$java$lang$String; | ||
|
||
/** | ||
* Creates a new {@link RecordBuilder}. | ||
*/ | ||
public RecordBuilder() { | ||
self = (RecordBuilder)this; | ||
} | ||
|
||
/** | ||
* Sets the default value for the name property. | ||
* | ||
* @param value the default value | ||
* @return this builder | ||
*/ | ||
public RecordBuilder withName(String value) { | ||
this.value$name$java$lang$String = value; | ||
this.isSet$name$java$lang$String = true; | ||
return self; | ||
} | ||
|
||
/** | ||
* Sets the default value for the assignee property. | ||
* | ||
* @param value the default value | ||
* @return this builder | ||
*/ | ||
public RecordBuilder withAssignee(User value) { | ||
this.value$assignee$samples$User = value; | ||
this.isSet$assignee$samples$User = true; | ||
return self; | ||
} | ||
|
||
/** | ||
* Sets the default value for the description property. | ||
* | ||
* @param value the default value | ||
* @return this builder | ||
*/ | ||
public RecordBuilder withDescription(String value) { | ||
this.value$description$java$lang$String = value; | ||
this.isSet$description$java$lang$String = true; | ||
return self; | ||
} | ||
|
||
/** | ||
* Returns a clone of this builder. | ||
* | ||
* @return the clone | ||
*/ | ||
@Override | ||
@GwtIncompatible | ||
public Object clone() { | ||
try { | ||
RecordBuilder result = (RecordBuilder)super.clone(); | ||
result.self = result; | ||
return result; | ||
} catch (CloneNotSupportedException e) { | ||
throw new InternalError(e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Returns a clone of this builder. | ||
* | ||
* @return the clone | ||
*/ | ||
@GwtIncompatible | ||
public RecordBuilder but() { | ||
return (RecordBuilder)clone(); | ||
} | ||
|
||
/** | ||
* Creates a new {@link Record} based on this builder's settings. | ||
* | ||
* @return the created Record | ||
*/ | ||
public Record build() { | ||
try { | ||
Record result = new Record(value$name$java$lang$String, value$assignee$samples$User, value$description$java$lang$String); | ||
return result; | ||
} catch (RuntimeException ex) { | ||
throw ex; | ||
} catch (Exception ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
} |
Oops, something went wrong.