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

org.jaxdb.jsql.OneToManyTreeMap Maven / Gradle / Ivy

/* Copyright (c) 2022 JAX-DB
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * You should have received a copy of The MIT License (MIT) along with this
 * program. If not, see .
 */

package org.jaxdb.jsql;

import java.util.NavigableMap;

public class OneToManyTreeMap extends TreeCacheMap> implements OneToManyMap> {
  OneToManyTreeMap(final data.Table table) {
    super(table);
  }

  private OneToManyTreeMap(final data.Table table, final NavigableMap> map) {
    super(table, table.getSchema(), map);
  }

  @Override
  TreeCacheMap> newInstance(final data.Table table, final NavigableMap> map) {
    return new OneToManyTreeMap<>(table, map);
  }

  @Override
  public final NavigableMap get(final Object key) {
    final NavigableMap v = map.get(key);
    return v != null ? v : OneToOneTreeMap.EMPTY;
  }

  final void add$(final data.Key key, final V value) {
    // mask.add(key); Do not add key, because this is only 1 value being added of many

    OneToOneTreeMap v = (OneToOneTreeMap)map.get(key);
    if (v == null)
      map.put(key, v = new OneToOneTreeMap<>(table));

    v.put$(value.getKey(), value);
  }

  final void remove$(final data.Key key, final V value) {
    final OneToOneTreeMap v = (OneToOneTreeMap)map.get(key);
    if (v != null)
      v.remove$(value.getKey());
  }

  final void remove$Old(final data.Key key, final V value) {
    final OneToOneTreeMap v = (OneToOneTreeMap)map.get(key);
    if (v != null)
      v.remove$(value.getKeyOld());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy