org.babyfish.jimmer.sql.cache.CacheEnvironment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.sql.cache;
import org.babyfish.jimmer.sql.JSqlClient;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Connection;
import java.util.Objects;
public class CacheEnvironment {
private final JSqlClient sqlClient;
private final Connection connection;
private final CacheLoader loader;
public CacheEnvironment(
JSqlClient sqlClient,
Connection connection,
CacheLoader loader,
boolean requiresNewDraftContext) {
this.sqlClient = Objects.requireNonNull(sqlClient, "sqlClient cannot be null");
this.connection = Objects.requireNonNull(connection, "connection cannot be null");
this.loader = CacheLoaderWrapper.wrap(
Objects.requireNonNull(loader, "loader cannot be null"),
requiresNewDraftContext
);
}
@NotNull
public JSqlClient getSqlClient() {
return sqlClient;
}
@NotNull
public Connection getConnection() {
return connection;
}
@NotNull
public CacheLoader getLoader() {
return loader;
}
@Override
public int hashCode() {
return Objects.hash(sqlClient, connection, loader);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CacheEnvironment, ?> that = (CacheEnvironment, ?>) o;
return sqlClient.equals(that.sqlClient) &&
connection.equals(that.connection) &&
Objects.equals(loader, that.loader);
}
@Override
public String toString() {
return "CacheEnvironment{" +
"sqlClient=" + sqlClient +
", connection=" + connection +
", loader=" + loader +
'}';
}
}