mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
cosmetics: generics
This commit is contained in:
parent
3d60e9196b
commit
fa91dcc051
3 changed files with 57 additions and 54 deletions
|
@ -243,8 +243,7 @@ public final class PathSettingsContainer {
|
|||
if(pMap != null){
|
||||
if(list == null)
|
||||
list = new ArrayList<PathSettingsContainer>();
|
||||
for(Iterator iter = pMap.values().iterator(); iter.hasNext(); ){
|
||||
PathSettingsContainer cr = (PathSettingsContainer)iter.next();
|
||||
for (PathSettingsContainer cr : pMap.values()) {
|
||||
if(cr.fValue == INEXISTENT_VALUE){
|
||||
cr.doGetDirectChildren(list);
|
||||
} else {
|
||||
|
@ -256,7 +255,7 @@ public final class PathSettingsContainer {
|
|||
}
|
||||
|
||||
public Object[] getValues(final boolean includeThis){
|
||||
final List list = new ArrayList();
|
||||
final List<Object> list = new ArrayList<Object>();
|
||||
accept(new IPathSettingsContainerVisitor(){
|
||||
|
||||
public boolean visit(PathSettingsContainer container) {
|
||||
|
@ -332,8 +331,8 @@ public final class PathSettingsContainer {
|
|||
return;
|
||||
|
||||
|
||||
Collection c = pMap.values();
|
||||
PathSettingsContainer childContainers[] = (PathSettingsContainer[])c.toArray(new PathSettingsContainer[c.size()]);
|
||||
Collection<PathSettingsContainer> c = pMap.values();
|
||||
PathSettingsContainer childContainers[] = c.toArray(new PathSettingsContainer[c.size()]);
|
||||
|
||||
for (PathSettingsContainer childContainer : childContainers) {
|
||||
childContainer.removeChildren();
|
||||
|
@ -520,8 +519,7 @@ public final class PathSettingsContainer {
|
|||
|
||||
PatternNameMap pMap = getPatternChildrenMap(false);
|
||||
if(pMap != null){
|
||||
for(Iterator iter = pMap.values().iterator(); iter.hasNext();){
|
||||
PathSettingsContainer child = (PathSettingsContainer)iter.next();
|
||||
for (PathSettingsContainer child : pMap.values()) {
|
||||
if(!child.doAccept(visitor))
|
||||
return false;
|
||||
}
|
||||
|
@ -551,8 +549,8 @@ public final class PathSettingsContainer {
|
|||
if(!moveChildren){
|
||||
if(hasChildren()){
|
||||
PathSettingsContainer cr = new PathSettingsContainer(fRootContainer, fDirectParentContainer, fName, fIsPatternMode);
|
||||
for(Iterator iter = fPatternChildrenMap.values().iterator(); iter.hasNext();){
|
||||
PathSettingsContainer child = (PathSettingsContainer)iter.next();
|
||||
for(Iterator<PathSettingsContainer> iter = fPatternChildrenMap.values().iterator(); iter.hasNext();){
|
||||
PathSettingsContainer child = iter.next();
|
||||
iter.remove();
|
||||
child.setParent(cr);
|
||||
cr.connectChild(child);
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
|
||||
|
@ -25,9 +26,9 @@ public class PatternNameMap {
|
|||
private static final char[] SPEC_CHARS = new char[]{'*', '?'};
|
||||
static final String DOUBLE_STAR_PATTERN = "**"; //$NON-NLS-1$
|
||||
|
||||
private Map fChildrenMap;
|
||||
private Map fPatternMap;
|
||||
private Collection fValues;
|
||||
private Map<String, PathSettingsContainer> fChildrenMap;
|
||||
private Map<StringCharArray, PathSettingsContainer> fPatternMap;
|
||||
private Collection<PathSettingsContainer> fValues;
|
||||
private boolean fContainsDoubleStar;
|
||||
|
||||
private static class StringCharArray {
|
||||
|
@ -67,13 +68,13 @@ public class PatternNameMap {
|
|||
}
|
||||
}
|
||||
|
||||
private class EmptyIterator implements Iterator{
|
||||
private class EmptyIterator implements Iterator<PathSettingsContainer>{
|
||||
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
public PathSettingsContainer next() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
|
@ -83,27 +84,27 @@ public class PatternNameMap {
|
|||
|
||||
}
|
||||
|
||||
private class ValuesCollection extends AbstractCollection {
|
||||
private class ValuesCollection extends AbstractCollection<PathSettingsContainer> {
|
||||
|
||||
private class Iter implements Iterator {
|
||||
private Iterator fEntrySetIter;
|
||||
private Map.Entry fCur;
|
||||
private class Iter implements Iterator<PathSettingsContainer> {
|
||||
private Iterator<Entry<String, PathSettingsContainer>> fEntrySetIter;
|
||||
private Entry<String, PathSettingsContainer> fCur;
|
||||
|
||||
Iter (Iterator entryIter){
|
||||
Iter (Iterator<Entry<String, PathSettingsContainer>> entryIter){
|
||||
this.fEntrySetIter = entryIter;
|
||||
}
|
||||
public boolean hasNext() {
|
||||
return fEntrySetIter.hasNext();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
fCur = (Map.Entry)fEntrySetIter.next();
|
||||
public PathSettingsContainer next() {
|
||||
fCur = fEntrySetIter.next();
|
||||
return fCur.getValue();
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
fEntrySetIter.remove();
|
||||
String name = (String)fCur.getKey();
|
||||
String name = fCur.getKey();
|
||||
if(DOUBLE_STAR_PATTERN.equals(name)){
|
||||
fContainsDoubleStar = false;
|
||||
} else {
|
||||
|
@ -113,8 +114,8 @@ public class PatternNameMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterator iterator() {
|
||||
return fChildrenMap != null ? (Iterator)new Iter(fChildrenMap.entrySet().iterator()) : (Iterator)new EmptyIterator();
|
||||
public Iterator<PathSettingsContainer> iterator() {
|
||||
return fChildrenMap != null ? new Iter(fChildrenMap.entrySet().iterator()) : new EmptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,7 +134,7 @@ public class PatternNameMap {
|
|||
}
|
||||
}
|
||||
|
||||
public Object get(String name){
|
||||
public /* PathSettingsContainer */ Object get(String name){
|
||||
return fChildrenMap != null ? fChildrenMap.get(name) : null;
|
||||
}
|
||||
|
||||
|
@ -153,35 +154,35 @@ public class PatternNameMap {
|
|||
return (fPatternMap != null && fPatternMap.size() != 0);
|
||||
}
|
||||
|
||||
public List getValues(String name){
|
||||
public List<PathSettingsContainer> getValues(String name){
|
||||
if(fChildrenMap == null)
|
||||
return null;
|
||||
|
||||
Object val = fChildrenMap.get(name);
|
||||
PathSettingsContainer val = fChildrenMap.get(name);
|
||||
if(hasPatternsMap()){
|
||||
List list;
|
||||
List<PathSettingsContainer> list;
|
||||
if(val != null){
|
||||
list = new ArrayList(3);
|
||||
list = new ArrayList<PathSettingsContainer>(3);
|
||||
list.add(val);
|
||||
} else {
|
||||
list = null;;
|
||||
list = null;
|
||||
}
|
||||
|
||||
Map.Entry entry;
|
||||
Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer> entry;
|
||||
StringCharArray strCA;
|
||||
char[] nameCharArray = name.toCharArray();
|
||||
for(Iterator iter = fPatternMap.entrySet().iterator(); iter.hasNext();){
|
||||
entry = (Map.Entry)iter.next();
|
||||
strCA = (StringCharArray)entry.getKey();
|
||||
for(Iterator<Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer>> iter = fPatternMap.entrySet().iterator(); iter.hasNext();){
|
||||
entry = iter.next();
|
||||
strCA = entry.getKey();
|
||||
if(CoreModelUtil.match(strCA.getCharArray(), nameCharArray, true)){
|
||||
if(list == null)
|
||||
list = new ArrayList(2);
|
||||
list = new ArrayList<PathSettingsContainer>(2);
|
||||
list.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
} else if (val != null){
|
||||
List list = new ArrayList(1);
|
||||
List<PathSettingsContainer> list = new ArrayList<PathSettingsContainer>(1);
|
||||
list.add(val);
|
||||
return list;
|
||||
}
|
||||
|
@ -192,13 +193,17 @@ public class PatternNameMap {
|
|||
return fContainsDoubleStar;
|
||||
}
|
||||
|
||||
public Object put(String name, Object value){
|
||||
if(value == null)
|
||||
return remove(name);
|
||||
public /* PathSettingsContainer */ Object put(String name, /* PathSettingsContainer */Object value){
|
||||
return put(name, (PathSettingsContainer)value);
|
||||
}
|
||||
|
||||
Object oldValue;
|
||||
private PathSettingsContainer put(String name, PathSettingsContainer value){
|
||||
if(value == null)
|
||||
return (PathSettingsContainer)remove(name);
|
||||
|
||||
PathSettingsContainer oldValue;
|
||||
if(fChildrenMap == null){
|
||||
fChildrenMap = new HashMap();
|
||||
fChildrenMap = new HashMap<String, PathSettingsContainer>();
|
||||
oldValue = null;
|
||||
} else {
|
||||
oldValue = fChildrenMap.get(name);
|
||||
|
@ -211,7 +216,7 @@ public class PatternNameMap {
|
|||
} else if(isPatternName(name)){
|
||||
StringCharArray strCA = new StringCharArray(name);
|
||||
if(fPatternMap == null)
|
||||
fPatternMap = new HashMap();
|
||||
fPatternMap = new HashMap<StringCharArray, PathSettingsContainer>();
|
||||
|
||||
fPatternMap.put(strCA, value);
|
||||
}
|
||||
|
@ -219,9 +224,9 @@ public class PatternNameMap {
|
|||
return oldValue;
|
||||
}
|
||||
|
||||
public Object remove(String name){
|
||||
public /* PathSettingsContainer */ Object remove(String name){
|
||||
if(fChildrenMap != null){
|
||||
Object oldVal = fChildrenMap.remove(name);
|
||||
PathSettingsContainer oldVal = fChildrenMap.remove(name);
|
||||
if(fChildrenMap.size() == 0){
|
||||
fChildrenMap = null;
|
||||
fPatternMap = null;
|
||||
|
@ -263,7 +268,7 @@ public class PatternNameMap {
|
|||
fContainsDoubleStar = false;
|
||||
}
|
||||
|
||||
public Collection values(){
|
||||
public Collection<PathSettingsContainer> values(){
|
||||
if(fValues == null)
|
||||
fValues = new ValuesCollection();
|
||||
return fValues;
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,10 +14,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class ThreadLocalMap {
|
||||
private ThreadLocal fLocal = new ThreadLocal();
|
||||
private ThreadLocal<Map<Object, Object>> fLocal = new ThreadLocal<Map<Object, Object>>();
|
||||
|
||||
public Object get(Object key){
|
||||
Map map = getMap(false);
|
||||
Map<Object, Object> map = getMap(false);
|
||||
return map != null ? map.get(key) : null;
|
||||
}
|
||||
|
||||
|
@ -25,24 +25,24 @@ public class ThreadLocalMap {
|
|||
if(value == null)
|
||||
clear(key);
|
||||
else {
|
||||
Map map = getMap(true);
|
||||
Map<Object, Object> map = getMap(true);
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear(Object key){
|
||||
Map map = getMap(false);
|
||||
Map<Object, Object> map = getMap(false);
|
||||
if(map != null){
|
||||
map.remove(key);
|
||||
if(map == null)
|
||||
fLocal.set(null);
|
||||
}
|
||||
// if(map == null)
|
||||
// fLocal.set(null);
|
||||
}
|
||||
|
||||
private Map getMap(boolean create){
|
||||
Map map = (Map)fLocal.get();
|
||||
private Map<Object, Object> getMap(boolean create){
|
||||
Map<Object, Object> map = fLocal.get();
|
||||
if(map == null && create){
|
||||
map = new HashMap();
|
||||
map = new HashMap<Object, Object>();
|
||||
fLocal.set(map);
|
||||
}
|
||||
return map;
|
||||
|
|
Loading…
Add table
Reference in a new issue