Skip to content

Commit

Permalink
adds periodAndDuration constructor using a periodAndDuration value.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsessanchez committed Aug 15, 2023
1 parent 1a1fc24 commit dfa1e89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public Period getPeriod() {
public Duration getDuration() {
return duration;
}

/**
* Non-public Constructor for PeriodAndDuration
* @param period The {@code Period} component of the aggregate type
Expand All @@ -72,7 +71,6 @@ private PeriodAndDuration(@Nonnull Period period, @Nonnull Duration duration) {
this.period = period;
this.duration = duration;
}

/**
* Creates an instance based on a period and duration.
* @param period the {@code Period}, not null
Expand All @@ -85,7 +83,6 @@ public static PeriodAndDuration of(@Nonnull Period period, @Nonnull Duration dur
Objects.requireNonNull(duration, "parameter duration cannot be null");
return new PeriodAndDuration(period, duration);
}

/**
* Creates an instance based on a period.
* @param period the {@code Period}, not null
Expand All @@ -96,7 +93,6 @@ public static PeriodAndDuration ofPeriod(@Nonnull Period period) {
Objects.requireNonNull(period, "parameter period cannot be null");
return new PeriodAndDuration(period, Duration.ZERO);
}

/**
* Creates an instance based on a duration.
* @param duration the {@code Duration}, not null
Expand All @@ -107,7 +103,16 @@ public static PeriodAndDuration ofDuration(@Nonnull Duration duration) {
Objects.requireNonNull(duration, "parameter duration cannot be null");
return new PeriodAndDuration(Period.ZERO, duration);
}

/**
* Creates an instance based on a PeriodAndDuration.
* @param periodAndDuration the {@code PeriodAndDuration}, not null
* @return the combined {@code PeriodAndDuration}, not null
*/
@Nonnull
public static PeriodAndDuration ofPeriodAndDuration(@Nonnull PeriodAndDuration periodAndDuration) {
Objects.requireNonNull(periodAndDuration, "parameter periodAndDuration cannot be null");
return new PeriodAndDuration(periodAndDuration.getPeriod(), periodAndDuration.getDuration());
}
/**
* @param stringValue the {@code String} parse from.
* @return parsed instance of {@code PeriodAndDuration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public PeriodAndDuration getWorkDuration() {
}

public void setWorkDuration(PeriodAndDuration value) {
this._workDuration = PeriodAndDuration.of(value.getPeriod(), value.getDuration());
this._workDuration = PeriodAndDuration.ofPeriodAndDuration(value);
}

private LocalTime _startWorkTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public PeriodAndDuration getWorkDuration() {
}

public void setWorkDuration(PeriodAndDuration value) {
this._workDuration = PeriodAndDuration.of(value.getPeriod(), value.getDuration());
this._workDuration = PeriodAndDuration.ofPeriodAndDuration(value);
}

private LocalTime _startWorkTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public PeriodAndDuration getWorkDuration() {
}

public void setWorkDuration(PeriodAndDuration value) {
this._workDuration = PeriodAndDuration.of(value.getPeriod(), value.getDuration());
this._workDuration = PeriodAndDuration.ofPeriodAndDuration(value);
}

private LocalTime _startWorkTime;
Expand Down

0 comments on commit dfa1e89

Please sign in to comment.