Skip to content

Instantly share code, notes, and snippets.

@gilou
Created April 26, 2017 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilou/3098d26a22924cfd35d783dda6e8462a to your computer and use it in GitHub Desktop.
Save gilou/3098d26a22924cfd35d783dda6e8462a to your computer and use it in GitHub Desktop.
Talend routines to make use of Faker java lib
package routines;
import java.util.Locale;
import com.github.javafaker.Faker;
/*
* user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
* it must be before the "{talendTypes}" key.
*
* 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
* long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
* Short
*
* 3. {Category} define a category for the Function. it is required. its value is user-defined .
*
* 4. {param} 's format is: {param} <type>[(<default value or closed list values>)] <name>[ : <comment>]
*
* <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
* Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
* added. you can have many parameters for the Function.
*
* 5. {example} gives a example for the Function. it is optional.
*/
public class FakerDataGenerator {
private static Locale internalLocale = new Locale("fr");
private static Faker internalFaker = getFaker();
private static Faker getFaker() {
Faker faker = new Faker(internalLocale);
return faker;
}
/**
* {talendTypes} String
*
* {Category} FakerDataGenerator
*
* {example} getFirstName() # Bill.
*/
public static String getFirstName() {
return internalFaker.name().firstName();
}
/**
* {talendTypes} String
*
* {Category} FakerDataGenerator
*
* {example} getLastName() # Washington.
*/
public static String getLastName() {
return internalFaker.name().lastName();
}
/**
* {talendTypes} String
*
* {Category} FakerDataGenerator
*
* {example} getCity() # Paris.
*/
public static String getCity() {
return internalFaker.address().city();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment