1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

cosmetics: generics

This commit is contained in:
Andrew Gvozdev 2010-01-25 18:59:21 +00:00
parent 891a5172a0
commit 28c7d3f789

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others. * Copyright (c) 2007, 2010 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,19 +10,18 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.settings.model.util; package org.eclipse.cdt.core.settings.model.util;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry;
public class CEntriesSet { public class CEntriesSet {
private LinkedHashMap fEntriesMap = new LinkedHashMap(); private LinkedHashMap<Object, ICSettingEntry> fEntriesMap = new LinkedHashMap<Object, ICSettingEntry>();
public CEntriesSet(){ public CEntriesSet(){
} }
public CEntriesSet(List list){ public CEntriesSet(List<ICSettingEntry> list){
setEntries(list); setEntries(list);
} }
@ -42,7 +41,7 @@ public class CEntriesSet {
} }
*/ */
public ICSettingEntry[] toArray() { public ICSettingEntry[] toArray() {
return (ICSettingEntry[])fEntriesMap.values().toArray(new ICSettingEntry[fEntriesMap.size()]); return fEntriesMap.values().toArray(new ICSettingEntry[fEntriesMap.size()]);
} }
protected Object getKey(ICSettingEntry entry){ protected Object getKey(ICSettingEntry entry){
@ -50,28 +49,23 @@ public class CEntriesSet {
} }
public ICSettingEntry addEntry(ICSettingEntry entry) { public ICSettingEntry addEntry(ICSettingEntry entry) {
return (ICSettingEntry)fEntriesMap.put(getKey(entry), entry); return fEntriesMap.put(getKey(entry), entry);
} }
public void clear() { public void clear() {
fEntriesMap.clear(); fEntriesMap.clear();
} }
public void setEntries(List list) { public void setEntries(List<ICSettingEntry> list) {
clear(); clear();
for(Iterator iter = list.iterator(); iter.hasNext();){ for (ICSettingEntry entry : list) {
Object obj = iter.next();
if(obj instanceof ICSettingEntry){
ICSettingEntry entry = (ICSettingEntry)obj;
addEntry(entry); addEntry(entry);
} }
} }
}
public void setEntries(ICSettingEntry[] entries) { public void setEntries(ICSettingEntry[] entries) {
clear(); clear();
for(int i = 0; i < entries.length; i++){ for (ICSettingEntry entry : entries) {
ICSettingEntry entry = entries[i];
if(entry != null){ if(entry != null){
addEntry(entry); addEntry(entry);
} }