Skip to content

Commit

Permalink
Deployer litt logging for inntektsgenerator-service
Browse files Browse the repository at this point in the history
#deploy-inntektsmelding-generator-service
  • Loading branch information
stigus committed Jun 5, 2024
1 parent 93416a5 commit 1092764
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private XmlConverter() {
}

public static <T> String toXml(JAXBElement<T> value, Class<T> clazz) {
log.debug("Konverterer Jaxb element til XML: value: {}, clazz: {}", value, clazz.getName());
try {
JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

Expand Down Expand Up @@ -55,21 +56,6 @@ public static <T> boolean validate(String xml, Class<T> clazz) {
}
}


@SuppressWarnings("unchecked")
private static <T> T toObject(String xml, Class<T> clazz) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

return (T) unmarshaller.unmarshal(new StringReader(xml));

} catch (JAXBException e) {
throw new JaxbToXmlException("klarte ikke å konvertere Jaxb element til Objekt", e);
}
}

public static BigDecimal toBigDecimal(Double value) {

return nonNull(value) ? BigDecimal.valueOf(value) : null;
Expand All @@ -89,4 +75,18 @@ public static LocalDate toLocalDate(LocalDateTime localDateTime) {

return nonNull(localDateTime) ? localDateTime.toLocalDate() : null;
}

@SuppressWarnings("unchecked")
private static <T> T toObject(String xml, Class<T> clazz) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

return (T) unmarshaller.unmarshal(new StringReader(xml));

} catch (JAXBException e) {
throw new JaxbToXmlException("klarte ikke å konvertere Jaxb element til Objekt", e);
}
}
}

0 comments on commit 1092764

Please sign in to comment.