java-faker
java-faker copied to clipboard
Vehicle Faker
Problem I want a faker that generates vehicle data such as:
- Make
- Model
- Year
- VIN
- Mileage
Solution
- Implement the missing Vehicle class
- .yml file already exists
Additional Details
It appears that the work for this was done in PR #436 but is not in master. Is this a mistake? In a future release? or was there a decision to remove this?
Working on a new PR. I will reuse most of the previous PR but I have some thoughts:
- the .yml file has an entry for manufacturer and make. These are interchangeable in my opinion, I'm considering removing one entirely.
- Previous PR uses the following code to generate a model, This should return null if the make is not found instead of a validation message imo
public String model(String make) {
ArrayList<String> arr = (ArrayList<String>) faker.fakeValuesService().fetchObject("vehicle.makes");
if (arr.contains(make))
return faker.fakeValuesService().fetchString(String.format("vehicle.models_by_make.%s", make));
else
return "Only Supports models of the following make: " + arr;
}
- The previous PR uses the following code to generate a license plate, This should return null if the state is blank/null imo. I want to create an overload of
licensePlate
that takes no parameter that will handle the 'else' case
public String licensePlate(String stateAbbreviation) {
String key;
if (!StringUtils.isBlank(stateAbbreviation)) {
key = "vehicle.license_plate_by_state." + stateAbbreviation;
return faker.regexify(faker.bothify(faker.fakeValuesService().fetchObject(key).toString()));
} else {
key = "vehicle.license_plate";
return faker.regexify(faker.bothify(faker.fakeValuesService().fetchObject(key).toString()));
}
}
I could use this. Any plans to put this in a next release?
I sure could use it too.
Still willing to merge this in. The PR has been sitting here for over a year and I have not been contacted by anyone to explain why
@thePantz explain what exactly?
EDIT: Understanding now. You are the author of the PR, not a contributor.
The good folks at https://github.com/datafaker-net/datafaker (fork of this repo) have added a vehicle faker among many others. I suggest we all move there
I'm happy to hear that 2 years after the original report we can still add some value with Datafaker.
FYI, using Datafaker, it's also possible to create your own custom fakers of data, should there be a special case not supported by any of the current fakers.