From b3e202b8c72c79edf615f93d590c49af074862ce Mon Sep 17 00:00:00 2001 From: Vasyl' Vavrychuk Date: Mon, 5 Jan 2009 00:20:19 +0200 Subject: [PATCH] Parametrized raw types in a few places. Signed-off-by: Vasyl Vavrychuk Signed-off-by: Robin Rosenberg --- .../spearce/egit/core/project/GitProjectData.java | 18 ++++++-------- .../egit/core/project/RepositoryFinder.java | 5 ++-- .../tst/org/spearce/jgit/lib/T0002_Tree.java | 4 +-- .../src/org/spearce/jgit/lib/GitIndex.java | 29 ++++++++++------------ .../src/org/spearce/jgit/lib/ObjectIdMap.java | 1 - .../jgit/lib/TreeVisitorWithCurrentDirectory.java | 5 ++-- 6 files changed, 27 insertions(+), 35 deletions(-) diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java index 04130dba..db5f20b3 100644 --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java @@ -48,9 +48,9 @@ import org.spearce.jgit.lib.WindowCache; * a Git repository. */ public class GitProjectData { - private static final Map projectDataCache = new HashMap(); + private static final Map projectDataCache = new HashMap(); - private static final Map repositoryCache = new HashMap(); + private static final Map repositoryCache = new HashMap(); private static RepositoryChangeListener[] repositoryChangeListeners = {}; @@ -193,7 +193,7 @@ public class GitProjectData { } private synchronized static GitProjectData lookup(final IProject p) { - return (GitProjectData) projectDataCache.get(p); + return projectDataCache.get(p); } private synchronized static Repository lookupRepository(final File gitDir) @@ -206,11 +206,11 @@ public class GitProjectData { } } - final Reference r = (Reference) repositoryCache.get(gitDir); + final Reference r = repositoryCache.get(gitDir); Repository d = r != null ? (Repository) r.get() : null; if (d == null) { d = new Repository(gitDir); - repositoryCache.put(gitDir, new WeakReference(d)); + repositoryCache.put(gitDir, new WeakReference(d)); } return d; } @@ -229,9 +229,9 @@ public class GitProjectData { private final IProject project; - private final Collection mappings; + private final Collection mappings = new ArrayList(); - private final Set protectedResources; + private final Set protectedResources = new HashSet(); /** * Construct a {@link GitProjectData} for the mapping @@ -241,8 +241,6 @@ public class GitProjectData { */ public GitProjectData(final IProject p) { project = p; - mappings = new ArrayList(); - protectedResources = new HashSet(); } /** @@ -257,7 +255,7 @@ public class GitProjectData { * * @param newMappings */ - public void setRepositoryMappings(final Collection newMappings) { + public void setRepositoryMappings(final Collection newMappings) { mappings.clear(); mappings.addAll(newMappings); remapAll(); diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java index c33f3a0a..2b4b16fa 100644 --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java @@ -47,7 +47,7 @@ import org.spearce.egit.core.CoreText; public class RepositoryFinder { private final IProject proj; - private final Collection results; + private final Collection results = new ArrayList(); /** * Create a new finder to locate Git repositories for a project. @@ -58,7 +58,6 @@ public class RepositoryFinder { */ public RepositoryFinder(final IProject p) { proj = p; - results = new ArrayList(); } /** @@ -72,7 +71,7 @@ public class RepositoryFinder { * Eclipse was unable to access its workspace, and threw up on * us. We're throwing it back at the caller. */ - public Collection find(IProgressMonitor m) throws CoreException { + public Collection find(IProgressMonitor m) throws CoreException { if (m == null) { m = new NullProgressMonitor(); } diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java index fcb4d96b..97f299c3 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java @@ -236,7 +236,7 @@ public class T0002_Tree extends RepositoryTestCase { public void test007_manyFileLookup() throws IOException { final Tree t = new Tree(db); - final List files = new ArrayList(26 * 26); + final List files = new ArrayList(26 * 26); for (char level1 = 'a'; level1 <= 'z'; level1++) { for (char level2 = 'a'; level2 <= 'z'; level2++) { final String n = "." + level1 + level2 + "9"; @@ -251,7 +251,7 @@ public class T0002_Tree extends RepositoryTestCase { assertNotNull(ents); assertEquals(files.size(), ents.length); for (int k = 0; k < ents.length; k++) { - assertTrue("File " + ((FileTreeEntry) files.get(k)).getName() + assertTrue("File " + files.get(k).getName() + " is at " + k + ".", files.get(k) == ents[k]); } } diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java index 7ff67540..454b5402 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java @@ -107,18 +107,16 @@ public class GitIndex { private final Repository db; - private Map entries = new TreeMap(new Comparator() { - public int compare(Object arg0, Object arg1) { - byte[] a = (byte[]) arg0; - byte[] b = (byte[]) arg1; - for (int i = 0; i < a.length && i < b.length; ++i) { - int c = a[i] - b[i]; + private Map entries = new TreeMap(new Comparator() { + public int compare(byte[] o1, byte[] o2) { + for (int i = 0; i < o1.length && i < o2.length; ++i) { + int c = o1[i] - o2[i]; if (c != 0) return c; } - if (a.length < b.length) + if (o1.length < o2.length) return -1; - else if (a.length > b.length) + else if (o1.length > o2.length) return 1; return 0; } @@ -161,7 +159,7 @@ public class GitIndex { */ public Entry add(File wd, File f) throws IOException { byte[] key = makeKey(wd, f); - Entry e = (Entry) entries.get(key); + Entry e = entries.get(key); if (e == null) { e = new Entry(key, f, 0); entries.put(key, e); @@ -302,7 +300,7 @@ public class GitIndex { return FS.INSTANCE.supportsExecute(); } - static byte[] makeKey(File wd, File f) throws IOException { + static byte[] makeKey(File wd, File f) { if (!f.getPath().startsWith(wd.getPath())) throw new Error("Path is not in working dir"); String relName = Repository.stripWorkDir(wd, f); @@ -362,8 +360,7 @@ public class GitIndex { flags = (short) ((stage << 12) | name.length); // TODO: fix flags } - Entry(TreeEntry f, int stage) - throws UnsupportedEncodingException { + Entry(TreeEntry f, int stage) { ctime = -1; // hmm mtime = -1; dev = -1; @@ -810,7 +807,7 @@ public class GitIndex { checkWriteOk(); ObjectWriter writer = new ObjectWriter(db); Tree current = new Tree(db); - Stack trees = new Stack(); + Stack trees = new Stack(); trees.push(current); String[] prevName = new String[0]; for (Iterator i = entries.values().iterator(); i.hasNext();) { @@ -844,7 +841,7 @@ public class GitIndex { current.setId(writer.writeTree(current)); trees.pop(); if (!trees.isEmpty()) - current = (Tree) trees.peek(); + current = trees.peek(); } return current.getTreeId(); } @@ -886,7 +883,7 @@ public class GitIndex { * @return The index entries sorted */ public Entry[] getMembers() { - return (Entry[]) entries.values().toArray(new Entry[entries.size()]); + return entries.values().toArray(new Entry[entries.size()]); } /** @@ -897,7 +894,7 @@ public class GitIndex { * @throws UnsupportedEncodingException */ public Entry getEntry(String path) throws UnsupportedEncodingException { - return (Entry) entries.get(Repository.gitInternalSlash(Constants.encode(path))); + return entries.get(Repository.gitInternalSlash(Constants.encode(path))); } /** diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java index 600d0f47..d3c7f1db 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java @@ -178,7 +178,6 @@ public class ObjectIdMap extends AbstractMap { return true; } - @SuppressWarnings("unchecked") public V put(ObjectId key, V value) { return submap(key).put(key, value); } diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java index 55854b2d..e227adb8 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java @@ -46,12 +46,11 @@ import java.util.ArrayList; * Abstract TreeVisitor for visiting all files known by a Tree. */ public abstract class TreeVisitorWithCurrentDirectory implements TreeVisitor { - private final ArrayList stack; + private final ArrayList stack = new ArrayList(16); private File currentDirectory; protected TreeVisitorWithCurrentDirectory(final File rootDirectory) { - stack = new ArrayList(16); currentDirectory = rootDirectory; } @@ -67,6 +66,6 @@ public abstract class TreeVisitorWithCurrentDirectory implements TreeVisitor { } public void endVisitTree(final Tree t) throws IOException { - currentDirectory = (File) stack.remove(stack.size() - 1); + currentDirectory = stack.remove(stack.size() - 1); } } -- 2.11.4.GIT