1 package org.sourceforge.jemm.client.id; 2 3 import org.sourceforge.jemm.types.ID; 4 5 /** 6 * A Factory which produces TrackedID flyweights. 7 * 8 * @see TrackedIDFactoryImpl 9 * @author Paul Keeble 10 * 11 */ 12 public interface TrackedIDFactory { 13 14 /** 15 * Determines if a TrackedID already exists and if so uses it, 16 * otherwise creates a new TrackedID and maps that weakly and returns 17 * the value. 18 * 19 * @param id The id to look up 20 * @return The TrackedID associated with the ID 21 */ 22 TrackedID create(ID id); 23 24 /** 25 * Returns true if there is a TrackedID for that ID, false otherwise. 26 * 27 * @param id The ID to lookup 28 * @return True if the TrackedID is present, false otherwise. 29 */ 30 boolean contains(ID id); 31 32 /** 33 * Gets a TrackedID if it exists, otherwise returns null. 34 * 35 * @param id The ID to find. 36 * @return The TrackedID or null if not found 37 */ 38 TrackedID get(ID id); 39 40 /** 41 * Removes a mapping for an ID and the associated TrackedID. 42 * 43 * @param id 44 */ 45 void remove(ID id); 46 47 /** 48 * Adds a listener which receives notification if a trackedID 49 * is enqueued for garbage collection. 50 * 51 * @param listener 52 */ 53 void addListener(TrackedIDListener listener); 54 55 /** 56 * Removes the listener 57 * 58 * @param listener 59 */ 60 void removeListener(TrackedIDListener listener); 61 }