Skip to content

Commit

Permalink
refactor: use record instead of class
Browse files Browse the repository at this point in the history
  • Loading branch information
pcvolkmer committed Aug 15, 2024
1 parent 97f1bc7 commit 0166811
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
package org.miracum.streams.ume.obdstofhir.model;

import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;

@AllArgsConstructor
@Builder
@EqualsAndHashCode
@Getter
public class StructKey implements Serializable {
private String referenzNummer;
private String tumorId;
}
public record StructKey(String referenzNummer, String tumorId) implements Serializable {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public Serializer<StructKey> serializer() {
}
return String.format(
"Struct{REFERENZ_NUMMER=\"%s\",TUMOR_ID=\"%s\"}",
null == structKey.getReferenzNummer() ? "" : structKey.getReferenzNummer(),
null == structKey.getTumorId() ? "" : structKey.getTumorId())
null == structKey.referenzNummer() ? "" : structKey.referenzNummer(),
null == structKey.tumorId() ? "" : structKey.tumorId())
.getBytes(StandardCharsets.UTF_8);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ void shouldDeserializeStructKey() {
.getBytes(StandardCharsets.UTF_8));
assertThat(actual).isEqualTo(new StructKey("01234", "1"));
}

@Test
void shouldUseLombokBuilderForStructKeyRecord() {
var expected = new StructKey("01234", "1");
var actual = StructKey.builder().referenzNummer("01234").tumorId("1").build();

assertThat(actual).isEqualTo(expected);
}
}

0 comments on commit 0166811

Please sign in to comment.