Example #1
0
  public Coll(
      String name,
      Class<E> entityClass,
      Db db,
      Plugin plugin,
      boolean lazy,
      boolean creative,
      boolean lowercasing,
      Comparator<? super String> idComparator,
      Comparator<? super E> entityComparator) {
    // Setup the name and the parsed parts
    this.name = name;
    String[] nameParts = this.name.split("\\@");
    this.basename = nameParts[0];
    if (nameParts.length > 1) {
      this.universe = nameParts[1];
    } else {
      this.universe = null;
    }

    // WHAT DO WE HANDLE?
    this.entityClass = entityClass;
    this.lazy = lazy;
    this.creative = creative;
    this.lowercasing = lowercasing;

    // SUPPORTING SYSTEM
    this.plugin = plugin;
    this.db = db;
    this.collDriverObject = db.getCollDriverObject(this);

    // STORAGE
    this.ids = new ConcurrentSkipListSet<String>(idComparator);
    this.id2entity = new ConcurrentSkipListMap<String, E>(idComparator);
    this.entity2id = new ConcurrentSkipListMap<E, String>(entityComparator);

    // IDENTIFIED CHANGES
    this.localAttachIds = new ConcurrentSkipListSet<String>(idComparator);
    this.localDetachIds = new ConcurrentSkipListSet<String>(idComparator);
    this.changedIds = new ConcurrentSkipListSet<String>(idComparator);

    // SYNCLOG
    this.lastMtime = new ConcurrentSkipListMap<String, Long>(idComparator);
    this.lastRaw = new ConcurrentSkipListMap<String, JsonElement>(idComparator);
    this.lastDefault = new ConcurrentSkipListSet<String>(idComparator);

    final Coll<E> me = this;
    this.tickTask =
        new Runnable() {
          @Override
          public void run() {
            me.onTick();
          }
        };
  }