001/*-------------------------------------------------------------------------+ 002| | 003| Copyright 2005-2011 The ConQAT Project | 004| | 005| Licensed under the Apache License, Version 2.0 (the "License"); | 006| you may not use this file except in compliance with the License. | 007| You may obtain a copy of the License at | 008| | 009| http://www.apache.org/licenses/LICENSE-2.0 | 010| | 011| Unless required by applicable law or agreed to in writing, software | 012| distributed under the License is distributed on an "AS IS" BASIS, | 013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 014| See the License for the specific language governing permissions and | 015| limitations under the License. | 016+-------------------------------------------------------------------------*/ 017package org.conqat.lib.commons.collections; 018 019import java.util.HashMap; 020import java.util.Map; 021 022/** 023 * This class assigns unique ids to objects. The id creation is based on 024 * <code>hashCode()/equals()</code>-semantics. 025 * 026 * <p> 027 * Note that obtaining a unique id from this class for an object prevents it 028 * from being garbage collected. 029 * 030 * 031 * @author Florian Deissenboeck 032 */ 033public class IdManager<K> extends IdManagerBase<K> { 034 035 /** 036 * Create new id manager 037 * 038 */ 039 public IdManager() { 040 super(new HashMap<K, Integer>()); 041 } 042 043 /** 044 * Creates a new id manager that used the given map as initial object->id 045 * map. 046 */ 047 public IdManager(Map<K, Integer> initialMap) { 048 super(initialMap); 049 } 050 051}