Skip to content

Commit

Permalink
Refactor DTO classes to use Lombok's @DaTa annotation
Browse files Browse the repository at this point in the history
#deploy-test-sykemelding-api

Replaced @value, @Getter, and @Setter with @DaTa for simplicity and consistency across all DTO classes. Removed the forced argument requirement from @NoArgsConstructor where it was previously applied. Additionally, adjusted null handling in the "Arbeidsgiver" domain class to manage DTO presence better.
  • Loading branch information
krharum committed Dec 9, 2024
1 parent 3d8dc32 commit eac553d
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import static java.util.Objects.nonNull;

public class Arbeidsgiver {
private XMLHelseOpplysningerArbeidsuforhet.Arbeidsgiver xmlArbeidsgiver;
private final XMLHelseOpplysningerArbeidsuforhet.Arbeidsgiver xmlArbeidsgiver;

Arbeidsgiver(ArbeidsgiverDTO dto) {
xmlArbeidsgiver = new XMLHelseOpplysningerArbeidsuforhet.Arbeidsgiver()
.withHarArbeidsgiver(new XMLCS()
.withDN("En arbeidsgiver")
.withV("1"))
.withDN(nonNull(dto) ? "En arbeidsgiver" : "Ingen arbeidsgiver")
.withV(nonNull(dto) ? "1" : "3"))
.withNavnArbeidsgiver(nonNull(dto) ? dto.getNavn() : null)
.withYrkesbetegnelse(nonNull(dto) ? dto.getYrkesbetegnelse() : null)
.withStillingsprosent(nonNull(dto) ? getStillingsprosent(dto) : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@EqualsAndHashCode
@NoArgsConstructor
public class AdresseDTO {

private String gate;
private String postnummer;
private String by;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@NoArgsConstructor
public class AktivitetDTO {
private final Integer grad;
private final Boolean reisetilskudd;
private final Integer behandlingsdager;
private final Aktivitet aktivitet;

private Integer grad;
private Boolean reisetilskudd;
private Integer behandlingsdager;
private Aktivitet aktivitet;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@EqualsAndHashCode
@NoArgsConstructor
public class ArbeidsgiverDTO {

private String navn;
private String yrkesbetegnelse;
private Float stillingsprosent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DetaljerDTO {

private String tiltakArbeidsplass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package no.nav.testnav.libs.dto.sykemelding.v1;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@NoArgsConstructor
public class DiagnoseDTO {
@JsonProperty
private String diagnose;

@JsonProperty
private String diagnose;
private String system;

@JsonProperty
private String diagnosekode;
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
package no.nav.testnav.libs.dto.sykemelding.v1;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@EqualsAndHashCode
@NoArgsConstructor
public class HelsepersonellDTO {
@JsonProperty

private String ident;
@JsonProperty
private String fornavn;
@JsonProperty
private String mellomnavn;
@JsonProperty
private String etternavn;
@JsonProperty
private String hprId;
@JsonProperty
private String samhandlerType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@EqualsAndHashCode
@NoArgsConstructor
public class OrganisasjonDTO {
private final String navn;
private final String orgNr;
private final AdresseDTO adresse;

private String navn;
private String orgNr;
private AdresseDTO adresse;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

import java.time.LocalDate;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@EqualsAndHashCode
@NoArgsConstructor
public class PasientDTO {

private String ident;
private String fornavn;
private String mellomnavn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

import java.time.LocalDate;

@Value
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@EqualsAndHashCode
@NoArgsConstructor
public class PeriodeDTO {

private LocalDate fom;
private LocalDate tom;
private AktivitetDTO aktivitet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
@NoArgsConstructor
public class SykemeldingDTO {

private LocalDate startDato;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UtdypendeOpplysningerDTO {

Expand Down

0 comments on commit eac553d

Please sign in to comment.