Skip to content

(chore): Enhance readability of ContentEnricher.java #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ public ContentEnricher(Defaults defaults, DateProvider dateProvider) {
}

public void enrich(Invoice input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand Down Expand Up @@ -83,14 +81,12 @@ public void enrich(DebitNote input) {
}

private void enrichNote(Note input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand All @@ -106,14 +102,12 @@ private void enrichNote(Note input) {
}

public void enrich(VoidedDocuments input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand All @@ -128,14 +122,12 @@ public void enrich(VoidedDocuments input) {
}

public void enrich(SummaryDocuments input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand All @@ -150,14 +142,12 @@ public void enrich(SummaryDocuments input) {
}

public void enrich(Perception input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand All @@ -167,14 +157,12 @@ public void enrich(Perception input) {
}

public void enrich(Retention input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand All @@ -184,14 +172,12 @@ public void enrich(Retention input) {
}

public void enrich(DespatchAdvice input) {
LocalDate systemLocalDate = dateProvider.now();

Stream
.of(RulePhase.PhaseType.ENRICH, RulePhase.PhaseType.PROCESS, RulePhase.PhaseType.SUMMARY)
.forEach(phaseType -> {
// Header
HeaderRuleContext ruleContextHeader = HeaderRuleContext.builder()
.localDate(systemLocalDate)
.localDate(dateProvider.now())
.build();
RuleUnit ruleUnitHeader = new HeaderRuleUnit(phaseType, defaults, ruleContextHeader);
ruleUnitHeader.modify(input);
Expand Down