Skip to content

Commit

Permalink
update javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
fmbenhassine committed Mar 17, 2019
1 parent 31ba6b7 commit b8476b2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,18 @@ public class EasyRandom extends Random {

private final ExclusionPolicy exclusionPolicy;

/**
* Create a new {@link EasyRandom} instance with default parameters.
*/
public EasyRandom() {
this(new EasyRandomParameters());
}

/**
* Create a new {@link EasyRandom} instance.
*
* @param easyRandomParameters randomization parameters
*/
public EasyRandom(final EasyRandomParameters easyRandomParameters) {
Objects.requireNonNull(easyRandomParameters, "Parameters must not be null");
super.setSeed(easyRandomParameters.getSeed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public class EasyRandomParameters {
private Set<Predicate<Field>> fieldExclusionPredicates;
private Set<Predicate<Class<?>>> typeExclusionPredicates;

/**
* Create a new {@link EasyRandomParameters} with default values.
*/
public EasyRandomParameters() {
seed = DEFAULT_SEED;
charset = DEFAULT_CHARSET;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
* <ul>
* <li>{@link EasyRandom} whenever the field is a user defined type.</li>
* <li>{@link ArrayPopulator} whenever the field is an array type.</li>
* <li>{@link CollectionPopulator}, {@link MapPopulator} whenever the field is a collection type.</li>
* <li>{@link CollectionPopulator} whenever the field is a collection type.</li>
* <li>{@link CollectionPopulator}whenever the field is a map type.</li>
* </ul>
*
* @author Mahmoud Ben Hassine ([email protected])
*/
class FieldPopulator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ public static boolean isAnnotationPresent(Field field, Class<? extends Annotatio
return field.isAnnotationPresent(annotationType) || readMethod.isPresent() && readMethod.get().isAnnotationPresent(annotationType);
}

/**
* Return an empty implementation for a {@link Collection} type.
*
* @param collectionInterface for which an empty implementation should be returned
* @return empty implementation for the collection interface
*/
public static Collection<?> getEmptyImplementationForCollectionInterface(final Class<?> collectionInterface) {
Collection<?> collection = new ArrayList<>();
if (List.class.isAssignableFrom(collectionInterface)) {
Expand All @@ -445,6 +451,12 @@ public static Collection<?> getEmptyImplementationForCollectionInterface(final C
return collection;
}

/**
* Create an empty collection for the given type.
* @param fieldType for which an empty collection should we created
* @param initialSize initial size of the collection
* @return empty collection
*/
public static Collection<?> createEmptyCollectionForType(Class<?> fieldType, int initialSize) {
rejectUnsupportedTypes(fieldType);
Collection<?> collection;
Expand All @@ -460,6 +472,11 @@ public static Collection<?> createEmptyCollectionForType(Class<?> fieldType, int
return collection;
}

/**
* Return an empty implementation for the given {@link Map} interface.
* @param mapInterface for which an empty implementation should be returned
* @return empty implementation for the given {@link Map} interface.
*/
public static Map<?, ?> getEmptyImplementationForMapInterface(final Class<?> mapInterface) {
Map<?, ?> map = new HashMap<>();
if (ConcurrentNavigableMap.class.isAssignableFrom(mapInterface)) {
Expand Down

0 comments on commit b8476b2

Please sign in to comment.