1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

cosmetics: generics

This commit is contained in:
Andrew Gvozdev 2010-01-25 14:57:54 +00:00
parent 1a51feea87
commit e3e3e5ef70

View file

@ -22,19 +22,20 @@ import org.eclipse.core.runtime.IPath;
public class CSettingEntryFactory { public class CSettingEntryFactory {
private static final HashSet<IPath> EMPTY_SET = new HashSet<IPath>(0); private static final HashSet<IPath> EMPTY_SET = new HashSet<IPath>(0);
private KindBasedStore fStore = new KindBasedStore(false); private KindBasedStore<HashMap<String, ?>> fStore = new KindBasedStore<HashMap<String, ?>>(false);
private HashMap getNameMap(int kind, boolean create){ private <K, V> HashMap<String, HashMap<K, V>> getNameMap(int kind, boolean create, HashMap<K, V> type){
HashMap map = (HashMap)fStore.get(kind); @SuppressWarnings("unchecked")
HashMap<String, HashMap<K, V>> map = (HashMap<String, HashMap<K, V>>) fStore.get(kind);
if(map == null && create){ if(map == null && create){
map = new HashMap(); map = new HashMap<String, HashMap<K, V>>();
fStore.put(kind, map); fStore.put(kind, map);
} }
return map; return map;
} }
private HashMap getValueMap(String name, boolean create){ private <K, V> HashMap<K, V> getValueMap(String name, boolean create, HashMap<K, V> type){
HashMap nameMap = getNameMap(ICSettingEntry.MACRO, create); HashMap<String, HashMap<K, V>> nameMap = getNameMap(ICSettingEntry.MACRO, create, (HashMap<K, V>)null);
if(nameMap != null){ if(nameMap != null){
return getMap(nameMap, name, create); return getMap(nameMap, name, create);
} }
@ -44,21 +45,21 @@ public class CSettingEntryFactory {
private HashMap<Integer, ICSettingEntry> getFlagMap(int kind, String name, String value, IPath[] exclusionPatters, boolean create){ private HashMap<Integer, ICSettingEntry> getFlagMap(int kind, String name, String value, IPath[] exclusionPatters, boolean create){
switch(kind){ switch(kind){
case ICSettingEntry.MACRO: case ICSettingEntry.MACRO:
HashMap valueMap = getValueMap(name, create); HashMap<String, HashMap<Integer, ICSettingEntry>> valueMap = getValueMap(name, create, (HashMap<String, HashMap<Integer, ICSettingEntry>>)null);
if(valueMap != null){ if(valueMap != null){
return getMap(valueMap, name, create); return getMap(valueMap, name, create);
} }
return null; return null;
case ICSettingEntry.SOURCE_PATH: case ICSettingEntry.SOURCE_PATH:
case ICSettingEntry.OUTPUT_PATH: case ICSettingEntry.OUTPUT_PATH:
HashMap excPatternMap = getExclusionPatternsMap(kind, name, create); HashMap<HashSet<IPath>, HashMap<Integer, ICSettingEntry>> excPatternMap = getExclusionPatternsMap(kind, name, create);
if(excPatternMap != null){ if(excPatternMap != null){
HashSet<IPath> setKey = exclusionPatters == null || exclusionPatters.length == 0 ? EMPTY_SET : new HashSet<IPath>(Arrays.asList(exclusionPatters)); HashSet<IPath> setKey = exclusionPatters == null || exclusionPatters.length == 0 ? EMPTY_SET : new HashSet<IPath>(Arrays.asList(exclusionPatters));
return getMap(excPatternMap, setKey, create); return getMap(excPatternMap, setKey, create);
} }
return null; return null;
default: default:
HashMap nameMap = getNameMap(kind, create); HashMap<String, HashMap<Integer, ICSettingEntry>> nameMap = getNameMap(kind, create, (HashMap<Integer, ICSettingEntry>)null);
if(nameMap != null){ if(nameMap != null){
return getMap(nameMap, name, create); return getMap(nameMap, name, create);
} }
@ -66,18 +67,18 @@ public class CSettingEntryFactory {
} }
} }
private HashMap getExclusionPatternsMap(int kind, String name, boolean create){ private HashMap<HashSet<IPath>, HashMap<Integer, ICSettingEntry>> getExclusionPatternsMap(int kind, String name, boolean create){
HashMap nameMap = getNameMap(kind, create); HashMap<String, HashMap<HashSet<IPath>, HashMap<Integer, ICSettingEntry>>> nameMap = getNameMap(kind, create, (HashMap<HashSet<IPath>, HashMap<Integer, ICSettingEntry>>)null);
if(nameMap != null){ if(nameMap != null){
return getMap(nameMap, name, create); return getMap(nameMap, name, create);
} }
return null; return null;
} }
private static HashMap getMap(HashMap container, Object key, boolean create){ private static <Key, K, V> HashMap<K, V> getMap(HashMap<Key, HashMap<K, V>> container, Key key, boolean create){
HashMap map = (HashMap)container.get(key); HashMap<K, V> map = container.get(key);
if(map == null && create){ if(map == null && create){
map = new HashMap(); map = new HashMap<K, V>();
container.put(key, map); container.put(key, map);
} }
return map; return map;