-
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.
feat(processor): add option for custom static factory method name
- Loading branch information
1 parent
a65a7e6
commit 286a122
Showing
11 changed files
with
381 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
...esources/tests/Strategies/Permissive/CustomFactoryMethodName/CustomFactoryMethodName.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(factoryName = "customName") | ||
public class CustomFactoryMethodName { | ||
private String make; | ||
|
||
private int year; | ||
|
||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
public CustomFactoryMethodName(double engineSize, boolean isElectric, float fuelEfficiency) { | ||
this.engineSize = engineSize; | ||
this.isElectric = isElectric; | ||
this.fuelEfficiency = fuelEfficiency; | ||
} | ||
|
||
public CustomFactoryMethodName setMake(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodName setYear(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...trategies/Permissive/CustomFactoryMethodName/Expected_CustomFactoryMethodNameBuilder.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,54 @@ | ||
package io.jonasg.bob.test; | ||
|
||
import java.lang.String; | ||
|
||
public final class CustomFactoryMethodNameBuilder { | ||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
private String make; | ||
|
||
private int year; | ||
|
||
public CustomFactoryMethodNameBuilder() { | ||
} | ||
|
||
public CustomFactoryMethodNameBuilder engineSize(double engineSize) { | ||
this.engineSize = engineSize; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodNameBuilder isElectric(boolean isElectric) { | ||
this.isElectric = isElectric; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodNameBuilder fuelEfficiency(float fuelEfficiency) { | ||
this.fuelEfficiency = fuelEfficiency; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodNameBuilder make(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodNameBuilder year(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodName build() { | ||
var instance = new CustomFactoryMethodName(engineSize, isElectric, fuelEfficiency); | ||
instance.setMake(this.make); | ||
instance.setYear(this.year); | ||
return instance; | ||
} | ||
|
||
public static CustomFactoryMethodNameBuilder customName() { | ||
return new CustomFactoryMethodNameBuilder(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../resources/tests/Strategies/StepWise/CustomFactoryMethodName/CustomFactoryMethodName.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, factoryName = "customName") | ||
public class CustomFactoryMethodName { | ||
private String make; | ||
|
||
private int year; | ||
|
||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
public CustomFactoryMethodName(double engineSize, boolean isElectric, float fuelEfficiency) { | ||
this.engineSize = engineSize; | ||
this.isElectric = isElectric; | ||
this.fuelEfficiency = fuelEfficiency; | ||
} | ||
|
||
public CustomFactoryMethodName setMake(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodName setYear(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../Strategies/StepWise/CustomFactoryMethodName/Expected_CustomFactoryMethodNameBuilder.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 CustomFactoryMethodNameBuilder { | ||
static CustomFactoryMethodNameBuilder customName() { | ||
return new DefaultCustomFactoryMethodNameBuilder(); | ||
} | ||
|
||
IsElectricStep engineSize(double engineSize); | ||
|
||
interface BuildStep { | ||
BuildStep year(int year); | ||
|
||
BuildStep make(String make); | ||
|
||
CustomFactoryMethodName build(); | ||
} | ||
|
||
interface FuelEfficiencyStep { | ||
BuildStep fuelEfficiency(float fuelEfficiency); | ||
} | ||
|
||
interface IsElectricStep { | ||
FuelEfficiencyStep isElectric(boolean isElectric); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...gies/StepWise/CustomFactoryMethodName/Expected_DefaultCustomFactoryMethodNameBuilder.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 DefaultCustomFactoryMethodNameBuilder implements CustomFactoryMethodNameBuilder.BuildStep, CustomFactoryMethodNameBuilder, CustomFactoryMethodNameBuilder.FuelEfficiencyStep, CustomFactoryMethodNameBuilder.IsElectricStep { | ||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
private String make; | ||
|
||
private int year; | ||
|
||
public DefaultCustomFactoryMethodNameBuilder() { | ||
} | ||
|
||
public DefaultCustomFactoryMethodNameBuilder engineSize(double engineSize) { | ||
this.engineSize = engineSize; | ||
return this; | ||
} | ||
|
||
public DefaultCustomFactoryMethodNameBuilder isElectric(boolean isElectric) { | ||
this.isElectric = isElectric; | ||
return this; | ||
} | ||
|
||
public DefaultCustomFactoryMethodNameBuilder fuelEfficiency(float fuelEfficiency) { | ||
this.fuelEfficiency = fuelEfficiency; | ||
return this; | ||
} | ||
|
||
public DefaultCustomFactoryMethodNameBuilder make(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public DefaultCustomFactoryMethodNameBuilder year(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodName build() { | ||
var instance = new CustomFactoryMethodName(engineSize, isElectric, fuelEfficiency); | ||
instance.setMake(this.make); | ||
instance.setYear(this.year); | ||
return instance; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...st/resources/tests/Strategies/Strict/CustomFactoryMethodName/CustomFactoryMethodName.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.STRICT, factoryName = "customName") | ||
public class CustomFactoryMethodName { | ||
private String make; | ||
|
||
private int year; | ||
|
||
private double engineSize; | ||
|
||
private boolean isElectric; | ||
|
||
private float fuelEfficiency; | ||
|
||
public CustomFactoryMethodName(double engineSize, boolean isElectric, float fuelEfficiency) { | ||
this.engineSize = engineSize; | ||
this.isElectric = isElectric; | ||
this.fuelEfficiency = fuelEfficiency; | ||
} | ||
|
||
public CustomFactoryMethodName setMake(String make) { | ||
this.make = make; | ||
return this; | ||
} | ||
|
||
public CustomFactoryMethodName setYear(int year) { | ||
this.year = year; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.