From 6a0b26af099e3f2b73b769f3a55450c497c3171a Mon Sep 17 00:00:00 2001
From: Guillermo Calvo <guillermo@guillermo.dev>
Date: Sat, 24 Aug 2024 15:56:24 +0200
Subject: [PATCH] Refactor Guava's `Optional` usage in favor of JDK8's

---
 .../src/test/java/japicmp/maven/util/CtClassBuilder.java   | 4 ++--
 .../test/java/japicmp/maven/util/CtInterfaceBuilder.java   | 7 ++++---
 .../test/java/japicmp/test/service/MavenPluginTestIT.java  | 4 ++--
 japicmp/src/test/java/japicmp/util/CtClassBuilder.java     | 4 ++--
 japicmp/src/test/java/japicmp/util/CtInterfaceBuilder.java | 7 ++++---
 5 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtClassBuilder.java b/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtClassBuilder.java
index 5a8346217..14ccf2989 100644
--- a/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtClassBuilder.java
+++ b/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtClassBuilder.java
@@ -1,6 +1,5 @@
 package japicmp.maven.util;
 
-import com.google.common.base.Optional;
 import japicmp.util.ModifierHelper;
 import javassist.ClassPool;
 import javassist.CtClass;
@@ -12,13 +11,14 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 public class CtClassBuilder {
 	private static final String DEFAULT_CLASS_NAME = "japicmp.Test";
 	private String name = DEFAULT_CLASS_NAME;
 	private int modifier = Modifier.PUBLIC;
 	private final List<String> annotations = new ArrayList<>();
-	private Optional<CtClass> superclass = Optional.absent();
+	private Optional<CtClass> superclass = Optional.empty();
 	private final List<CtClass> interfaces = new ArrayList<>();
 
 	public CtClassBuilder name(String name) {
diff --git a/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtInterfaceBuilder.java b/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtInterfaceBuilder.java
index 4f6efa954..db41cc4f8 100644
--- a/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtInterfaceBuilder.java
+++ b/japicmp-maven-plugin/src/test/java/japicmp/maven/util/CtInterfaceBuilder.java
@@ -1,13 +1,14 @@
 package japicmp.maven.util;
 
-import com.google.common.base.Optional;
 import javassist.CannotCompileException;
 import javassist.ClassPool;
 import javassist.CtClass;
 
+import java.util.Optional;
+
 public class CtInterfaceBuilder {
 	private String name = "japicmp.Test";
-	private Optional<CtClass> superInterfaceOptional = Optional.absent();
+	private Optional<CtClass> superInterfaceOptional = Optional.empty();
 
 	public CtInterfaceBuilder name(String name) {
 		this.name = name;
@@ -29,7 +30,7 @@ public static CtInterfaceBuilder create() {
 	}
 
 	public CtInterfaceBuilder withSuperInterface(CtClass superInterface) {
-		this.superInterfaceOptional = Optional.fromNullable(superInterface);
+		this.superInterfaceOptional = Optional.ofNullable(superInterface);
 		return this;
 	}
 }
diff --git a/japicmp-testbase/japicmp-test-service-impl-base/japicmp-test-service-test/src/test/java/japicmp/test/service/MavenPluginTestIT.java b/japicmp-testbase/japicmp-test-service-impl-base/japicmp-test-service-test/src/test/java/japicmp/test/service/MavenPluginTestIT.java
index f8502d47d..2b8de6756 100644
--- a/japicmp-testbase/japicmp-test-service-impl-base/japicmp-test-service-test/src/test/java/japicmp/test/service/MavenPluginTestIT.java
+++ b/japicmp-testbase/japicmp-test-service-impl-base/japicmp-test-service-test/src/test/java/japicmp/test/service/MavenPluginTestIT.java
@@ -1,6 +1,5 @@
 package japicmp.test.service;
 
-import com.google.common.base.Optional;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -9,6 +8,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
+import java.util.Optional;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -30,6 +30,6 @@ private Optional<String> findLineThatContains(List<String> lines, String str) {
 				return Optional.of(line);
 			}
 		}
-		return Optional.absent();
+		return Optional.empty();
 	}
 }
diff --git a/japicmp/src/test/java/japicmp/util/CtClassBuilder.java b/japicmp/src/test/java/japicmp/util/CtClassBuilder.java
index dd5f23bae..01ce7b3f8 100644
--- a/japicmp/src/test/java/japicmp/util/CtClassBuilder.java
+++ b/japicmp/src/test/java/japicmp/util/CtClassBuilder.java
@@ -1,6 +1,5 @@
 package japicmp.util;
 
-import com.google.common.base.Optional;
 import javassist.ClassPool;
 import javassist.CtClass;
 import javassist.Modifier;
@@ -13,13 +12,14 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 public class CtClassBuilder {
 	public static final String DEFAULT_CLASS_NAME = "japicmp.Test";
 	private String name = DEFAULT_CLASS_NAME;
 	private int modifier = Modifier.PUBLIC;
 	private final Map<String, CtElement[]> annotations = new HashMap<>();
-	private Optional<CtClass> superclass = Optional.absent();
+	private Optional<CtClass> superclass = Optional.empty();
 	private final List<CtClass> interfaces = new ArrayList<>();
 
 	public CtClassBuilder name(String name) {
diff --git a/japicmp/src/test/java/japicmp/util/CtInterfaceBuilder.java b/japicmp/src/test/java/japicmp/util/CtInterfaceBuilder.java
index eef3e0022..c9d8f2b44 100644
--- a/japicmp/src/test/java/japicmp/util/CtInterfaceBuilder.java
+++ b/japicmp/src/test/java/japicmp/util/CtInterfaceBuilder.java
@@ -1,13 +1,14 @@
 package japicmp.util;
 
-import com.google.common.base.Optional;
 import javassist.CannotCompileException;
 import javassist.ClassPool;
 import javassist.CtClass;
 
+import java.util.Optional;
+
 public class CtInterfaceBuilder {
 	private String name = "japicmp.Test";
-	private Optional<CtClass> superInterfaceOptional = Optional.absent();
+	private Optional<CtClass> superInterfaceOptional = Optional.empty();
 
 	public CtInterfaceBuilder name(String name) {
 		this.name = name;
@@ -29,7 +30,7 @@ public static CtInterfaceBuilder create() {
 	}
 
 	public CtInterfaceBuilder withSuperInterface(CtClass superInterface) {
-		this.superInterfaceOptional = Optional.fromNullable(superInterface);
+		this.superInterfaceOptional = Optional.ofNullable(superInterface);
 		return this;
 	}
 }