Skip to content

Commit

Permalink
Rename and refactor mapping strategy classes
Browse files Browse the repository at this point in the history
#deploy-skattekort-service

Renamed `TrekktypeMappingStrategy` to `ForskuddstrekkMappingStrategy` for better clarity. Updated variable names inside the class to align with the new name. Modified `Forskuddstrekk` class by adding `AllArgsConstructor` and changing `SuperBuilder` to `Builder`.
  • Loading branch information
krharum committed Aug 9, 2024
1 parent c4b30bd commit 0e61095
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ public void mapAtoB(SkattekortResponsIntermediate.Skattekortmelding source, Skat
})
.register();

// factory.classMap(SkattekortResponsIntermediate.Forskuddstrekk.class, Forskuddstrekk.class)
// .customize(new CustomMapper<>() {
// @Override
// public void mapAtoB(SkattekortResponsIntermediate.Forskuddstrekk source, Forskuddstrekk target, MappingContext context) {
//
// target.setTrekkode(Trekkode.valueOf(source.getTrekkode().getValue()));
// }
// })
// .register();

factory.classMap(SkattekortResponsIntermediate.Frikort.class, Frikort.class)
.customize(new CustomMapper<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static java.util.Objects.nonNull;

@Component
public class TrekktypeMappingStrategy implements MappingStrategy {
public class ForskuddstrekkMappingStrategy implements MappingStrategy {
@Override
public void register(MapperFactory factory) {

Expand All @@ -26,15 +26,15 @@ public void register(MapperFactory factory) {
public void mapAtoB(Skattekort skattekort, no.skatteetaten.fastsetting.formueinntekt.forskudd.skattekorttilarbeidsgiver.v3.Skattekort skattekort2, MappingContext context) {

skattekort2.getForskuddstrekk().addAll(skattekort.getForskuddstrekk().stream()
.map(trekktype -> {
if (nonNull(trekktype.getFrikort())) {
return mapperFacade.map(trekktype.getFrikort(),
.map(forskuddstrekk -> {
if (nonNull(forskuddstrekk.getFrikort())) {
return mapperFacade.map(forskuddstrekk.getFrikort(),
no.skatteetaten.fastsetting.formueinntekt.forskudd.skattekorttilarbeidsgiver.v3.Frikort.class);
} else if (nonNull(trekktype.getTrekktabell())) {
return mapperFacade.map(trekktype.getTrekktabell(),
} else if (nonNull(forskuddstrekk.getTrekktabell())) {
return mapperFacade.map(forskuddstrekk.getTrekktabell(),
no.skatteetaten.fastsetting.formueinntekt.forskudd.skattekorttilarbeidsgiver.v3.Trekktabell.class);
} else if (nonNull(trekktype.getTrekkprosent())) {
return mapperFacade.map(trekktype.getTrekkprosent(),
} else if (nonNull(forskuddstrekk.getTrekkprosent())) {
return mapperFacade.map(forskuddstrekk.getTrekkprosent(),
no.skatteetaten.fastsetting.formueinntekt.forskudd.skattekorttilarbeidsgiver.v3.Trekkprosent.class);
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package no.nav.testnav.libs.dto.skattekortservice.v1;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Arrays;
import java.util.Objects;

@Data
@SuperBuilder
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Forskuddstrekk {

private Frikort frikort;
Expand Down

0 comments on commit 0e61095

Please sign in to comment.