This is a library to generate random localized names consuming the API of uinames as source.
Download the JAR file and its dependencies (see below) and import them to your project.
At the time this library was written, this was the dependencies used to work with it.
First of all import the library classes into your project:
import name.davidsanchez.uiname.*;
Then create an instance of the UIName class:
UIName uiName = new UIName();
This way, you will use the default parameters. You can modify parameters this way:
UIName uiName = new UIName()
.setAmount(2) // Amount of names you want to generate
.setGender(Constants.Gender.FEMALE) // Gender of the names you want to generate
.setCountry(Constants.Country.COLOMBIA); // Localization of the names you want to generate
Then, you can use the generateNames() method, it will ask you to implement the UINameResponse interface:
uiName.generateNames(new UINameResponse() {
@Override
public void onNamesReceived(Person[] people) {
// The parameter people have all the generated people names in their
// corresponding class.
for (Person person : people) {
System.out.println("Name: " + p.getName() +
"\nSurname: " + p.getSurname() +
"\nCountry: " + p.getCountry() +
"\nGender: " + p.getGender());
}
}
});