forked from loafle/openapi-generator-original
* add builder pattern to java client and spring generator * regenerate samples * update doc --------- Co-authored-by: jpfinne <jeanpaul@finne.be>
This commit is contained in:
@@ -104,5 +104,69 @@ public class Addressable {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Addressable instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Addressable());
|
||||
}
|
||||
|
||||
protected Builder(Addressable instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Addressable value) {
|
||||
this.instance.setHref(value.href);
|
||||
this.instance.setId(value.id);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Addressable.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Addressable.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Addressable instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Addressable build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Addressable.Builder builder() {
|
||||
return new Addressable.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Addressable.Builder toBuilder() {
|
||||
Addressable.Builder builder = new Addressable.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -119,5 +119,69 @@ public class Apple implements Fruit {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Apple instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Apple());
|
||||
}
|
||||
|
||||
protected Builder(Apple instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Apple value) {
|
||||
this.instance.setSeeds(value.seeds);
|
||||
this.instance.setFruitType(value.fruitType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Apple.Builder seeds(Integer seeds) {
|
||||
this.instance.seeds(seeds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Apple.Builder fruitType(FruitType fruitType) {
|
||||
this.instance.fruitType(fruitType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Apple instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Apple build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Apple.Builder builder() {
|
||||
return new Apple.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Apple.Builder toBuilder() {
|
||||
Apple.Builder builder = new Apple.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -119,5 +119,69 @@ public class Banana implements Fruit {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Banana instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Banana());
|
||||
}
|
||||
|
||||
protected Builder(Banana instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Banana value) {
|
||||
this.instance.setLength(value.length);
|
||||
this.instance.setFruitType(value.fruitType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banana.Builder length(Integer length) {
|
||||
this.instance.length(length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banana.Builder fruitType(FruitType fruitType) {
|
||||
this.instance.fruitType(fruitType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Banana instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Banana build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Banana.Builder builder() {
|
||||
return new Banana.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Banana.Builder toBuilder() {
|
||||
Banana.Builder builder = new Banana.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -191,5 +191,108 @@ public class Bar extends Entity implements BarRefOrValue {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder {
|
||||
|
||||
private Bar instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Bar());
|
||||
}
|
||||
|
||||
protected Builder(Bar instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Bar value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setId(value.id);
|
||||
this.instance.setBarPropA(value.barPropA);
|
||||
this.instance.setFooPropB(value.fooPropB);
|
||||
this.instance.setFoo(value.foo);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar.Builder barPropA(String barPropA) {
|
||||
this.instance.barPropA(barPropA);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar.Builder fooPropB(String fooPropB) {
|
||||
this.instance.fooPropB(fooPropB);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bar.Builder foo(FooRefOrValue foo) {
|
||||
this.instance.foo(foo);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bar.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bar.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bar.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bar.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Bar instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Bar build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Bar.Builder builder() {
|
||||
return new Bar.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Bar.Builder toBuilder() {
|
||||
Bar.Builder builder = new Bar.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -173,5 +173,108 @@ public class BarCreate extends Entity {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder {
|
||||
|
||||
private BarCreate instance;
|
||||
|
||||
public Builder() {
|
||||
this(new BarCreate());
|
||||
}
|
||||
|
||||
protected Builder(BarCreate instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(BarCreate value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setBarPropA(value.barPropA);
|
||||
this.instance.setFooPropB(value.fooPropB);
|
||||
this.instance.setFoo(value.foo);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BarCreate.Builder barPropA(String barPropA) {
|
||||
this.instance.barPropA(barPropA);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BarCreate.Builder fooPropB(String fooPropB) {
|
||||
this.instance.fooPropB(fooPropB);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BarCreate.Builder foo(FooRefOrValue foo) {
|
||||
this.instance.foo(foo);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarCreate.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarCreate.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarCreate.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarCreate.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarCreate.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built BarCreate instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public BarCreate build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static BarCreate.Builder builder() {
|
||||
return new BarCreate.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public BarCreate.Builder toBuilder() {
|
||||
BarCreate.Builder builder = new BarCreate.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -107,5 +107,102 @@ public class BarRef extends EntityRef implements BarRefOrValue {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends EntityRef.Builder {
|
||||
|
||||
private BarRef instance;
|
||||
|
||||
public Builder() {
|
||||
this(new BarRef());
|
||||
}
|
||||
|
||||
protected Builder(BarRef instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(BarRef value) {
|
||||
super.copyOf(instance);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder name(String name) {
|
||||
this.instance.name(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder atReferredType(String atReferredType) {
|
||||
this.instance.atReferredType(atReferredType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BarRef.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built BarRef instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public BarRef build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static BarRef.Builder builder() {
|
||||
return new BarRef.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public BarRef.Builder toBuilder() {
|
||||
BarRef.Builder builder = new BarRef.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -203,5 +203,87 @@ public class Entity {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Entity instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Entity());
|
||||
}
|
||||
|
||||
protected Builder(Entity instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Entity value) {
|
||||
this.instance.setHref(value.href);
|
||||
this.instance.setId(value.id);
|
||||
this.instance.setAtSchemaLocation(value.atSchemaLocation);
|
||||
this.instance.setAtBaseType(value.atBaseType);
|
||||
this.instance.setAtType(value.atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Entity.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Entity.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Entity.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Entity.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Entity.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Entity instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Entity build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Entity.Builder builder() {
|
||||
return new Entity.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Entity.Builder toBuilder() {
|
||||
Entity.Builder builder = new Entity.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -248,5 +248,99 @@ public class EntityRef {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private EntityRef instance;
|
||||
|
||||
public Builder() {
|
||||
this(new EntityRef());
|
||||
}
|
||||
|
||||
protected Builder(EntityRef instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(EntityRef value) {
|
||||
this.instance.setName(value.name);
|
||||
this.instance.setAtReferredType(value.atReferredType);
|
||||
this.instance.setHref(value.href);
|
||||
this.instance.setId(value.id);
|
||||
this.instance.setAtSchemaLocation(value.atSchemaLocation);
|
||||
this.instance.setAtBaseType(value.atBaseType);
|
||||
this.instance.setAtType(value.atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder name(String name) {
|
||||
this.instance.name(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder atReferredType(String atReferredType) {
|
||||
this.instance.atReferredType(atReferredType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityRef.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built EntityRef instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public EntityRef build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static EntityRef.Builder builder() {
|
||||
return new EntityRef.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public EntityRef.Builder toBuilder() {
|
||||
EntityRef.Builder builder = new EntityRef.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -138,5 +138,75 @@ public class Extensible {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Extensible instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Extensible());
|
||||
}
|
||||
|
||||
protected Builder(Extensible instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Extensible value) {
|
||||
this.instance.setAtSchemaLocation(value.atSchemaLocation);
|
||||
this.instance.setAtBaseType(value.atBaseType);
|
||||
this.instance.setAtType(value.atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Extensible.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Extensible.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Extensible.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Extensible instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Extensible build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Extensible.Builder builder() {
|
||||
return new Extensible.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Extensible.Builder toBuilder() {
|
||||
Extensible.Builder builder = new Extensible.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -146,5 +146,102 @@ public class Foo extends Entity implements FooRefOrValue {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder {
|
||||
|
||||
private Foo instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Foo());
|
||||
}
|
||||
|
||||
protected Builder(Foo instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Foo value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setFooPropA(value.fooPropA);
|
||||
this.instance.setFooPropB(value.fooPropB);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Foo.Builder fooPropA(String fooPropA) {
|
||||
this.instance.fooPropA(fooPropA);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Foo.Builder fooPropB(String fooPropB) {
|
||||
this.instance.fooPropB(fooPropB);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Foo.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Foo.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Foo.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Foo.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Foo.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Foo instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Foo build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Foo.Builder builder() {
|
||||
return new Foo.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Foo.Builder toBuilder() {
|
||||
Foo.Builder builder = new Foo.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -132,5 +132,108 @@ public class FooRef extends EntityRef implements FooRefOrValue {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends EntityRef.Builder {
|
||||
|
||||
private FooRef instance;
|
||||
|
||||
public Builder() {
|
||||
this(new FooRef());
|
||||
}
|
||||
|
||||
protected Builder(FooRef instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(FooRef value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setFoorefPropA(value.foorefPropA);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FooRef.Builder foorefPropA(String foorefPropA) {
|
||||
this.instance.foorefPropA(foorefPropA);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder name(String name) {
|
||||
this.instance.name(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder atReferredType(String atReferredType) {
|
||||
this.instance.atReferredType(atReferredType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FooRef.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built FooRef instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public FooRef build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static FooRef.Builder builder() {
|
||||
return new FooRef.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public FooRef.Builder toBuilder() {
|
||||
FooRef.Builder builder = new FooRef.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -122,5 +122,96 @@ public class Pasta extends Entity {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder {
|
||||
|
||||
private Pasta instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Pasta());
|
||||
}
|
||||
|
||||
protected Builder(Pasta instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Pasta value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setVendor(value.vendor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pasta.Builder vendor(String vendor) {
|
||||
this.instance.vendor(vendor);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pasta.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pasta.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pasta.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pasta.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pasta.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Pasta instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Pasta build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Pasta.Builder builder() {
|
||||
return new Pasta.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Pasta.Builder toBuilder() {
|
||||
Pasta.Builder builder = new Pasta.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -131,5 +131,96 @@ public class Pizza extends Entity {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder {
|
||||
|
||||
private Pizza instance;
|
||||
|
||||
public Builder() {
|
||||
this(new Pizza());
|
||||
}
|
||||
|
||||
protected Builder(Pizza instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(Pizza value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setPizzaSize(value.pizzaSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pizza.Builder pizzaSize(BigDecimal pizzaSize) {
|
||||
this.instance.pizzaSize(pizzaSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pizza.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pizza.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pizza.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pizza.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pizza.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built Pizza instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public Pizza build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static Pizza.Builder builder() {
|
||||
return new Pizza.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public Pizza.Builder toBuilder() {
|
||||
Pizza.Builder builder = new Pizza.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -128,5 +128,102 @@ public class PizzaSpeziale extends Pizza {
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
public static class Builder extends Pizza.Builder {
|
||||
|
||||
private PizzaSpeziale instance;
|
||||
|
||||
public Builder() {
|
||||
this(new PizzaSpeziale());
|
||||
}
|
||||
|
||||
protected Builder(PizzaSpeziale instance) {
|
||||
super(instance); // the parent builder shares the same instance
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
protected Builder copyOf(PizzaSpeziale value) {
|
||||
super.copyOf(instance);
|
||||
this.instance.setToppings(value.toppings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PizzaSpeziale.Builder toppings(String toppings) {
|
||||
this.instance.toppings(toppings);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PizzaSpeziale.Builder pizzaSize(BigDecimal pizzaSize) {
|
||||
this.instance.pizzaSize(pizzaSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PizzaSpeziale.Builder href(String href) {
|
||||
this.instance.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PizzaSpeziale.Builder id(String id) {
|
||||
this.instance.id(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PizzaSpeziale.Builder atSchemaLocation(String atSchemaLocation) {
|
||||
this.instance.atSchemaLocation(atSchemaLocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PizzaSpeziale.Builder atBaseType(String atBaseType) {
|
||||
this.instance.atBaseType(atBaseType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PizzaSpeziale.Builder atType(String atType) {
|
||||
this.instance.atType(atType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a built PizzaSpeziale instance.
|
||||
*
|
||||
* The builder is not reusable (NullPointerException)
|
||||
*/
|
||||
public PizzaSpeziale build() {
|
||||
try {
|
||||
return this.instance;
|
||||
} finally {
|
||||
// ensure that this.instance is not reused
|
||||
super.build();
|
||||
this.instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass() + "=(" + instance + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with no initialized field (except for the default values).
|
||||
*/
|
||||
public static PizzaSpeziale.Builder builder() {
|
||||
return new PizzaSpeziale.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a shallow copy of this instance.
|
||||
*/
|
||||
public PizzaSpeziale.Builder toBuilder() {
|
||||
PizzaSpeziale.Builder builder = new PizzaSpeziale.Builder();
|
||||
return builder.copyOf(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user