diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 35f7eef1a..e5bc795a4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -7,12 +7,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
- uses: actions/checkout@v1
+ uses: actions/checkout@v6.0.2
with:
ref: master
- - name: Set up JDK 11
- uses: actions/setup-java@v1
+ - name: Set up JDK 17
+ uses: actions/setup-java@v5.2.0
with:
- java-version: 11
+ distribution: 'temurin'
+ java-version: '17'
- name: Build with Maven
- run: mvn clean package
+ run: mvn clean package --batch-mode
diff --git a/LICENSE.txt b/LICENSE.txt
index 6b96290ce..aa1602581 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
+Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 8e026c4d7..b930afa6a 100644
--- a/README.md
+++ b/README.md
@@ -2,15 +2,13 @@
Easy Random
- The simple, stupid random Java™ beans generator
+ The simple, stupid random Java™ objects generator
[](http://opensource.org/licenses/MIT)
[](https://github.com/j-easy/easy-random/actions)
-[](https://repo1.maven.org/maven2/org/jeasy/easy-random-core/5.0.0/)
-[](http://www.javadoc.io/doc/org.jeasy/easy-random-core)
[](https://img.shields.io/badge/Project%20status-Maintenance-orange.svg)
@@ -31,7 +29,7 @@ for now. Please consider upgrading to one of these versions at your earliest con
# What is Easy Random ?
-Easy Random is a library that generates random Java beans. You can think of it as an [ObjectMother](https://martinfowler.com/bliki/ObjectMother.html) for the JVM. Let's say you have a class `Person` and you want to generate a random instance of it, here we go:
+Easy Random is a library that generates random Java objects. You can think of it as an [ObjectMother](https://martinfowler.com/bliki/ObjectMother.html) for the JVM. Let's say you have a class `Person` and you want to generate a random instance of it, here we go:
```java
EasyRandom easyRandom = new EasyRandom();
@@ -108,7 +106,7 @@ Address address = new Address(street, "123456", "London", "United Kingdom");
Person person = new Person("Foo", "Bar", "foo.bar@gmail.com", Gender.MALE, address);
```
-And if these classes do not provide constructors with parameters (may be some legacy beans you can't change), you would write:
+And if these classes do not provide constructors with parameters (may be some legacy types you can't change), you would write:
```java
Street street = new Street();
diff --git a/easy-random-bean-validation/pom.xml b/easy-random-bean-validation/pom.xml
deleted file mode 100644
index 18ccdd821..000000000
--- a/easy-random-bean-validation/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
- easy-random
- org.jeasy
- 5.0.1-SNAPSHOT
-
- 4.0.0
-
- Easy Random Bean Validation
- easy-random-bean-validation
- Easy Random module for Bean Validation API support
- https://github.com/j-easy/easy-random
-
-
- git@github.com:j-easy/easy-random.git
- scm:git:git@github.com:j-easy/easy-random.git
- scm:git:git@github.com:j-easy/easy-random.git
- HEAD
-
-
-
- Github Actions
- https://github.com/j-easy/easy-random/actions
-
-
-
- GitHub
- https://github.com/j-easy/easy-random
-
-
-
-
- MIT License
- http://opensource.org/licenses/mit-license.php
-
-
-
-
-
- benas
- Mahmoud Ben Hassine
- http://benas.github.io
- mahmoud.benhassine@icloud.com
-
- Lead developer
-
-
-
-
-
-
- org.jeasy
- easy-random-randomizers
-
-
- javax.validation
- validation-api
-
-
- org.hibernate
- hibernate-validator
- test
-
-
- org.glassfish
- javax.el
- test
-
-
- org.junit.jupiter
- junit-jupiter
- test
-
-
- org.assertj
- assertj-core
- test
-
-
-
-
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AbstractNumberBaseAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AbstractNumberBaseAnnotationHandler.java
deleted file mode 100644
index f3a2fe4de..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AbstractNumberBaseAnnotationHandler.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.randomizers.range.*;
-import org.jeasy.random.randomizers.text.StringDelegatingRandomizer;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Random;
-
-/**
- * @author dadiyang
- * @since 4.3
- */
-public abstract class AbstractNumberBaseAnnotationHandler implements BeanValidationAnnotationHandler {
- private final Random random;
-
- AbstractNumberBaseAnnotationHandler(long seed) {
- random = new Random(seed);
- }
-
- protected Randomizer> getRandomizer(Class> fieldType, BigDecimal minValue, BigDecimal maxValue) {
- if (fieldType.equals(Byte.TYPE) || fieldType.equals(Byte.class)) {
- return new ByteRangeRandomizer(
- minValue == null ? null : minValue.byteValue(),
- maxValue == null ? null : maxValue.byteValue(),
- random.nextLong()
- );
- }
- if (fieldType.equals(Short.TYPE) || fieldType.equals(Short.class)) {
- return new ShortRangeRandomizer(
- minValue == null ? null : minValue.shortValue(),
- maxValue == null ? null : maxValue.shortValue(),
- random.nextLong()
- );
- }
- if (fieldType.equals(Integer.TYPE) || fieldType.equals(Integer.class)) {
- return new IntegerRangeRandomizer(
- minValue == null ? null : minValue.intValue(),
- maxValue == null ? null : maxValue.intValue(),
- random.nextLong()
- );
- }
- if (fieldType.equals(Long.TYPE) || fieldType.equals(Long.class)) {
- return new LongRangeRandomizer(
- minValue == null ? null : minValue.longValue(),
- maxValue == null ? null : maxValue.longValue(),
- random.nextLong()
- );
- }
- if (fieldType.equals(BigInteger.class)) {
- return new BigIntegerRangeRandomizer(
- minValue == null ? null : minValue.intValue(),
- maxValue == null ? null : maxValue.intValue(),
- random.nextLong()
- );
- }
- if (fieldType.equals(BigDecimal.class)) {
- return new BigDecimalRangeRandomizer(
- minValue == null ? null : minValue.doubleValue(),
- maxValue == null ? null : maxValue.doubleValue(),
- random.nextLong()
- );
- }
- if (fieldType.equals(String.class)) {
- BigDecimalRangeRandomizer delegate = new BigDecimalRangeRandomizer(
- minValue == null ? null : minValue.doubleValue(),
- maxValue == null ? null : maxValue.doubleValue(),
- random.nextLong()
- );
- return new StringDelegatingRandomizer(delegate);
- }
- return null;
- }
-
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertFalseAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertFalseAnnotationHandler.java
deleted file mode 100644
index a4ca59052..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertFalseAnnotationHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.randomizers.misc.ConstantRandomizer;
-
-import java.lang.reflect.Field;
-
-class AssertFalseAnnotationHandler implements BeanValidationAnnotationHandler {
-
- public Randomizer> getRandomizer(Field field) {
- return new ConstantRandomizer<>(false);
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertTrueAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertTrueAnnotationHandler.java
deleted file mode 100644
index bb7280ed1..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertTrueAnnotationHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.randomizers.misc.ConstantRandomizer;
-
-import java.lang.reflect.Field;
-
-class AssertTrueAnnotationHandler implements BeanValidationAnnotationHandler {
-
- public Randomizer> getRandomizer(Field field) {
- return new ConstantRandomizer<>(true);
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationAnnotationHandler.java
deleted file mode 100644
index 44310425c..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationAnnotationHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-
-import org.jeasy.random.api.Randomizer;
-
-import java.lang.reflect.Field;
-
-interface BeanValidationAnnotationHandler {
-
- Randomizer> getRandomizer(Field field);
-
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationRandomizerRegistry.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationRandomizerRegistry.java
deleted file mode 100644
index 90772fdc2..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationRandomizerRegistry.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.annotation.Priority;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.api.RandomizerRegistry;
-import org.jeasy.random.util.ReflectionUtils;
-
-import javax.validation.constraints.*;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A registry of randomizers to support fields annotated with the JSR 349 annotations.
- *
- * @author Rémi Alvergnat (toilal.dev@gmail.com)
- */
-@Priority(-2)
-public class BeanValidationRandomizerRegistry implements RandomizerRegistry {
-
- protected Map, BeanValidationAnnotationHandler> annotationHandlers = new HashMap<>();
-
- @Override
- public void init(EasyRandomParameters parameters) {
- long seed = parameters.getSeed();
- annotationHandlers.put(AssertFalse.class, new AssertFalseAnnotationHandler());
- annotationHandlers.put(AssertTrue.class, new AssertTrueAnnotationHandler());
- annotationHandlers.put(Null.class, new NullAnnotationHandler());
- annotationHandlers.put(Future.class, new FutureAnnotationHandler(parameters));
- annotationHandlers.put(FutureOrPresent.class, new FutureOrPresentAnnotationHandler(parameters));
- annotationHandlers.put(Past.class, new PastAnnotationHandler(parameters));
- annotationHandlers.put(PastOrPresent.class, new PastOrPresentAnnotationHandler(parameters));
- annotationHandlers.put(Min.class, new MinMaxAnnotationHandler(seed));
- annotationHandlers.put(Max.class, new MinMaxAnnotationHandler(seed));
- annotationHandlers.put(DecimalMin.class, new DecimalMinMaxAnnotationHandler(seed));
- annotationHandlers.put(DecimalMax.class, new DecimalMinMaxAnnotationHandler(seed));
- annotationHandlers.put(Pattern.class, new PatternAnnotationHandler(seed));
- annotationHandlers.put(Size.class, new SizeAnnotationHandler(parameters));
- annotationHandlers.put(Positive.class, new PositiveAnnotationHandler(seed));
- annotationHandlers.put(PositiveOrZero.class, new PositiveOrZeroAnnotationHandler(seed));
- annotationHandlers.put(Negative.class, new NegativeAnnotationHandler(seed));
- annotationHandlers.put(NegativeOrZero.class, new NegativeOrZeroAnnotationHandler(seed));
- annotationHandlers.put(NotBlank.class, new NotBlankAnnotationHandler(seed));
- annotationHandlers.put(Email.class, new EmailAnnotationHandler(seed));
- }
-
- @Override
- public Randomizer> getRandomizer(final Field field) {
-
- for (Map.Entry, BeanValidationAnnotationHandler> entry : annotationHandlers.entrySet()) {
- Class extends Annotation> annotation = entry.getKey();
- BeanValidationAnnotationHandler annotationHandler = entry.getValue();
- if (ReflectionUtils
- .isAnnotationPresent(field, annotation) && annotationHandler != null) {
- return annotationHandler.getRandomizer(field);
- }
- }
- return null;
- }
-
- @Override
- public Randomizer> getRandomizer(Class> fieldType) {
- return null;
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/DecimalMinMaxAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/DecimalMinMaxAnnotationHandler.java
deleted file mode 100644
index 20dc10da1..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/DecimalMinMaxAnnotationHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.util.ReflectionUtils;
-
-import javax.validation.constraints.DecimalMax;
-import javax.validation.constraints.DecimalMin;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-
-class DecimalMinMaxAnnotationHandler extends AbstractNumberBaseAnnotationHandler {
-
- DecimalMinMaxAnnotationHandler(long seed) {
- super(seed);
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- Class> fieldType = field.getType();
- DecimalMax decimalMaxAnnotation = ReflectionUtils
- .getAnnotation(field, DecimalMax.class);
- DecimalMin decimalMinAnnotation = ReflectionUtils
- .getAnnotation(field, DecimalMin.class);
-
- BigDecimal maxValue = null;
- BigDecimal minValue = null;
-
- if (decimalMaxAnnotation != null) {
- maxValue = new BigDecimal(decimalMaxAnnotation.value());
- }
-
- if (decimalMinAnnotation != null) {
- minValue = new BigDecimal(decimalMinAnnotation.value());
- }
- return getRandomizer(fieldType, minValue, maxValue);
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureAnnotationHandler.java
deleted file mode 100644
index 18238f911..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureAnnotationHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import java.lang.reflect.Field;
-import java.time.LocalDate;
-import java.time.temporal.ChronoUnit;
-
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.api.Randomizer;
-
-class FutureAnnotationHandler implements BeanValidationAnnotationHandler {
-
- private EasyRandom easyRandom;
- private EasyRandomParameters parameters;
-
- FutureAnnotationHandler(EasyRandomParameters parameters) {
- this.parameters = parameters.copy();
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- if (easyRandom == null) {
- LocalDate now = LocalDate.now();
- parameters.setDateRange(new EasyRandomParameters.Range<>(
- now.plus(1, ChronoUnit.DAYS),
- now.plusYears(EasyRandomParameters.DEFAULT_DATE_RANGE)
- ));
- easyRandom = new EasyRandom(parameters);
- }
- return () -> easyRandom.nextObject(field.getType());
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureOrPresentAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureOrPresentAnnotationHandler.java
deleted file mode 100644
index f7c46dceb..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureOrPresentAnnotationHandler.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.api.Randomizer;
-
-import java.lang.reflect.Field;
-import java.time.LocalDate;
-
-class FutureOrPresentAnnotationHandler implements BeanValidationAnnotationHandler {
-
- private EasyRandom easyRandom;
- private EasyRandomParameters parameters;
-
- FutureOrPresentAnnotationHandler(EasyRandomParameters parameters) {
- this.parameters = parameters.copy();
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- if (easyRandom == null) {
- LocalDate now = LocalDate.now();
- parameters.setDateRange(new EasyRandomParameters.Range<>(
- now, now.plusYears(EasyRandomParameters.DEFAULT_DATE_RANGE))
- );
- easyRandom = new EasyRandom(parameters);
- }
- return () -> easyRandom.nextObject(field.getType());
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/MinMaxAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/MinMaxAnnotationHandler.java
deleted file mode 100644
index f94818045..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/MinMaxAnnotationHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.util.ReflectionUtils;
-
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-
-class MinMaxAnnotationHandler extends AbstractNumberBaseAnnotationHandler {
-
- MinMaxAnnotationHandler(long seed) {
- super(seed);
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- Class> fieldType = field.getType();
- Max maxAnnotation = ReflectionUtils
- .getAnnotation(field, Max.class);
- Min minAnnotation = ReflectionUtils
- .getAnnotation(field, Min.class);
- BigDecimal maxValue = null;
- BigDecimal minValue = null;
-
- if (maxAnnotation != null) {
- maxValue = new BigDecimal(maxAnnotation.value());
- }
-
- if (minAnnotation != null) {
- minValue = new BigDecimal(minAnnotation.value());
- }
- return getRandomizer(fieldType, minValue, maxValue);
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeAnnotationHandler.java
deleted file mode 100644
index 962f91164..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeAnnotationHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-
-class NegativeAnnotationHandler extends AbstractNumberBaseAnnotationHandler {
-
- NegativeAnnotationHandler(final long seed) {
- super(seed);
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- return getRandomizer(field.getType(), null, BigDecimal.ZERO);
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeOrZeroAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeOrZeroAnnotationHandler.java
deleted file mode 100644
index 9024f85e0..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeOrZeroAnnotationHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-
-class NegativeOrZeroAnnotationHandler extends AbstractNumberBaseAnnotationHandler {
- NegativeOrZeroAnnotationHandler(final long seed) {
- super(seed);
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- return getRandomizer(field.getType(), null, new BigDecimal("0.001"));
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NullAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NullAnnotationHandler.java
deleted file mode 100644
index 972495aa4..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NullAnnotationHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.randomizers.misc.NullRandomizer;
-
-import java.lang.reflect.Field;
-
-class NullAnnotationHandler implements BeanValidationAnnotationHandler {
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- return new NullRandomizer();
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastAnnotationHandler.java
deleted file mode 100644
index b95a22e4f..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastAnnotationHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import java.lang.reflect.Field;
-import java.time.LocalDate;
-import java.time.temporal.ChronoUnit;
-
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.api.Randomizer;
-
-class PastAnnotationHandler implements BeanValidationAnnotationHandler {
-
- private EasyRandom easyRandom;
- private EasyRandomParameters parameters;
-
- PastAnnotationHandler(EasyRandomParameters parameters) {
- this.parameters = parameters.copy();
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- if (easyRandom == null) {
- LocalDate now = LocalDate.now();
- parameters.setDateRange(new EasyRandomParameters.Range<>(
- now.minusYears(EasyRandomParameters.DEFAULT_DATE_RANGE),
- now.minus(1, ChronoUnit.DAYS)
- ));
- easyRandom = new EasyRandom(parameters);
- }
- return () -> easyRandom.nextObject(field.getType());
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastOrPresentAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastOrPresentAnnotationHandler.java
deleted file mode 100644
index 2fa4387be..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastOrPresentAnnotationHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.api.Randomizer;
-
-import java.lang.reflect.Field;
-import java.time.LocalDate;
-
-class PastOrPresentAnnotationHandler implements BeanValidationAnnotationHandler {
-
- private EasyRandom easyRandom;
- private EasyRandomParameters parameters;
-
- PastOrPresentAnnotationHandler(EasyRandomParameters parameters) {
- this.parameters = parameters.copy();
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- if (easyRandom == null) {
- LocalDate now = LocalDate.now();
- parameters.setDateRange(new EasyRandomParameters.Range<>(
- now.minusYears(EasyRandomParameters.DEFAULT_DATE_RANGE), now));
- easyRandom = new EasyRandom(parameters);
- }
- return () -> easyRandom.nextObject(field.getType());
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PatternAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PatternAnnotationHandler.java
deleted file mode 100644
index b59581cfa..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PatternAnnotationHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.randomizers.RegularExpressionRandomizer;
-import org.jeasy.random.util.ReflectionUtils;
-
-import javax.validation.constraints.Pattern;
-import java.lang.reflect.Field;
-import java.util.Random;
-
-class PatternAnnotationHandler implements BeanValidationAnnotationHandler {
-
- private final Random random;
-
- PatternAnnotationHandler(long seed) {
- random = new Random(seed);
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- Class> fieldType = field.getType();
- Pattern patternAnnotation = ReflectionUtils
- .getAnnotation(field, Pattern.class);
-
- final String regex = patternAnnotation.regexp();
- if (fieldType.equals(String.class)) {
- return new RegularExpressionRandomizer(regex, random.nextLong());
- }
- return null;
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveOrZeroAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveOrZeroAnnotationHandler.java
deleted file mode 100644
index c6837abfb..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveOrZeroAnnotationHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.api.Randomizer;
-
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-
-class PositiveOrZeroAnnotationHandler extends AbstractNumberBaseAnnotationHandler {
-
- PositiveOrZeroAnnotationHandler(final long seed) {
- super(seed);
- }
-
- @Override
- public Randomizer> getRandomizer(Field field) {
- return getRandomizer(field.getType(), BigDecimal.ZERO, null);
- }
-}
diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/SizeAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/SizeAnnotationHandler.java
deleted file mode 100644
index 27e908c68..000000000
--- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/SizeAnnotationHandler.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.jeasy.random.validation;
-
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.api.Randomizer;
-import org.jeasy.random.randomizers.range.IntegerRangeRandomizer;
-import org.jeasy.random.randomizers.text.StringRandomizer;
-import org.jeasy.random.util.ReflectionUtils;
-import org.objenesis.ObjenesisStd;
-
-import javax.validation.constraints.Size;
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.Map;
-
-import static org.jeasy.random.util.ReflectionUtils.*;
-
-class SizeAnnotationHandler implements BeanValidationAnnotationHandler {
-
- private EasyRandom easyRandom;
- private EasyRandomParameters parameters;
-
- SizeAnnotationHandler(EasyRandomParameters parameters) {
- this.parameters = parameters.copy();
- }
-
- @Override
- @SuppressWarnings({"unchecked"})
- public Randomizer> getRandomizer(Field field) {
- Class> fieldType = field.getType();
- Size sizeAnnotation = ReflectionUtils
- .getAnnotation(field, Size.class);
-
- final int min = sizeAnnotation.min();
- final int max = sizeAnnotation.max() == Integer.MAX_VALUE ? 255 : sizeAnnotation.max();
- if (easyRandom == null) {
- easyRandom = new EasyRandom(parameters);
- }
-
- if (fieldType.equals(String.class)) {
- return new StringRandomizer(parameters.getCharset(), min, max, easyRandom.nextLong());
- }
-
- // FIXME: There should be away to reuse code from ArrayPopulator/CollectionPopulator/MapPopulator *without* making them public
-
- if (isArrayType(fieldType)) {
- return (Randomizer