From 6ad32131c7a43f692ae3b51036601a79c22dab5f Mon Sep 17 00:00:00 2001
From: Jens-Otto Larsen <46576810+jolarsen@users.noreply.github.com>
Date: Wed, 12 May 2021 09:32:18 +0200
Subject: [PATCH] Java16 (#70)
* Java16
---
.github/workflows/build-pr.yml | 2 +-
.github/workflows/build.yml | 2 +-
.github/workflows/release.yml | 2 +-
.java-version | 2 +-
pom.xml | 6 +++---
src/main/java/no/nav/fpsak/nare/doc/RuleEdge.java | 10 ++--------
.../nav/fpsak/nare/doc/doclet/GrunnlagModell.java | 11 +----------
.../no/nav/fpsak/nare/doc/doclet/RegelModell.java | 4 ++--
.../nav/fpsak/nare/doc/doclet/RegelflytModell.java | 14 +++-----------
.../fpsak/nare/doc/doclet/RegelmodellDoclet.java | 2 +-
.../nare/evaluation/EvaluationRuleDescription.java | 2 +-
.../fpsak/nare/doc/doclet/DummyRegelService.java | 4 ++--
.../regler/HarRettTilForeldrePenger.java | 2 +-
.../regler/HarUttaksplanForModreKvote.java | 4 ++--
14 files changed, 22 insertions(+), 45 deletions(-)
diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml
index 12e2b32..72561e0 100644
--- a/.github/workflows/build-pr.yml
+++ b/.github/workflows/build-pr.yml
@@ -23,7 +23,7 @@ jobs:
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
- java-version: 11
+ java-version: 16
- name: Hent tag
run: echo "TAG=$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Build
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9cb40b2..d07981b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -33,7 +33,7 @@ jobs:
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
- java-version: 11
+ java-version: 16
- name: Hent tag
run: echo "TAG=$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 499bebd..6c722dc 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -15,7 +15,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: '16'
distribution: 'adopt'
- name: Setup build cache
diff --git a/.java-version b/.java-version
index 2dbc24b..b6a7d89 100644
--- a/.java-version
+++ b/.java-version
@@ -1 +1 @@
-11.0
+16
diff --git a/pom.xml b/pom.xml
index b78f9d9..5c9e6b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
UTF-8
UTF-8
1.0-SNAPSHOT
- 11
+ 16
5.7.1
${java.version}
${java.version}
@@ -124,7 +124,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.6
+ 0.8.7
report
@@ -155,7 +155,7 @@
org.sonarsource.scanner.maven
sonar-maven-plugin
- 3.8.0.2131
+ 3.9.0.2155
org.apache.maven.plugins
diff --git a/src/main/java/no/nav/fpsak/nare/doc/RuleEdge.java b/src/main/java/no/nav/fpsak/nare/doc/RuleEdge.java
index 23ce7c2..9e86d12 100644
--- a/src/main/java/no/nav/fpsak/nare/doc/RuleEdge.java
+++ b/src/main/java/no/nav/fpsak/nare/doc/RuleEdge.java
@@ -4,14 +4,8 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@JsonInclude(Include.NON_NULL)
-public class RuleEdge {
- String source;
- String target;
- String role;
-
+public record RuleEdge(String source, String target, String role) {
public RuleEdge(RuleNode source, RuleNode target, String edgeRole) {
- this.source = source.id;
- this.target = target.id;
- role = edgeRole;
+ this(source.id, target.id, edgeRole);
}
}
\ No newline at end of file
diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java
index d322dc6..6a18fb9 100644
--- a/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java
+++ b/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java
@@ -16,16 +16,7 @@ class GrunnlagModell implements MarkupOutput {
private final List entries = new ArrayList<>();
private DocletEnvironment docEnv;
- static class Entry {
- TypeElement targetClass;
- String name;
- String classDoc;
-
- Entry(TypeElement targetClass, String name, String classDoc) {
- this.targetClass = targetClass;
- this.name = name;
- this.classDoc = classDoc;
- }
+ static record Entry(TypeElement targetClass, String name, String classDoc) {
}
public GrunnlagModell(DocletEnvironment docEnv) {
diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java
index fef8ac7..d57211a 100644
--- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java
+++ b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java
@@ -37,7 +37,7 @@ static class Entry {
private static Optional getRuleServiceITypeName(Type[] interfaces) {
Optional getGenericInterfaceTypeName = Optional.empty();
Optional ruleServiceType = Arrays.stream(interfaces)
- .filter(interfaze -> isRuleService(interfaze))
+ .filter(RegelModell::isRuleService)
.findFirst();
if (ruleServiceType.isPresent()) {
@@ -96,7 +96,7 @@ private Optional getGenericType(Entry entry) {
Type[] interfaces = entry.targetClass.getGenericInterfaces();
Optional genericTypeName = getRuleServiceITypeName(interfaces);
- if (!genericTypeName.isPresent()) {
+ if (genericTypeName.isEmpty()) {
Class> c = entry.targetClass.getSuperclass();
Type[] superclassGenericTypes = c.getGenericInterfaces();
if (superclassGenericTypes == null || superclassGenericTypes.length == 0) {
diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java
index 88963fb..ed128f4 100644
--- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java
+++ b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java
@@ -9,17 +9,9 @@ class RegelflytModell implements MarkupOutput {
private final List entries = new ArrayList<>();
- static class Entry {
- String name;
- String simpleName;
-
- private Entry(String qualifiedName) {
- this.name = qualifiedName;
- this.simpleName = simplifyName(qualifiedName);
- }
-
- private String simplifyName(String name) {
- return name.replaceAll("\\.", "_").toLowerCase();
+ static record Entry(String name, String simpleName) {
+ Entry(String name) {
+ this(name, name.replaceAll("\\.", "_").toLowerCase());
}
}
diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java
index f521865..45b8762 100644
--- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java
+++ b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java
@@ -50,7 +50,7 @@ public boolean run(DocletEnvironment docEnv) {
RegelflytDoc regelflytDoc = new RegelflytDoc(docEnv, regelModell, getOutputLocation());
try {
Set types = ElementFilter.typesIn(docEnv.getIncludedElements());
- types.stream().forEach(t -> regelflytDoc.process(t));
+ types.stream().forEach(regelflytDoc::process);
File outputFileAdoc = new File(getOutputLocation(), "regler");
new AsciidocMapper().writeTo(outputFileAdoc.toPath(), regelModell);
return true;
diff --git a/src/main/java/no/nav/fpsak/nare/evaluation/EvaluationRuleDescription.java b/src/main/java/no/nav/fpsak/nare/evaluation/EvaluationRuleDescription.java
index aad6ad0..d015c09 100644
--- a/src/main/java/no/nav/fpsak/nare/evaluation/EvaluationRuleDescription.java
+++ b/src/main/java/no/nav/fpsak/nare/evaluation/EvaluationRuleDescription.java
@@ -28,7 +28,7 @@ public EvaluationRuleDescription(Operator operator, Evaluation evaluation,
List extends Evaluation> children) {
super(operator, evaluation.ruleIdentification(), evaluation.ruleDescriptionText(),
children == null ? Collections.emptyList()
- : children.stream().map(c -> c.toRuleDescription()).collect(Collectors.toList()));
+ : children.stream().map(Evaluation::toRuleDescription).collect(Collectors.toList()));
this.resultat = evaluation.result();
this.reason = evaluation.reason();
this.evaluationProperties = evaluation.getEvaluationProperties();
diff --git a/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java b/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java
index 5d2cda9..0befa0d 100644
--- a/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java
+++ b/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java
@@ -12,11 +12,11 @@ public class DummyRegelService implements RuleService {
@SuppressWarnings("unchecked")
@Override
public Specification getSpecification() {
- return new LeafSpecification("hello.spec") {
+ return new LeafSpecification<>("hello.spec") {
@Override
public Evaluation evaluate(DummyRegelInput t) {
- throw new UnsupportedOperationException("not implemented");
+ throw new UnsupportedOperationException("not implemented");
}
};
}
diff --git a/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarRettTilForeldrePenger.java b/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarRettTilForeldrePenger.java
index 7fadf0e..5ae5709 100644
--- a/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarRettTilForeldrePenger.java
+++ b/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarRettTilForeldrePenger.java
@@ -31,7 +31,7 @@ public String beskrivelse() {
public Evaluation evaluate(Soknad soknad) {
Optional søker = soknad.getSøker(rolle);
- if (!søker.isPresent()) {
+ if (søker.isEmpty()) {
return nei(ModrekvoteUtfall.ROLLE_INGEN_SØKER_MED_ROLLE, rolle);
} else if (!søker.get().harRettTilForeldrepenger()) {
return nei(ModrekvoteUtfall.ROLLE_HAR_IKKE_RETT, rolle);
diff --git a/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarUttaksplanForModreKvote.java b/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarUttaksplanForModreKvote.java
index 65cb1c2..02eb86e 100644
--- a/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarUttaksplanForModreKvote.java
+++ b/src/test/java/no/nav/fpsak/nare/specification/modrekvote/regler/HarUttaksplanForModreKvote.java
@@ -35,11 +35,11 @@ private HarUttaksplanForModreKvote(String id, Soknadstype soknadstype, Uttakspla
@Override
public Evaluation evaluate(Soknad soknad) {
Optional soker = soknad.getSøker(MOR);
- if (!soker.isPresent()) {
+ if (soker.isEmpty()) {
return nei(ModrekvoteUtfall.ROLLE_INGEN_SØKER_MED_ROLLE, MOR);
}
- if (!soker.get().getUttaksplan().isPresent()) {
+ if (soker.get().getUttaksplan().isEmpty()) {
return nei(ModrekvoteUtfall.UTTAKSPLAN_MANGLER, MOR);
}