From e9ffc3c67d4a1341e67ea941f490a4d04834d10e Mon Sep 17 00:00:00 2001 From: Oleksii Kucheruk <50623030+iselo@users.noreply.github.com> Date: Sun, 3 Sep 2023 22:29:23 +0300 Subject: [PATCH] Remove unused classes (#15) --- .../raccoons/meeko/util/OptionalDouble.java | 381 ------------------ .../co/raccoons/meeko/util/OptionalInt.java | 379 ----------------- .../co/raccoons/meeko/util/OptionalLong.java | 379 ----------------- .../meeko/util/OptionalDoubleTest.java | 137 ------- .../raccoons/meeko/util/OptionalIntTest.java | 138 ------- .../raccoons/meeko/util/OptionalLongTest.java | 137 ------- 6 files changed, 1551 deletions(-) delete mode 100644 lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java delete mode 100644 lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java delete mode 100644 lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java delete mode 100644 lib/src/test/java/co/raccoons/meeko/util/OptionalDoubleTest.java delete mode 100644 lib/src/test/java/co/raccoons/meeko/util/OptionalIntTest.java delete mode 100644 lib/src/test/java/co/raccoons/meeko/util/OptionalLongTest.java diff --git a/lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java b/lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java deleted file mode 100644 index d3ad085..0000000 --- a/lib/src/main/java/co/raccoons/meeko/util/OptionalDouble.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 2023, Raccoons. Developing simple way to change. - * - * @license GNU GPLv2 - */ - -/* - * @summary Refactored java.util.OptionalDouble - * @author Oleksii Kucheruk - */ - -/* - * Copyright (c) 2023, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package co.raccoons.meeko.util; - -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.function.DoubleConsumer; -import java.util.function.DoubleSupplier; -import java.util.function.Supplier; -import java.util.stream.DoubleStream; - -/** - * A container object which may or may not contain a {@code double} value. - * If a value is present, {@code isPresent()} returns {@code true}. If no - * value is present, the object is considered empty and - * {@code isPresent()} returns {@code false}. - * - *
Additional methods that depend on the presence or absence of a contained - * value are provided, such as {@link #orElse(double) orElse()} - * (returns a default value if no value is present) and - * {@link #ifPresent(DoubleConsumer) ifPresent()} (performs - * an action if a value is present). - * - *
This is a value-based
- * class; programmers should treat instances that are
- * {@linkplain #equals(Object) equal} as interchangeable and should not
- * use instances for synchronization, or unpredictable behavior may
- * occur. For example, in a future release, synchronization may fail.
- *
- * @apiNote {@code OptionalDouble} is primarily intended for use as a method return type where
- * there is a clear need to represent "no result." A variable whose type is
- * {@code OptionalDouble} should never itself be {@code null}; it should always point
- * to an {@code OptionalDouble} instance.
- * @since 1.8
- */
-public class OptionalDouble {
-
- private final double value;
-
- /**
- * Returns an empty {@code OptionalDouble} instance. No value is present
- * for this {@code OptionalDouble}.
- *
- * @return an empty {@code OptionalDouble}.
- * @apiNote Though it may be tempting to do so, avoid testing if an object is empty
- * by comparing with {@code ==} or {@code !=} against instances returned by
- * {@code OptionalDouble.empty()}. There is no guarantee that it is a singleton.
- * Instead, use {@link #isEmpty()} or {@link #isPresent()}.
- */
- public static OptionalDouble empty() {
- return new OptionalDouble(Double.NaN) {
-
- /**
- * @inheritDoc
- */
- @Override
- public boolean isEmpty() {
- return true;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public boolean isPresent() {
- return false;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public double getAsDouble() {
- throw new NoSuchElementException("No value present");
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public void ifPresent(DoubleConsumer action) {
- // Intentionally empty
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public void ifPresentOrElse(DoubleConsumer action, Runnable emptyAction) {
- Objects.requireNonNull(emptyAction);
- emptyAction.run();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public DoubleStream stream() {
- return DoubleStream.empty();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public double orElse(double other) {
- return other;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public double orElseGet(DoubleSupplier supplier) {
- Objects.requireNonNull(supplier);
- return supplier.getAsDouble();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public Additional methods that depend on the presence or absence of a contained
- * value are provided, such as {@link #orElse(int) orElse()}
- * (returns a default value if no value is present) and
- * {@link #ifPresent(IntConsumer) ifPresent()} (performs an
- * action if a value is present).
- *
- * This is a value-based
- * class; programmers should treat instances that are
- * {@linkplain #equals(Object) equal} as interchangeable and should not
- * use instances for synchronization, or unpredictable behavior may
- * occur. For example, in a future release, synchronization may fail.
- *
- * @apiNote {@code OptionalInt} is primarily intended for use as a method return type where
- * there is a clear need to represent "no result." A variable whose type is
- * {@code OptionalInt} should never itself be {@code null}; it should always point
- * to an {@code OptionalInt} instance.
- * @since 1.8
- */
-public class OptionalInt {
-
- private final int value;
-
- /**
- * Returns an empty {@code OptionalInt} instance. No value is present for
- * this {@code OptionalInt}.
- *
- * @return an empty {@code OptionalInt}
- * @apiNote Though it may be tempting to do so, avoid testing if an object is empty
- * by comparing with {@code ==} or {@code !=} against instances returned by
- * {@code OptionalInt.empty()}. There is no guarantee that it is a singleton.
- * Instead, use {@link #isEmpty()} or {@link #isPresent()}.
- */
- public static OptionalInt empty() {
- return new OptionalInt(0) {
-
- /**
- * @inheritDoc
- */
- @Override
- public boolean isEmpty() {
- return true;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public boolean isPresent() {
- return false;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public int getAsInt() {
- throw new NoSuchElementException("No value present");
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public void ifPresent(IntConsumer action) {
- // Intentionally empty
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public void ifPresentOrElse(IntConsumer action, Runnable emptyAction) {
- Objects.requireNonNull(emptyAction);
- emptyAction.run();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public IntStream stream() {
- return IntStream.empty();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public int orElse(int other) {
- return other;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public int orElseGet(IntSupplier supplier) {
- Objects.requireNonNull(supplier);
- return supplier.getAsInt();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public Additional methods that depend on the presence or absence of a contained
- * value are provided, such as {@link #orElse(long) orElse()}
- * (returns a default value if no value is present) and
- * {@link #ifPresent(LongConsumer) ifPresent()} (performs an
- * action if a value is present).
- *
- * This is a value-based
- * class; programmers should treat instances that are
- * {@linkplain #equals(Object) equal} as interchangeable and should not
- * use instances for synchronization, or unpredictable behavior may
- * occur. For example, in a future release, synchronization may fail.
- *
- * @apiNote {@code OptionalLong} is primarily intended for use as a method return type where
- * there is a clear need to represent "no result." A variable whose type is
- * {@code OptionalLong} should never itself be {@code null}; it should always point
- * to an {@code OptionalLong} instance.
- * @since 1.8
- */
-public class OptionalLong {
-
- private final long value;
-
- /**
- * Returns an empty {@code OptionalLong} instance. No value is present for
- * this {@code OptionalLong}.
- *
- * @return an empty {@code OptionalLong}.
- * @apiNote Though it may be tempting to do so, avoid testing if an object is empty
- * by comparing with {@code ==} or {@code !=} against instances returned by
- * {@code OptionalLong.empty()}. There is no guarantee that it is a singleton.
- * Instead, use {@link #isEmpty()} or {@link #isPresent()}.
- */
- public static OptionalLong empty() {
- return new OptionalLong(0) {
-
- /**
- * @inheritDoc
- */
- @Override
- public boolean isEmpty() {
- return true;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public boolean isPresent() {
- return false;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public long getAsLong() {
- throw new NoSuchElementException("No value present");
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public void ifPresent(LongConsumer action) {
- // Intentionally empty
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public void ifPresentOrElse(LongConsumer action, Runnable emptyAction) {
- Objects.requireNonNull(emptyAction);
- emptyAction.run();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public LongStream stream() {
- return LongStream.empty();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public long orElse(long other) {
- return other;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public long orElseGet(LongSupplier supplier) {
- Objects.requireNonNull(supplier);
- return supplier.getAsLong();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public {@code
- * Stream
- * @since 9
- */
- public DoubleStream stream() {
- return DoubleStream.of(value);
- }
-
- /**
- * If a value is present, returns the value, otherwise returns
- * {@code other}.
- *
- * @param other the value to be returned, if no value is present
- * @return the value, if present, otherwise {@code other}
- */
- public double orElse(double other) {
- return getAsDouble();
- }
-
- /**
- * If a value is present, returns the value, otherwise returns the result
- * produced by the supplying function.
- *
- * @param supplier the supplying function that produces a value to be returned
- * @return the value, if present, otherwise the result produced by the
- * supplying function
- * @throws NullPointerException if no value is present and the supplying
- * function is {@code null}
- */
- public double orElseGet(DoubleSupplier supplier) {
- return getAsDouble();
- }
-
- /**
- * If a value is present, returns the value, otherwise throws
- * {@code NoSuchElementException}.
- *
- * @return the value described by this {@code OptionalDouble}
- * @throws NoSuchElementException if no value is present
- * @since 10
- */
- public double orElseThrow() {
- return getAsDouble();
- }
-
- /**
- * If a value is present, returns the value, otherwise throws an exception
- * produced by the exception supplying function.
- *
- * @param
- *
- *
- * @param obj an object to be tested for equality
- * @return {@code true} if the other object is "equal to" this object
- * otherwise {@code false}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- return obj instanceof OptionalDouble other
- && (Double.compare(value, other.value) == 0);
- }
-
- /**
- * Returns the hash code of the value, if present, otherwise {@code 0}
- * (zero) if no value is present.
- *
- * @return hash code value of the present value or {@code 0} if no value is
- * present
- */
- @Override
- public int hashCode() {
- return Double.hashCode(value);
- }
-
- /**
- * Returns a non-empty string representation of this {@code OptionalDouble}
- * suitable for debugging. The exact presentation format is unspecified and
- * may vary between implementations and versions.
- *
- * @return the string representation of this instance
- * @implSpec If a value is present the result must include its string representation
- * in the result. Empty and present {@code OptionalDouble}s must be
- * unambiguously differentiable.
- */
- @Override
- public String toString() {
- return ("OptionalDouble[" + value + "]");
- }
-}
diff --git a/lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java b/lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java
deleted file mode 100644
index 7f36ac2..0000000
--- a/lib/src/main/java/co/raccoons/meeko/util/OptionalInt.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright 2023, Raccoons. Developing simple way to change.
- *
- * @license GNU GPLv2
- */
-
-/*
- * @summary Refactored java.util.OptionalInt
- * @author Oleksii Kucheruk
- */
-
-/*
- * Copyright (c) 2023, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package co.raccoons.meeko.util;
-
-import java.util.NoSuchElementException;
-import java.util.Objects;
-import java.util.function.IntConsumer;
-import java.util.function.IntSupplier;
-import java.util.function.Supplier;
-import java.util.stream.IntStream;
-
-/**
- * A container object which may or may not contain an {@code int} value.
- * If a value is present, {@code isPresent()} returns {@code true}. If no
- * value is present, the object is considered empty and
- * {@code isPresent()} returns {@code false}.
- *
- * {@code
- * Stream
- * @since 9
- */
- public IntStream stream() {
- return IntStream.of(value);
- }
-
- /**
- * If a value is present, returns the value, otherwise returns
- * {@code other}.
- *
- * @param other the value to be returned, if no value is present
- * @return the value, if present, otherwise {@code other}
- */
- public int orElse(int other) {
- return getAsInt();
- }
-
- /**
- * If a value is present, returns the value, otherwise returns the result
- * produced by the supplying function.
- *
- * @param supplier the supplying function that produces a value to be returned
- * @return the value, if present, otherwise the result produced by the
- * supplying function
- * @throws NullPointerException if no value is present and the supplying
- * function is {@code null}
- */
- public int orElseGet(IntSupplier supplier) {
- return getAsInt();
- }
-
- /**
- * If a value is present, returns the value, otherwise throws
- * {@code NoSuchElementException}.
- *
- * @return the value described by this {@code OptionalInt}
- * @throws NoSuchElementException if no value is present
- * @since 10
- */
- public int orElseThrow() {
- return getAsInt();
- }
-
- /**
- * If a value is present, returns the value, otherwise throws an exception
- * produced by the exception supplying function.
- *
- * @param
- *
- *
- * @param obj an object to be tested for equality
- * @return {@code true} if the other object is "equal to" this object
- * otherwise {@code false}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- return obj instanceof OptionalInt other
- && Objects.equals(value, other.value);
- }
-
- /**
- * Returns the hash code of the value, if present, otherwise {@code 0}
- * (zero) if no value is present.
- *
- * @return hash code value of the present value or {@code 0} if no value is
- * present
- */
- @Override
- public int hashCode() {
- return Integer.hashCode(value);
- }
-
- /**
- * Returns a non-empty string representation of this {@code OptionalInt}
- * suitable for debugging. The exact presentation format is unspecified and
- * may vary between implementations and versions.
- *
- * @return the string representation of this instance
- * @implSpec If a value is present the result must include its string representation
- * in the result. Empty and present {@code OptionalInt}s must be
- * unambiguously differentiable.
- */
- @Override
- public String toString() {
- return ("OptionalInt[" + value + "]");
- }
-}
diff --git a/lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java b/lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java
deleted file mode 100644
index 186173c..0000000
--- a/lib/src/main/java/co/raccoons/meeko/util/OptionalLong.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright 2023, Raccoons. Developing simple way to change.
- *
- * @license GNU GPLv2
- */
-
-/*
- * @summary Refactored java.util.OptionalLong
- * @author Oleksii Kucheruk
- */
-
-/*
- * Copyright (c) 2023, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package co.raccoons.meeko.util;
-
-import java.util.NoSuchElementException;
-import java.util.Objects;
-import java.util.function.LongConsumer;
-import java.util.function.LongSupplier;
-import java.util.function.Supplier;
-import java.util.stream.LongStream;
-
-/**
- * A container object which may or may not contain a {@code long} value.
- * If a value is present, {@code isPresent()} returns {@code true}. If no
- * value is present, the object is considered empty and
- * {@code isPresent()} returns {@code false}.
- *
- * {@code
- * Stream
- * @since 9
- */
- public LongStream stream() {
- return LongStream.of(value);
- }
-
- /**
- * If a value is present, returns the value, otherwise returns
- * {@code other}.
- *
- * @param other the value to be returned, if no value is present
- * @return the value, if present, otherwise {@code other}
- */
- public long orElse(long other) {
- return getAsLong();
- }
-
- /**
- * If a value is present, returns the value, otherwise returns the result
- * produced by the supplying function.
- *
- * @param supplier the supplying function that produces a value to be returned
- * @return the value, if present, otherwise the result produced by the
- * supplying function
- * @throws NullPointerException if no value is present and the supplying
- * function is {@code null}
- */
- public long orElseGet(LongSupplier supplier) {
- return getAsLong();
- }
-
- /**
- * If a value is present, returns the value, otherwise throws
- * {@code NoSuchElementException}.
- *
- * @return the value described by this {@code OptionalLong}
- * @throws NoSuchElementException if no value is present
- * @since 10
- */
- public long orElseThrow() {
- return getAsLong();
- }
-
- /**
- * If a value is present, returns the value, otherwise throws an exception
- * produced by the exception supplying function.
- *
- * @param
- *
- *
- * @param obj an object to be tested for equality
- * @return {@code true} if the other object is "equal to" this object
- * otherwise {@code false}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- return obj instanceof OptionalLong other
- && (value == other.value);
- }
-
- /**
- * Returns the hash code of the value, if present, otherwise {@code 0}
- * (zero) if no value is present.
- *
- * @return hash code value of the present value or {@code 0} if no value is
- * present
- */
- @Override
- public int hashCode() {
- return Long.hashCode(value);
- }
-
- /**
- * Returns a non-empty string representation of this {@code OptionalLong}
- * suitable for debugging. The exact presentation format is unspecified and
- * may vary between implementations and versions.
- *
- * @return the string representation of this instance
- * @implSpec If a value is present the result must include its string representation
- * in the result. Empty and present {@code OptionalLong}s must be
- * unambiguously differentiable.
- */
- @Override
- public String toString() {
- return ("OptionalLong[" + value + "]");
- }
-}
diff --git a/lib/src/test/java/co/raccoons/meeko/util/OptionalDoubleTest.java b/lib/src/test/java/co/raccoons/meeko/util/OptionalDoubleTest.java
deleted file mode 100644
index 3227446..0000000
--- a/lib/src/test/java/co/raccoons/meeko/util/OptionalDoubleTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2023, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8195649
- * @summary Basic functional test of OptionalDouble
- * @author Mike Duigou
- * @build ObscureException
- * @run testng BasicDouble
- */
-package co.raccoons.meeko.util;
-
-import org.testng.annotations.Test;
-
-import java.util.NoSuchElementException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertThrows;
-import static org.testng.Assert.assertTrue;
-
-public class OptionalDoubleTest {
- static final double DOUBLEVAL = Math.PI;
- static final double UNEXPECTED = 6.62607004E-34;
-
- /**
- * Checks a block of assertions over an empty OptionalDouble.
- */
- void checkEmpty(OptionalDouble empty) {
- assertTrue(empty.equals(OptionalDouble.empty()));
- assertTrue(OptionalDouble.empty().equals(empty));
- assertFalse(empty.equals(OptionalDouble.of(UNEXPECTED)));
- assertFalse(OptionalDouble.of(UNEXPECTED).equals(empty));
- assertFalse(empty.equals("unexpected"));
-
- assertFalse(empty.isPresent());
- assertTrue(empty.isEmpty());
- assertEquals(empty.hashCode(), 0);
- assertEquals(empty.orElse(UNEXPECTED), UNEXPECTED);
- assertEquals(empty.orElseGet(() -> UNEXPECTED), UNEXPECTED);
-
- assertThrows(NoSuchElementException.class, () -> empty.getAsDouble());
- assertThrows(NoSuchElementException.class, () -> empty.orElseThrow());
- assertThrows(ObscureException.class, () -> empty.orElseThrow(ObscureException::new));
-
- var b = new AtomicBoolean();
- empty.ifPresent(s -> b.set(true));
- assertFalse(b.get());
-
- var b1 = new AtomicBoolean(false);
- var b2 = new AtomicBoolean(false);
- empty.ifPresentOrElse(s -> b1.set(true), () -> b2.set(true));
- assertFalse(b1.get());
- assertTrue(b2.get());
-
- assertTrue(empty.equals(empty));
- assertEquals(empty.toString(), "OptionalDouble.empty");
- }
-
- /**
- * Checks a block of assertions over an OptionalDouble that is expected to
- * have a particular value present.
- */
- void checkPresent(OptionalDouble opt, double expected) {
- assertFalse(opt.equals(OptionalDouble.empty()));
- assertFalse(OptionalDouble.empty().equals(opt));
- assertTrue(opt.equals(OptionalDouble.of(expected)));
- assertTrue(OptionalDouble.of(expected).equals(opt));
- assertFalse(opt.equals(OptionalDouble.of(UNEXPECTED)));
- assertFalse(OptionalDouble.of(UNEXPECTED).equals(opt));
- assertFalse(opt.equals("unexpected"));
-
- assertTrue(opt.isPresent());
- assertFalse(opt.isEmpty());
- assertEquals(opt.hashCode(), Double.hashCode(expected));
- assertEquals(opt.orElse(UNEXPECTED), expected);
- assertEquals(opt.orElseGet(() -> UNEXPECTED), expected);
-
- assertEquals(opt.getAsDouble(), expected);
- assertEquals(opt.orElseThrow(), expected);
- assertEquals(opt.orElseThrow(ObscureException::new), expected);
-
- var b = new AtomicBoolean(false);
- opt.ifPresent(s -> b.set(true));
- assertTrue(b.get());
-
- var b1 = new AtomicBoolean(false);
- var b2 = new AtomicBoolean(false);
- opt.ifPresentOrElse(s -> b1.set(true), () -> b2.set(true));
- assertTrue(b1.get());
- assertFalse(b2.get());
-
- assertTrue(opt.equals(opt));
- assertEquals(opt.toString(), "OptionalDouble[" + expected + "]");
- }
-
- @Test(groups = "unit")
- public void testEmpty() {
- checkEmpty(OptionalDouble.empty());
- }
-
- @Test(groups = "unit")
- public void testPresent() {
- checkPresent(OptionalDouble.of(DOUBLEVAL), DOUBLEVAL);
- }
-
- @Test(groups = "unit")
- public void testStreamEmpty() {
- assertEquals(OptionalDouble.empty().stream().toArray(), new double[]{});
- }
-
- @Test(groups = "unit")
- public void testStreamPresent() {
- assertEquals(OptionalDouble.of(DOUBLEVAL).stream().toArray(), new double[]{DOUBLEVAL});
- }
-}
diff --git a/lib/src/test/java/co/raccoons/meeko/util/OptionalIntTest.java b/lib/src/test/java/co/raccoons/meeko/util/OptionalIntTest.java
deleted file mode 100644
index fdc8317..0000000
--- a/lib/src/test/java/co/raccoons/meeko/util/OptionalIntTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2023, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8195649
- * @summary Basic functional test of OptionalInt
- * @author Mike Duigou
- * @build ObscureException
- * @run testng OptionalIntTest
- */
-package co.raccoons.meeko.util;
-
-import org.testng.annotations.Test;
-
-import java.util.NoSuchElementException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertThrows;
-import static org.testng.Assert.assertTrue;
-
-public class OptionalIntTest {
-
- static final int INTVAL = 33_550_336;
- static final int UNEXPECTED = 0xCAFEBABE;
-
- /**
- * Checks a block of assertions over an empty OptionalInt.
- */
- void checkEmpty(OptionalInt empty) {
- assertTrue(empty.equals(OptionalInt.empty()));
- assertTrue(OptionalInt.empty().equals(empty));
- assertFalse(empty.equals(OptionalInt.of(UNEXPECTED)));
- assertFalse(OptionalInt.of(UNEXPECTED).equals(empty));
- assertFalse(empty.equals("unexpected"));
-
- assertFalse(empty.isPresent());
- assertTrue(empty.isEmpty());
- assertEquals(empty.hashCode(), 0);
- assertEquals(empty.orElse(UNEXPECTED), UNEXPECTED);
- assertEquals(empty.orElseGet(() -> UNEXPECTED), UNEXPECTED);
-
- assertThrows(NoSuchElementException.class, () -> empty.getAsInt());
- assertThrows(NoSuchElementException.class, () -> empty.orElseThrow());
- assertThrows(ObscureException.class, () -> empty.orElseThrow(ObscureException::new));
-
- var b = new AtomicBoolean();
- empty.ifPresent(s -> b.set(true));
- assertFalse(b.get());
-
- var b1 = new AtomicBoolean(false);
- var b2 = new AtomicBoolean(false);
- empty.ifPresentOrElse(s -> b1.set(true), () -> b2.set(true));
- assertFalse(b1.get());
- assertTrue(b2.get());
-
- assertTrue(empty.equals(empty));
- assertEquals(empty.toString(), "OptionalInt.empty");
- }
-
- /**
- * Checks a block of assertions over an OptionalInt that is expected to
- * have a particular value present.
- */
- void checkPresent(OptionalInt opt, int expected) {
- assertFalse(opt.equals(OptionalInt.empty()));
- assertFalse(OptionalInt.empty().equals(opt));
- assertTrue(opt.equals(OptionalInt.of(expected)));
- assertTrue(OptionalInt.of(expected).equals(opt));
- assertFalse(opt.equals(OptionalInt.of(UNEXPECTED)));
- assertFalse(OptionalInt.of(UNEXPECTED).equals(opt));
- assertFalse(opt.equals("unexpected"));
-
- assertTrue(opt.isPresent());
- assertFalse(opt.isEmpty());
- assertEquals(opt.hashCode(), Integer.hashCode(expected));
- assertEquals(opt.orElse(UNEXPECTED), expected);
- assertEquals(opt.orElseGet(() -> UNEXPECTED), expected);
-
- assertEquals(opt.getAsInt(), expected);
- assertEquals(opt.orElseThrow(), expected);
- assertEquals(opt.orElseThrow(ObscureException::new), expected);
-
- var b = new AtomicBoolean(false);
- opt.ifPresent(s -> b.set(true));
- assertTrue(b.get());
-
- var b1 = new AtomicBoolean(false);
- var b2 = new AtomicBoolean(false);
- opt.ifPresentOrElse(s -> b1.set(true), () -> b2.set(true));
- assertTrue(b1.get());
- assertFalse(b2.get());
-
- assertTrue(opt.equals(opt));
- assertEquals(opt.toString(), "OptionalInt[" + expected + "]");
- }
-
- @Test(groups = "unit")
- public void testEmpty() {
- checkEmpty(OptionalInt.empty());
- }
-
- @Test(groups = "unit")
- public void testPresent() {
- checkPresent(OptionalInt.of(INTVAL), INTVAL);
- }
-
- @Test(groups = "unit")
- public void testStreamEmpty() {
- assertEquals(OptionalInt.empty().stream().toArray(), new int[]{});
- }
-
- @Test(groups = "unit")
- public void testStreamPresent() {
- assertEquals(OptionalInt.of(INTVAL).stream().toArray(), new int[]{INTVAL});
- }
-}
diff --git a/lib/src/test/java/co/raccoons/meeko/util/OptionalLongTest.java b/lib/src/test/java/co/raccoons/meeko/util/OptionalLongTest.java
deleted file mode 100644
index 28a0b68..0000000
--- a/lib/src/test/java/co/raccoons/meeko/util/OptionalLongTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2023, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 8195649
- * @summary Basic functional test of OptionalLong
- * @author Mike Duigou
- * @build ObscureException
- * @run testng OptionalLongTest
- */
-package co.raccoons.meeko.util;
-
-import org.testng.annotations.Test;
-
-import java.util.NoSuchElementException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertThrows;
-import static org.testng.Assert.assertTrue;
-
-public class OptionalLongTest {
- static final long LONGVAL = 2_305_843_008_139_952_128L;
- static final long UNEXPECTED = 0xFEEDBEEFCAFEBABEL;
-
- /**
- * Checks a block of assertions over an empty OptionalLong.
- */
- void checkEmpty(OptionalLong empty) {
- assertTrue(empty.equals(OptionalLong.empty()));
- assertTrue(OptionalLong.empty().equals(empty));
- assertFalse(empty.equals(OptionalLong.of(UNEXPECTED)));
- assertFalse(OptionalLong.of(UNEXPECTED).equals(empty));
- assertFalse(empty.equals("unexpected"));
-
- assertFalse(empty.isPresent());
- assertTrue(empty.isEmpty());
- assertEquals(empty.hashCode(), 0);
- assertEquals(empty.orElse(UNEXPECTED), UNEXPECTED);
- assertEquals(empty.orElseGet(() -> UNEXPECTED), UNEXPECTED);
-
- assertThrows(NoSuchElementException.class, () -> empty.getAsLong());
- assertThrows(NoSuchElementException.class, () -> empty.orElseThrow());
- assertThrows(ObscureException.class, () -> empty.orElseThrow(ObscureException::new));
-
- var b = new AtomicBoolean();
- empty.ifPresent(s -> b.set(true));
- assertFalse(b.get());
-
- var b1 = new AtomicBoolean(false);
- var b2 = new AtomicBoolean(false);
- empty.ifPresentOrElse(s -> b1.set(true), () -> b2.set(true));
- assertFalse(b1.get());
- assertTrue(b2.get());
-
- assertTrue(empty.equals(empty));
- assertEquals(empty.toString(), "OptionalLong.empty");
- }
-
- /**
- * Checks a block of assertions over an OptionalLong that is expected to
- * have a particular value present.
- */
- void checkPresent(OptionalLong opt, long expected) {
- assertFalse(opt.equals(OptionalLong.empty()));
- assertFalse(OptionalLong.empty().equals(opt));
- assertTrue(opt.equals(OptionalLong.of(expected)));
- assertTrue(OptionalLong.of(expected).equals(opt));
- assertFalse(opt.equals(OptionalLong.of(UNEXPECTED)));
- assertFalse(OptionalLong.of(UNEXPECTED).equals(opt));
- assertFalse(opt.equals("unexpected"));
-
- assertTrue(opt.isPresent());
- assertFalse(opt.isEmpty());
- assertEquals(opt.hashCode(), Long.hashCode(expected));
- assertEquals(opt.orElse(UNEXPECTED), expected);
- assertEquals(opt.orElseGet(() -> UNEXPECTED), expected);
-
- assertEquals(opt.getAsLong(), expected);
- assertEquals(opt.orElseThrow(), expected);
- assertEquals(opt.orElseThrow(ObscureException::new), expected);
-
- var b = new AtomicBoolean(false);
- opt.ifPresent(s -> b.set(true));
- assertTrue(b.get());
-
- var b1 = new AtomicBoolean(false);
- var b2 = new AtomicBoolean(false);
- opt.ifPresentOrElse(s -> b1.set(true), () -> b2.set(true));
- assertTrue(b1.get());
- assertFalse(b2.get());
-
- assertTrue(opt.equals(opt));
- assertEquals(opt.toString(), "OptionalLong[" + expected + "]");
- }
-
- @Test(groups = "unit")
- public void testEmpty() {
- checkEmpty(OptionalLong.empty());
- }
-
- @Test(groups = "unit")
- public void testPresent() {
- checkPresent(OptionalLong.of(LONGVAL), LONGVAL);
- }
-
- @Test(groups = "unit")
- public void testStreamEmpty() {
- assertEquals(OptionalLong.empty().stream().toArray(), new long[]{});
- }
-
- @Test(groups = "unit")
- public void testStreamPresent() {
- assertEquals(OptionalLong.of(LONGVAL).stream().toArray(), new long[]{LONGVAL});
- }
-}