Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/net/datafaker/internal/helper/CopyOnWriteMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import java.util.function.Supplier;

/**
* This is a Copy On Write map. The main idea behind is that
* there is lots of static info per provider to make this provider working.
* At the same time there is no need to load all this info at start since
* This is a Copy On Write map. The main idea behind this is that
* there is lots of static info per provider to make the providers operate.
* At the same time there is no need to load all the info at the start since
* we don't know which providers will be used and loading for all takes time.
* For that reason it is loaded on request and stores in these Copy On Write maps.
* For that reason it is loaded on request and stored in these Copy On Write maps.
* Since it is loaded only once per provider and after that is only read then
* it should be ok and moreover it will allow to have non blocking reads.
* it should be ok and moreover it will allow to have non-blocking reads.
*
* In case for whatever reason there is a need to change this class,
* please double check jmh report before and after e.g.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/datafaker/providers/base/TimeAndDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/
public class TimeAndDate extends AbstractProvider<BaseProviders> {

private static final int DEFAULT_MIN_AGE = 18;
private static final int DEFAULT_MAX_AGE = 65;
public static final int DEFAULT_MIN_AGE = 18;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably package protected would be fine too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'll adjust in another in the next few days

public static final int DEFAULT_MAX_AGE = 65;

protected TimeAndDate(BaseProviders faker) {
super(faker);
Expand Down Expand Up @@ -329,7 +329,7 @@ public Period period(Period min, Period max) {
faker.random().nextInt(min.getDays(), max.getDays()));
}

private String formatInstant(TemporalAccessor instant, String pattern) {
private static String formatInstant(TemporalAccessor instant, String pattern) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern)
.withZone(ZoneId.systemDefault());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void testBetweenThenLargerThanNow() {
@RepeatedTest(100)
void testBirthday() {
final LocalDateTime now = LocalDateTime.now();
final LocalDate from = now.minusYears(18).toLocalDate();
final LocalDate to = now.minusYears(65).toLocalDate();
final LocalDate from = now.minusYears(TimeAndDate.DEFAULT_MIN_AGE).toLocalDate();
final LocalDate to = now.minusYears(TimeAndDate.DEFAULT_MAX_AGE).toLocalDate();
LocalDate birthday = timeAndDate.birthday();
assertThat(birthday).isBetween(to, from);
}
Expand Down