2021-08-28 22:42:51 +02:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
import it.cavallium.dbengine.buffers.Buf;
|
2021-10-01 19:17:33 +02:00
|
|
|
import java.util.Objects;
|
2021-08-29 23:18:03 +02:00
|
|
|
import java.util.StringJoiner;
|
2021-12-17 01:48:49 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2021-08-29 23:18:03 +02:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2021-08-28 22:42:51 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
public class LLEntry {
|
2021-08-28 22:42:51 +02:00
|
|
|
|
2021-12-17 01:48:49 +01:00
|
|
|
private static final Logger logger = LogManager.getLogger(LLEntry.class);
|
2023-02-09 23:34:25 +01:00
|
|
|
private final Buf key;
|
|
|
|
private final Buf value;
|
2021-10-01 19:17:33 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
private LLEntry(@NotNull Buf key, @NotNull Buf value) {
|
2022-05-20 10:20:00 +02:00
|
|
|
this.key = key;
|
|
|
|
this.value = value;
|
2021-08-29 23:18:03 +02:00
|
|
|
}
|
2021-08-28 22:42:51 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
public static LLEntry of(@NotNull Buf key, @NotNull Buf value) {
|
2021-11-08 16:33:41 +01:00
|
|
|
return new LLEntry(key, value);
|
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
public static LLEntry copyOf(Buf keyView, Buf valueView) {
|
|
|
|
return new LLEntry(keyView.copy(), valueView.copy());
|
2021-08-28 22:42:51 +02:00
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
public Buf getKey() {
|
|
|
|
return Objects.requireNonNull(key);
|
2021-08-28 22:42:51 +02:00
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
public Buf getValue() {
|
|
|
|
return Objects.requireNonNull(value);
|
2021-10-01 19:17:33 +02:00
|
|
|
}
|
|
|
|
|
2021-08-29 23:18:03 +02:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) {
|
|
|
|
return true;
|
2021-08-28 22:42:51 +02:00
|
|
|
}
|
2021-08-29 23:18:03 +02:00
|
|
|
if (o == null || getClass() != o.getClass()) {
|
|
|
|
return false;
|
2021-08-28 22:42:51 +02:00
|
|
|
}
|
2021-08-29 23:18:03 +02:00
|
|
|
LLEntry LLEntry = (LLEntry) o;
|
|
|
|
return LLUtils.equals(key, LLEntry.key) && LLUtils.equals(value, LLEntry.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
int result = LLUtils.hashCode(key);
|
|
|
|
result = 31 * result + LLUtils.hashCode(value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return new StringJoiner(", ", LLEntry.class.getSimpleName() + "[", "]")
|
|
|
|
.add("key=" + LLUtils.toString(key))
|
|
|
|
.add("value=" + LLUtils.toString(value))
|
|
|
|
.toString();
|
2021-08-28 22:42:51 +02:00
|
|
|
}
|
|
|
|
}
|