-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow Step Builder to have a custom setter prefix
- Loading branch information
1 parent
231e777
commit 2ebd260
Showing
6 changed files
with
150 additions
and
5 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
50 changes: 50 additions & 0 deletions
50
...tegies/StepWise/SetterWithCustomPrefix/Expected_DefaultSetterWithCustomPrefixBuilder.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,50 @@ | ||
package io.jonasg.bob.test; | ||
|
||
import java.lang.String; | ||
|
||
public final class DefaultSetterWithCustomPrefixBuilder implements SetterWithCustomPrefixBuilder, SetterWithCustomPrefixBuilder.BuildStep, SetterWithCustomPrefixBuilder.FuelEfficiencyStep, SetterWithCustomPrefixBuilder.IsElectricStep { | ||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
private String make; | ||
|
||
private int year; | ||
|
||
public DefaultSetterWithCustomPrefixBuilder() { | ||
} | ||
|
||
public DefaultSetterWithCustomPrefixBuilder withEngineSize(double engineSize) { | ||
this.engineSize = engineSize; | ||
return this; | ||
} | ||
|
||
public DefaultSetterWithCustomPrefixBuilder withIsElectric(boolean isElectric) { | ||
this.isElectric = isElectric; | ||
return this; | ||
} | ||
|
||
public DefaultSetterWithCustomPrefixBuilder withFuelEfficiency(float fuelEfficiency) { | ||
this.fuelEfficiency = fuelEfficiency; | ||
return this; | ||
} | ||
|
||
public DefaultSetterWithCustomPrefixBuilder withMake(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public DefaultSetterWithCustomPrefixBuilder withYear(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
|
||
public SetterWithCustomPrefix build() { | ||
var instance = new SetterWithCustomPrefix(engineSize, isElectric, fuelEfficiency); | ||
instance.setMake(this.make); | ||
instance.setYear(this.year); | ||
return instance; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ts/Strategies/StepWise/SetterWithCustomPrefix/Expected_SetterWithCustomPrefixBuilder.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 io.jonasg.bob.test; | ||
|
||
import java.lang.String; | ||
|
||
public interface SetterWithCustomPrefixBuilder { | ||
static SetterWithCustomPrefixBuilder newBuilder() { | ||
return new DefaultSetterWithCustomPrefixBuilder(); | ||
} | ||
|
||
IsElectricStep withEngineSize(double engineSize); | ||
|
||
interface BuildStep { | ||
BuildStep withYear(int year); | ||
|
||
BuildStep withMake(String make); | ||
|
||
SetterWithCustomPrefix build(); | ||
} | ||
|
||
interface FuelEfficiencyStep { | ||
BuildStep withFuelEfficiency(float fuelEfficiency); | ||
} | ||
|
||
interface IsElectricStep { | ||
FuelEfficiencyStep withIsElectric(boolean isElectric); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...st/resources/tests/Strategies/StepWise/SetterWithCustomPrefix/SetterWithCustomPrefix.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,33 @@ | ||
package io.jonasg.bob.test; | ||
|
||
import io.jonasg.bob.Buildable; | ||
import io.jonasg.bob.Strategy; | ||
|
||
@Buildable(strategy = Strategy.STEP_WISE, setterPrefix = "with") | ||
public class SetterWithCustomPrefix { | ||
private String make; | ||
|
||
private int year; | ||
|
||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
public SetterWithCustomPrefix(double engineSize, boolean isElectric, float fuelEfficiency) { | ||
this.engineSize = engineSize; | ||
this.isElectric = isElectric; | ||
this.fuelEfficiency = fuelEfficiency; | ||
} | ||
|
||
public SetterWithCustomPrefix setMake(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public SetterWithCustomPrefix setYear(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
} |