diff --git a/src/main/java/no/nav/fpsak/nare/doc/RuleDescriptionDigraph.java b/src/main/java/no/nav/fpsak/nare/doc/RuleDescriptionDigraph.java index 8d6173a..20b8940 100644 --- a/src/main/java/no/nav/fpsak/nare/doc/RuleDescriptionDigraph.java +++ b/src/main/java/no/nav/fpsak/nare/doc/RuleDescriptionDigraph.java @@ -42,7 +42,7 @@ public RuleDescriptionDigraph(RuleDescription root, RuleNodeIdProducer idProduce } //bruk istedet den andre constructoren - @Deprecated(forRemoval = true, since = "2.5.0") + @Deprecated(forRemoval = true, since = "2.6.0") public RuleDescriptionDigraph(RuleDescription root, RuleNodeIdProducer idProducer) { this.idProducer = idProducer; this.root = process(root); diff --git a/src/main/java/no/nav/fpsak/nare/doc/RuleNode.java b/src/main/java/no/nav/fpsak/nare/doc/RuleNode.java index c4f74c9..5129abd 100644 --- a/src/main/java/no/nav/fpsak/nare/doc/RuleNode.java +++ b/src/main/java/no/nav/fpsak/nare/doc/RuleNode.java @@ -13,7 +13,7 @@ public class RuleNode { private final Operator operator; private RuleDescription rule; - @Deprecated(forRemoval = true, since = "2.5.0") + @Deprecated(forRemoval = true, since = "2.6.0") public RuleNode(String ruleId, String ruleDescription, Operator operator) { this.id = UUID.randomUUID().toString(); this.ruleId = ruleId; @@ -21,7 +21,7 @@ public RuleNode(String ruleId, String ruleDescription, Operator operator) { this.operator = operator; } - @Deprecated(forRemoval = true, since = "2.5.0") + @Deprecated(forRemoval = true, since = "2.6.0") public RuleNode(RuleDescription node) { this.id = UUID.randomUUID().toString(); this.ruleId = node.getRuleIdentification(); diff --git a/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationSerializer.java b/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationSerializer.java index ef4a21a..433fb58 100644 --- a/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationSerializer.java +++ b/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationSerializer.java @@ -11,19 +11,26 @@ public class EvaluationSerializer { + + public static String asJson(Evaluation evaluation) { + var desc = evaluation.toRuleDescription(); + RuleDescriptionDigraph digraph = new RuleDescriptionDigraph(desc, new EvaluationSerializer.IncrementalIdProcucer(), Map.of()); + return digraph.toJson(); + } + public static String asJson(Evaluation evaluation, EvaluationVersion... versions) { var desc = evaluation.toRuleDescription(); - RuleDescriptionDigraph digraph = new RuleDescriptionDigraph(desc, new EvaluationSerializer.IncrementalIdProcucer(), toVerisonsMap(versions)); + RuleDescriptionDigraph digraph = new RuleDescriptionDigraph(desc, new EvaluationSerializer.IncrementalIdProcucer(), toVersionsMap(versions)); return digraph.toJson(); } public static String asJson(Specification specification, EvaluationVersion... versions) { - RuleDescriptionDigraph digraph = new RuleDescriptionDigraph(specification.ruleDescription(), new EvaluationSerializer.IncrementalIdProcucer(), toVerisonsMap(versions)); + RuleDescriptionDigraph digraph = new RuleDescriptionDigraph(specification.ruleDescription(), new EvaluationSerializer.IncrementalIdProcucer(), toVersionsMap(versions)); return digraph.toJson(); } - private static Map toVerisonsMap(EvaluationVersion[] versions) { - Map map = Arrays.stream(versions).collect(Collectors.toMap(EvaluationVersion::getName, EvaluationVersion::getVersion)); + private static Map toVersionsMap(EvaluationVersion[] versions) { + Map map = Arrays.stream(versions).collect(Collectors.toMap(EvaluationVersion::name, EvaluationVersion::version)); //hvis ingen versjoner er oppgitt, sender inn null for å unngå å få med versjon-elementet i sin helhet return map.isEmpty() ? null : map; } diff --git a/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationVersion.java b/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationVersion.java index 8cb75d0..a3c21e8 100644 --- a/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationVersion.java +++ b/src/main/java/no/nav/fpsak/nare/evaluation/summary/EvaluationVersion.java @@ -2,21 +2,19 @@ import java.util.Objects; -public class EvaluationVersion { - private String name; - private String version; +public record EvaluationVersion(String name, String version) { - public EvaluationVersion(String name, String version) { + public EvaluationVersion { Objects.requireNonNull(name, "name"); - Objects.requireNonNull(name, "version"); - this.name = name; - this.version = version; + Objects.requireNonNull(version, "version"); } + @Deprecated(forRemoval = true, since = "2.6.0") public String getName() { return name; } + @Deprecated(forRemoval = true, since = "2.6.0") public String getVersion() { return version; }