Revert "Cleanup usages"

This reverts commit 7aa7b81a67.
This commit is contained in:
Per Minborg
2020-12-11 11:01:36 +01:00
parent 7aa7b81a67
commit 66c8c2e6a4
8 changed files with 24 additions and 24 deletions
@@ -16,6 +16,7 @@
package net.openhft.chronicle.hash.impl.util;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@@ -32,10 +33,15 @@ public final class Objects {
}
public static boolean equal(@Nullable Object a, @Nullable Object b) {
return java.util.Objects.equals(a, b);
return a != null ? a.equals(b) : b == null;
}
public static boolean builderEquals(@NotNull Object builder, @Nullable Object o) {
return builder == o ||
o != null && builder.getClass() == o.getClass() &&
builder.toString().equals(o.toString());
}
/* Used by generated code */
public static void requireNonNull(Object obj) {
if (obj == null)
throw new NullPointerException();
@@ -16,8 +16,6 @@
package net.openhft.chronicle.hash.impl.util;
import static net.openhft.chronicle.core.util.ObjectUtils.requireNonNull;
/**
* Inspired by Guava's Throwables
*/
@@ -39,8 +37,8 @@ public final class Throwables {
public static <T extends Throwable> T propagateNotWrapping(
Throwable t, Class<T> notWrappingThrowableType) throws T {
requireNonNull(t);
requireNonNull(notWrappingThrowableType);
Objects.requireNonNull(t);
Objects.requireNonNull(notWrappingThrowableType);
if (t instanceof Error)
throw (Error) t;
if (t instanceof RuntimeException)
@@ -38,10 +38,10 @@ public final class WrongXxHash {
// unsigned here.
hash ^= input * P1;
hash = Long.rotateLeft(hash, 23) * P2 + P3;
return finish(hash);
return finalize(hash);
}
private static long finish(long hash) {
private static long finalize(long hash) {
hash ^= hash >>> 33;
hash *= P2;
hash ^= hash >>> 29;
@@ -28,7 +28,7 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import static java.util.Collections.emptyList;
import static net.openhft.chronicle.core.util.ObjectUtils.requireNonNull;
import static net.openhft.chronicle.hash.impl.util.Objects.requireNonNull;
interface AbstractChronicleMap<K, V> extends ChronicleMap<K, V> {
@@ -71,6 +71,7 @@ import static net.openhft.chronicle.hash.impl.SizePrefixedBlob.*;
import static net.openhft.chronicle.hash.impl.VanillaChronicleHash.throwRecoveryOrReturnIOException;
import static net.openhft.chronicle.hash.impl.util.FileIOUtils.readFully;
import static net.openhft.chronicle.hash.impl.util.FileIOUtils.writeFully;
import static net.openhft.chronicle.hash.impl.util.Objects.builderEquals;
import static net.openhft.chronicle.map.ChronicleHashCorruptionImpl.format;
import static net.openhft.chronicle.map.ChronicleHashCorruptionImpl.report;
import static net.openhft.chronicle.map.DefaultSpi.mapEntryOperations;
@@ -138,7 +139,7 @@ import static net.openhft.chronicle.map.VanillaChronicleMap.alignAddr;
*/
public final class ChronicleMapBuilder<K, V> implements
ChronicleHashBuilder<K, ChronicleMap<K, V>,
ChronicleMapBuilder<K, V>> {
ChronicleMapBuilder<K, V>> {
private static final int UNDEFINED_ALIGNMENT_CONFIG = -1;
private static final int NO_ALIGNMENT = 1;
@@ -1383,9 +1384,7 @@ public final class ChronicleMapBuilder<K, V> implements
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(final Object o) {
return this == o ||
o != null && this.getClass() == o.getClass() &&
this.toString().equals(o.toString());
return builderEquals(this, o);
}
@Override
@@ -1705,8 +1704,8 @@ public final class ChronicleMapBuilder<K, V> implements
if (!canonicalFile.exists()) {
if (recover)
throw new FileNotFoundException("file " + canonicalFile + " should exist for recovery");
if (!canonicalFile.createNewFile())
throw new IOException("Unable to create file " + canonicalFile + " which presumably already exists");
//noinspection ResultOfMethodCallIgnored
canonicalFile.createNewFile();
}
final RandomAccessFile raf = CanonicalRandomAccessFiles.acquire(canonicalFile);
final ChronicleHashResources resources = new PersistedChronicleHashResources(canonicalFile);
@@ -19,13 +19,12 @@ package net.openhft.chronicle.map.impl.stage.map;
import net.openhft.chronicle.bytes.BytesStore;
import net.openhft.chronicle.hash.Data;
import net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation;
import net.openhft.chronicle.hash.impl.util.Objects;
import net.openhft.chronicle.map.MapContext;
import net.openhft.chronicle.map.impl.stage.data.bytes.WrappedValueBytesData;
import net.openhft.sg.StageRef;
import net.openhft.sg.Staged;
import static net.openhft.chronicle.core.util.ObjectUtils.requireNonNull;
@Staged
public abstract class WrappedValueBytesDataAccess<K, V, R> implements MapContext<K, V, R> {
@@ -36,7 +35,7 @@ public abstract class WrappedValueBytesDataAccess<K, V, R> implements MapContext
@Override
public Data<V> wrapValueBytesAsData(BytesStore bytesStore, long offset, long size) {
requireNonNull(bytesStore);
Objects.requireNonNull(bytesStore);
checkOnEachPublicOperation.checkOnEachPublicOperation();
WrappedValueBytesData<V> wrapped = this.wrappedValueBytesData;
wrapped = wrapped.getUnusedWrappedValueBytesData();
@@ -32,7 +32,6 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
import static net.openhft.chronicle.core.util.ObjectUtils.requireNonNull;
import static net.openhft.chronicle.set.DummyValue.DUMMY_VALUE;
/**
@@ -221,7 +220,7 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
public boolean forEachEntryWhile(Predicate<? super SetEntry<E>> predicate) {
throwExceptionIfClosed();
requireNonNull(predicate);
Objects.requireNonNull(predicate);
return m.forEachEntryWhile(e -> predicate.test(((SetEntry<E>) e)));
}
@@ -229,7 +228,7 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
public void forEachEntry(Consumer<? super SetEntry<E>> action) {
throwExceptionIfClosed();
requireNonNull(action);
Objects.requireNonNull(action);
m.forEachEntry(e -> action.accept(((SetEntry<E>) e)));
}