KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > generics > InferTypeArgumentsUpdate


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.corext.refactoring.generics;
13
14 import java.util.ArrayList JavaDoc;
15 import java.util.HashMap JavaDoc;
16 import java.util.List JavaDoc;
17
18 import org.eclipse.core.runtime.Assert;
19
20 import org.eclipse.jdt.core.ICompilationUnit;
21
22 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2;
23 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2;
24
25 public class InferTypeArgumentsUpdate {
26     public static class CuUpdate {
27         private List JavaDoc fDeclarations= new ArrayList JavaDoc();
28         private List JavaDoc fCastsToRemove= new ArrayList JavaDoc();
29
30         public List JavaDoc/*<CollectionElementVariable2>*/ getDeclarations() {
31             return fDeclarations;
32         }
33         
34         public List JavaDoc/*<CastVariable2>*/ getCastsToRemove() {
35             return fCastsToRemove;
36         }
37     }
38     
39     private HashMap JavaDoc/*<ICompilationUnit, CuUpdate>*/ fUpdates= new HashMap JavaDoc();
40     
41     public HashMap JavaDoc/*<ICompilationUnit, CuUpdate>*/ getUpdates() {
42         return fUpdates;
43     }
44     
45     public void addDeclaration(CollectionElementVariable2 elementCv) {
46         ICompilationUnit cu= elementCv.getCompilationUnit();
47         if (cu == null)
48             return;
49         CuUpdate update= getUpdate(cu);
50         update.fDeclarations.add(elementCv);
51     }
52
53     public void addCastToRemove(CastVariable2 castCv) {
54         ICompilationUnit cu= castCv.getCompilationUnit();
55         CuUpdate update= getUpdate(cu);
56         update.fCastsToRemove.add(castCv);
57     }
58
59     private CuUpdate getUpdate(ICompilationUnit cu) {
60         Assert.isNotNull(cu);
61         Object JavaDoc obj= fUpdates.get(cu);
62         CuUpdate update;
63         if (obj == null) {
64             update= new CuUpdate();
65             fUpdates.put(cu, update);
66         } else {
67             update= (CuUpdate) obj;
68         }
69         return update;
70     }
71     
72 }
73
Popular Tags