/** * Creates an instance of {@link ObjectGenerator} which generates empty list. * * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates empty list. */ public static <T> ObjectGenerator<List<T>> emptyList() { return wrap(new EmptyListValue<>()); }
/** * Creates an instance of {@link ObjectGenerator} which generates UUIDs. * * @return An instance of {@link ObjectGenerator} which generates UUIDS. */ public static ObjectGenerator<String> uuid() { return wrap(new UUIDValue()); }
/** * Creates an instance of {@link ObjectGenerator} which generates current date-time as {@link Date} object. * * @return An instance of {@link ObjectGenerator} which generates current date-time as {@link Date} object. */ public static ObjectGenerator<Date> nowDate() { return wrap(new NowDateValue()); }
/** * Creates an instance of {@link ObjectGenerator} which generates current date-time as {@link LocalDateTime} object. * * @return An instance of {@link ObjectGenerator} which generates current date-time as {@link LocalDateTime} object. */ public static ObjectGenerator<LocalDateTime> nowLocalDateTime() { return wrap(new NowLocalDateTimeValue()); }
/** * Creates an instance of {@link ObjectGenerator} which converts specified instance of {@link ObjectGenerator} to * JSON. Uses default instance of {@link ObjectMapper} to converted to JSON. * * @param generator Instance of {@link ObjectGenerator} which value will be converted to JSON. * @return An instance of {@link ObjectGenerator} which converts specified instance of {@link ObjectGenerator} to * JSON. */ public static ObjectGenerator<String> json(ObjectGenerator<?> generator) { return wrap(new JsonTransformer(generator.value)); }
/** * Creates an instance of {@link ObjectGenerator} which always returns specified value. * * @param value Value to be returned by created constant object generator. * @param <T> Type this value would evaluate to. * * @return An instance of {@link ObjectGenerator}. */ public static <T> ObjectGenerator<T> constant(T value) { return wrap(ConstantValue.of(value)); }
/** * Creates an instance of {@link ObjectGenerator} which generates empty map. * * @param <K> Key type of map which {@link ObjectGenerator} will generate. * @param <V> Value type of map which {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates empty map. */ public static <K, V> ObjectGenerator<Map<K, V>> emptyMap() { return wrap(new EmptyMapValue<>()); }
/** * Creates an instance of {@link ObjectGenerator} which generates current date as {@link LocalDate} object. * * @return An instance of {@link ObjectGenerator} which generates current date as {@link LocalDate} object. */ public static ObjectGenerator<LocalDate> nowLocalDate() { return wrap(new NowLocalDateValue()); }
/** * Creates an instance of {@link ObjectGenerator} which generates empty list. * * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates empty list. */ public static <T> ObjectGenerator<List<T>> emptyList() { return wrap(new EmptyListValue<>()); }
/** * Creates an instance of {@link ObjectGenerator} which converts specified instance of {@link ObjectGenerator} to * JSON. Uses default instance of {@link ObjectMapper} to converted to JSON. * * @param generator Instance of {@link ObjectGenerator} which value will be converted to JSON. * @return An instance of {@link ObjectGenerator} which converts specified instance of {@link ObjectGenerator} to * JSON. */ public static ObjectGenerator<String> json(ObjectGenerator<?> generator) { return wrap(new JsonTransformer(generator.value)); }
/** * Creates an instance of {@link ObjectGenerator} which generates empty map. * * @param <K> Key type of map which {@link ObjectGenerator} will generate. * @param <V> Value type of map which {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates empty map. */ public static <K, V> ObjectGenerator<Map<K, V>> emptyMap() { return wrap(new EmptyMapValue<>()); }
/** * Creates an instance of {@link ObjectGenerator} which generates current date-time as {@link Date} object. * * @return An instance of {@link ObjectGenerator} which generates current date-time as {@link Date} object. */ public static ObjectGenerator<Date> nowDate() { return wrap(new NowDateValue()); }
/** * Creates an instance of {@link ObjectGenerator} which generates current date as {@link LocalDate} object. * * @return An instance of {@link ObjectGenerator} which generates current date as {@link LocalDate} object. */ public static ObjectGenerator<LocalDate> nowLocalDate() { return wrap(new NowLocalDateValue()); }
/** * Creates an instance of {@link ObjectGenerator} which generates current date-time as {@link LocalDateTime} object. * * @return An instance of {@link ObjectGenerator} which generates current date-time as {@link LocalDateTime} object. */ public static ObjectGenerator<LocalDateTime> nowLocalDateTime() { return wrap(new NowLocalDateTimeValue()); }
/** * Creates an instance of {@link ObjectGenerator} which generates uniformly distributed values from specified list. * * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates uniformly distributed values from specified list. */ public static <T> ObjectGenerator<T> random(List<T> values) { return wrap(new DiscreteValue<>(unwrap(values))); }
/** * Creates an instance of {@link ObjectGenerator} which generates a formatted string using the specified format * string and objects. Placeholder for value is defined as '{}', first placeholder uses first value, second, second * value, and so on. * * @param format Format string, * @param values List of values. * @return An instance of {@link ObjectGenerator} which generates formated strings. */ public static ObjectGenerator<String> string(String format, List<Object> values) { return wrap(new StringTransformer(format, unwrapRaw(values))); }
/** * Creates an instance of {@link ObjectGenerator} which generates list containing all values specified. * * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates list containing all values specified. */ public static <T> ObjectGenerator<List<T>> list(List<T> values) { return wrap(new ListValue<>(unwrap(values))); }
/** * Creates an instance of {@link ObjectGenerator} which generates specified values distributed by their weights. * * @param pairs List of values with corresponding weights. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates specified values distributed by their weights. */ public static <T> ObjectGenerator<T> weighted(List<WeightPair<T>> pairs) { return wrap(new WeightedValue<>(unwrapWeightPairs(pairs))); }
/** * Creates an instance of {@link ObjectGenerator} which generates a formatted string using the specified format * string and objects. Placeholder for value is defined as '{}', first placeholder uses first value, second, second * value, and so on. * * @param format Format string, * @param values List of values. * @return An instance of {@link ObjectGenerator} which generates formated strings. */ public static ObjectGenerator<String> string(String format, List<Object> values) { return wrap(new StringTransformer(format, unwrapRaw(values))); }
/** * Creates an instance of {@link ObjectGenerator} which generates list containing all values specified. * * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates list containing all values specified. */ public static <T> ObjectGenerator<List<T>> list(List<T> values) { return wrap(new ListValue<>(unwrap(values))); }