All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.telegram.telegrambots.abilitybots.api.db.MapDBVar Maven / Gradle / Ivy

There is a newer version: 7.10.0
Show newest version
package org.telegram.telegrambots.abilitybots.api.db;

import com.google.common.base.MoreObjects;
import org.mapdb.Atomic;

import java.util.Objects;

/**
 * The MapDB variant for {@link DBContext#getVar(String)}.
 *
 * @param  the type of the inner variable
 */
public final class MapDBVar implements Var {
  private Atomic.Var var;

  public MapDBVar(Atomic.Var var) {
    this.var = var;
  }

  @Override
  public T get() {
    return var.get();
  }

  @Override
  public void set(T var) {
    this.var.set(var);
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    MapDBVar mapDBVar = (MapDBVar) o;
    return Objects.equals(var, mapDBVar.var);
  }

  @Override
  public int hashCode() {
    return Objects.hash(var);
  }

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this)
        .add("var", var)
        .toString();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy