From 520d3cb363be62aa4147b70586921a95fa695178 Mon Sep 17 00:00:00 2001 From: Jan-Olav Eide Date: Thu, 24 Jun 2021 09:46:57 +0200 Subject: [PATCH] bruk record, deprecae getter --- .../integrasjon/pdl/PDLExceptionDetails.java | 31 ++++++------------- .../pdl/PDLExceptionExtension.java | 22 +++---------- .../felles/integrasjon/pdl/PdlException.java | 4 +++ 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionDetails.java b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionDetails.java index f4c9a6dd8..9ecef04c0 100644 --- a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionDetails.java +++ b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionDetails.java @@ -1,34 +1,21 @@ package no.nav.vedtak.felles.integrasjon.pdl; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PDLExceptionDetails { - private final String type; - private final String cause; - private final String policy; - - @JsonCreator - public PDLExceptionDetails(@JsonProperty("type") String type, @JsonProperty("cause") String cause, @JsonProperty("policy") String policy) { - this.type = type; - this.cause = cause; - this.policy = policy; - } - +public record PDLExceptionDetails(String type, String cause,String policy) { + + @Deprecated(since = "2.3", forRemoval = true) public String getType() { - return type; + return type(); } + @Deprecated(since = "2.3", forRemoval = true) public String getCause() { - return cause; + return cause(); } + @Deprecated(since = "2.3", forRemoval = true) public String getPolicy() { - return policy; + return policy(); } - @Override - public String toString() { - return getClass().getSimpleName() + " [type=" + type + ", cause=" + cause + ", policy=" + policy + "]"; - } + } diff --git a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionExtension.java b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionExtension.java index d2a5f5599..4dfdd6658 100644 --- a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionExtension.java +++ b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PDLExceptionExtension.java @@ -1,29 +1,15 @@ package no.nav.vedtak.felles.integrasjon.pdl; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class PDLExceptionExtension { - private final String code; - private final PDLExceptionDetails details; - - @JsonCreator - public PDLExceptionExtension(@JsonProperty("code") String code, @JsonProperty("details") PDLExceptionDetails details) { - this.code = code; - this.details = details; - } +public record PDLExceptionExtension(String code, PDLExceptionDetails details) { + @Deprecated(since = "2.3", forRemoval = true) public PDLExceptionDetails getDetails() { return details; } + @Deprecated(since = "2.3", forRemoval = true) public String getCode() { - return code; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [code=" + code + ", details=" + details + "]"; + return code(); } } diff --git a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PdlException.java b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PdlException.java index 8fe24670e..ea8490900 100644 --- a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PdlException.java +++ b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/PdlException.java @@ -24,6 +24,10 @@ public PDLExceptionExtension getExtension() { return extension; } + public PDLExceptionDetails getDetails() { + return getExtension().details(); + } + public int getStatus() { return status; }