mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 04:18:44 +00:00
[issue #1347] When lombok generates constructors, it should call the @Builder.Default static method instead of initializing to null/0/false. This does that, for javac.
This commit is contained in:
1 parent
577ce94fac
commit
3987f54b83
10 files changed
+361
-41
No files matched your search
@@ -0,0 +1,74 @@
|
||||
//CONF: lombok.noArgsConstructor.extraPrivate = true
|
||||
import lombok.NoArgsConstructor;
|
||||
final class ConstructorsWithBuilderDefaults {
|
||||
private final int x;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private static int $default$x() {
|
||||
return 5;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
ConstructorsWithBuilderDefaults(final int x) {
|
||||
this.x = x;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static class ConstructorsWithBuilderDefaultsBuilder {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private boolean x$set;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private int x;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
ConstructorsWithBuilderDefaultsBuilder() {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public ConstructorsWithBuilderDefaultsBuilder x(final int x) {
|
||||
this.x = x;
|
||||
x$set = true;
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public ConstructorsWithBuilderDefaults build() {
|
||||
int x = this.x;
|
||||
if (!x$set) x = ConstructorsWithBuilderDefaults.$default$x();
|
||||
return new ConstructorsWithBuilderDefaults(x);
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder(x=" + this.x + ")";
|
||||
}
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static ConstructorsWithBuilderDefaultsBuilder builder() {
|
||||
return new ConstructorsWithBuilderDefaultsBuilder();
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private ConstructorsWithBuilderDefaults() {
|
||||
this.x = ConstructorsWithBuilderDefaults.$default$x();
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof ConstructorsWithBuilderDefaults)) return false;
|
||||
final ConstructorsWithBuilderDefaults other = (ConstructorsWithBuilderDefaults) o;
|
||||
if (this.getX() != other.getX()) return false;
|
||||
return true;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.getX();
|
||||
return result;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "ConstructorsWithBuilderDefaults(x=" + this.getX() + ")";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user