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

xapi.collect.api.InitMap Maven / Gradle / Ivy

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The newest version!
package xapi.collect.api;

import java.util.Map.Entry;

import xapi.collect.impl.AbstractInitMap;
import xapi.util.api.ConvertsValue;
import xapi.util.api.Pair;
import xapi.util.api.Triple;

/**
 * Our init map purposely forces string-key semantics,
 * to force our subclasses to take care of key serialization for us.
 *
 * {@link AbstractInitMap} will accept a key converter, which will work,
 * and allow reuse of code and singleton sharing,
 * but will be slower than if you extends an existing StringDictionary
 *
 * @author "James X. Nelson ([email protected])"
 *
 * @param 
 * @param 
 */
public interface InitMap  extends StringDictionary, ConvertsValue, Iterable>{

  /**
   * @param key - The Key used when value was null.
   * @return - A newly created instance of whatever you need to init.
   *
   * Note that you can use Pair<,> or Triple<,,> to overload your key type.
   */
  Value initialize(Key key);

  /**
   * We force subclasses to deal with serializing keys to unique names,
   * so javascript can implement this directly on an object,
   * and you can achieve a degree of portability,
   * by making map structure deterministic.
   *
   * @param key - A key of whatever type you want.  Use {@link Pair} or {@link Triple} to overload.
   * @return - A unique key for dictionary-like sematics
   * try to have a string id pre-constructed;
   * if your object fields are immutable, you can safely construct the id,
   * and never have to null check.
   */
  String toKey(Key key);

  // Add some typed methods, for easier map-like access
  Value get(Key key);
  boolean containsKey(Key key);
  Value put(Key key, Value value);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy