Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/AdapterFactory.java13
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/rebase/RebaseInteractivePlan.java26
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/WorkingTreeFileRevision.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/storage/GitBlobStorage.java2
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/factories/GitFlowAdapterFactory.java54
-rw-r--r--org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorInput.java20
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java32
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogItem.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoryTreeNode.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java12
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/StorageTypedElement.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntryAdapterFactory.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingFolderEntry.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/compare/LocalNonWorkspaceTypedElement.java9
24 files changed, 132 insertions, 136 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/AdapterFactory.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/AdapterFactory.java
index 509b51fd7..a1a59bb0b 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/AdapterFactory.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/AdapterFactory.java
@@ -19,22 +19,19 @@ import org.eclipse.jgit.lib.Repository;
*/
public class AdapterFactory implements IAdapterFactory {
- // TODO: Generify once baseline is Eclipse Neon
@Override
- @SuppressWarnings("unchecked")
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType == Repository.class) {
if (adaptableObject instanceof GitFileRevision) {
- return ((GitFileRevision) adaptableObject).getRepository();
+ return adapterType.cast(
+ ((GitFileRevision) adaptableObject).getRepository());
}
}
return null;
}
- // TODO: Generify once baseline is Eclipse Neon
@Override
- @SuppressWarnings("unchecked")
- public Class[] getAdapterList() {
- return new Class[] { Repository.class };
+ public Class<?>[] getAdapterList() {
+ return new Class<?>[] { Repository.class };
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/rebase/RebaseInteractivePlan.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/rebase/RebaseInteractivePlan.java
index 02149615b..6bd16fa28 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/rebase/RebaseInteractivePlan.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/rebase/RebaseInteractivePlan.java
@@ -109,7 +109,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
public void planWasUpdatedFromRepository(RebaseInteractivePlan plan);
}
- private CopyOnWriteArrayList<RebaseInteractivePlanChangeListener> planChangeListeners = new CopyOnWriteArrayList<RebaseInteractivePlanChangeListener>();
+ private CopyOnWriteArrayList<RebaseInteractivePlanChangeListener> planChangeListeners = new CopyOnWriteArrayList<>();
private List<PlanElement> todoList;
@@ -123,7 +123,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
private ListenerHandle refsChangedListener;
- private static final Map<File, RebaseInteractivePlan> planRegistry = new HashMap<File, RebaseInteractivePlan>();
+ private static final Map<File, RebaseInteractivePlan> planRegistry = new HashMap<>();
private static final String REBASE_TODO = "rebase-merge/git-rebase-todo"; //$NON-NLS-1$
@@ -296,7 +296,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
try {
rebaseTodoLines = repository.readRebaseTodo(REBASE_TODO, true);
} catch (IOException e) {
- rebaseTodoLines = new LinkedList<RebaseTodoLine>();
+ rebaseTodoLines = new LinkedList<>();
}
List<PlanElement> todoElements = createElementList(rebaseTodoLines,
walk);
@@ -308,7 +308,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
try {
rebaseDoneLines = repository.readRebaseTodo(REBASE_DONE, false);
} catch (IOException e) {
- rebaseDoneLines = new LinkedList<RebaseTodoLine>();
+ rebaseDoneLines = new LinkedList<>();
}
List<PlanElement> doneElements = createElementList(rebaseDoneLines,
walk);
@@ -317,7 +317,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
private List<PlanElement> createElementList(
List<RebaseTodoLine> rebaseTodoLines, RevWalk walk) {
- List<PlanElement> planElements = new ArrayList<PlanElement>(
+ List<PlanElement> planElements = new ArrayList<>(
rebaseTodoLines.size());
for (RebaseTodoLine todoLine : rebaseTodoLines) {
PlanElement element = createElement(todoLine, walk);
@@ -432,7 +432,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
.getRepositoryState() != RepositoryState.REBASING_INTERACTIVE) {
return false;
}
- List<RebaseTodoLine> todoLines = new LinkedList<RebaseTodoLine>();
+ List<RebaseTodoLine> todoLines = new LinkedList<>();
for (PlanElement element : planList.getSecondList())
todoLines.add(element.getRebaseTodoLine());
try {
@@ -684,14 +684,12 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
return line.toString();
}
- @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
- // TODO generify once EGit baseline is Eclipse 4.5
+ public <T> T getAdapter(Class<T> adapter) {
if (Repository.class.equals(adapter)) {
- return getRepository();
+ return adapter.cast(getRepository());
} else if (RevCommit.class.equals(adapter)) {
- return getRevCommit();
+ return adapter.cast(getRevCommit());
}
return null;
}
@@ -1010,7 +1008,7 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
*/
public static <L extends List<T>, T> JoinedList<L, T> wrap(L first,
L second) {
- return new JoinedList<L, T>(first, second);
+ return new JoinedList<>(first, second);
}
private static class RelativeIndex<T> {
@@ -1035,8 +1033,8 @@ public class RebaseInteractivePlan implements IndexDiffChangedListener,
private RelativeIndex<T> mapAbsolutIndex(int index) {
if (index < firstList.size())
- return new RelativeIndex<T>(index, firstList);
- return new RelativeIndex<T>(index - firstList.size(), secondList);
+ return new RelativeIndex<>(index, firstList);
+ return new RelativeIndex<>(index - firstList.size(), secondList);
}
/**
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
index b0b028d7a..be9f9c346 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
@@ -268,7 +268,7 @@ class GitFileHistory extends FileHistory implements IAdaptable {
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/WorkingTreeFileRevision.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/WorkingTreeFileRevision.java
index d9f0e6206..b3fa84222 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/WorkingTreeFileRevision.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/WorkingTreeFileRevision.java
@@ -43,7 +43,7 @@ public class WorkingTreeFileRevision extends GitFileRevision {
return new IStorage() {
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/storage/GitBlobStorage.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/storage/GitBlobStorage.java
index 0bab029b2..72573dd20 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/storage/GitBlobStorage.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/storage/GitBlobStorage.java
@@ -166,7 +166,7 @@ public class GitBlobStorage implements IEncodedStorage {
}
@Override
- public Object getAdapter(final Class adapter) {
+ public <T> T getAdapter(final Class<T> adapter) {
return null;
}
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/factories/GitFlowAdapterFactory.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/factories/GitFlowAdapterFactory.java
index 8dbe97d1c..58ea4ae3e 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/factories/GitFlowAdapterFactory.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/factories/GitFlowAdapterFactory.java
@@ -25,32 +25,35 @@ import org.eclipse.team.ui.history.IHistoryView;
* Get JGit repository for element selected in Git Flow UI.
*/
public class GitFlowAdapterFactory implements IAdapterFactory {
- @SuppressWarnings("unchecked")
+
@Override
- public Repository getAdapter(Object adaptableObject, Class adapterType) {
- Repository repository = null;
- if (adaptableObject instanceof IResource) {
- IResource resource = (IResource) adaptableObject;
- repository = getRepository(resource);
- } else if (adaptableObject instanceof IHistoryView) {
- IHistoryView historyView = (IHistoryView) adaptableObject;
- IHistoryPage historyPage = historyView.getHistoryPage();
- Object input = historyPage.getInput();
- if (input instanceof RepositoryNode) {
- RepositoryNode node = (RepositoryNode) input;
- repository = node.getRepository();
- } else if (input instanceof IResource) {
- repository = getRepository((IResource) input);
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
+ if (Repository.class.equals(adapterType)) {
+ Repository repository = null;
+ if (adaptableObject instanceof IResource) {
+ IResource resource = (IResource) adaptableObject;
+ repository = getRepository(resource);
+ } else if (adaptableObject instanceof IHistoryView) {
+ IHistoryView historyView = (IHistoryView) adaptableObject;
+ IHistoryPage historyPage = historyView.getHistoryPage();
+ Object input = historyPage.getInput();
+ if (input instanceof RepositoryNode) {
+ RepositoryNode node = (RepositoryNode) input;
+ repository = node.getRepository();
+ } else if (input instanceof IResource) {
+ repository = getRepository((IResource) input);
+ }
+ } else if (adaptableObject instanceof ISelection) {
+ IStructuredSelection structuredSelection = SelectionUtils
+ .getStructuredSelection((ISelection) adaptableObject);
+ repository = SelectionUtils.getRepository(structuredSelection);
+ } else {
+ return null;
}
- } else if (adaptableObject instanceof ISelection) {
- IStructuredSelection structuredSelection = SelectionUtils
- .getStructuredSelection((ISelection) adaptableObject);
- repository = SelectionUtils.getRepository(structuredSelection);
- } else {
- throw new IllegalStateException();
- }
- return repository;
+ return adapterType.cast(repository);
+ }
+ return null;
}
private Repository getRepository(IResource resource) {
@@ -58,9 +61,8 @@ public class GitFlowAdapterFactory implements IAdapterFactory {
return mapping != null ? mapping.getRepository() : null;
}
- @SuppressWarnings("unchecked")
@Override
- public Class[] getAdapterList() {
- return new Class[] { Repository.class };
+ public Class<?>[] getAdapterList() {
+ return new Class<?>[] { Repository.class };
}
}
diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
index 4d417a979..eb1dd8b85 100644
--- a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
+++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
@@ -50,20 +50,18 @@ public class TaskReferenceFactory implements IAdapterFactory {
private static final String BUGTRACK_URL = "url"; //$NON-NLS-1$
@Override
- @SuppressWarnings({ "rawtypes" })
- public Class[] getAdapterList() {
- final Class[] c = new Class[ADAPTER_TYPES.length];
+ public Class<?>[] getAdapterList() {
+ final Class<?>[] c = new Class[ADAPTER_TYPES.length];
System.arraycopy(ADAPTER_TYPES, 0, c, 0, c.length);
return c;
}
@Override
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (!AbstractTaskReference.class.equals(adapterType))
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
+ if (!AbstractTaskReference.class.equals(adapterType)) {
return null;
-
- return adaptFromObject(adaptableObject);
+ }
+ return adapterType.cast(adaptFromObject(adaptableObject));
}
private AbstractTaskReference adaptFromObject(Object element) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
index ac2add4ca..84ad8d15b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
@@ -88,9 +88,10 @@ public class BlameOperation implements IEGitOperation {
}
@Override
- public Object getAdapter(Class adapter) {
- if (RevCommit.class == adapter)
- return commit;
+ public <T> T getAdapter(Class<T> adapter) {
+ if (RevCommit.class == adapter) {
+ return adapter.cast(commit);
+ }
return Platform.getAdapterManager().getAdapter(this, adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java
index 725fcc7c4..28222f02a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java
@@ -457,18 +457,18 @@ public class CommitEditor extends SharedHeaderFormEditor implements
}
private RepositoryCommit getCommit() {
- return (RepositoryCommit) getAdapter(RepositoryCommit.class);
+ return getAdapter(RepositoryCommit.class);
}
/**
* @see org.eclipse.ui.part.MultiPageEditorPart#getAdapter(java.lang.Class)
*/
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (RepositoryCommit.class == adapter) {
- return AdapterUtils.adapt(getEditorInput(), RepositoryCommit.class);
+ return AdapterUtils.adapt(getEditorInput(), adapter);
} else if (IContentOutlinePage.class == adapter) {
- return getOutlinePage();
+ return adapter.cast(getOutlinePage());
}
return super.getAdapter(adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorInput.java
index cce21162d..ccfe727d0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorInput.java
@@ -80,16 +80,16 @@ public class CommitEditorInput extends PlatformObject implements IEditorInput,
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@Override
- public Object getAdapter(Class adapter) {
- if (RepositoryCommit.class == adapter)
- return commit;
-
- if (RevCommit.class == adapter)
- return commit.getRevCommit();
-
- if (Repository.class == adapter)
- return commit.getRepository();
-
+ public <T> T getAdapter(Class<T> adapter) {
+ if (RepositoryCommit.class == adapter) {
+ return adapter.cast(commit);
+ }
+ if (RevCommit.class == adapter) {
+ return adapter.cast(commit.getRevCommit());
+ }
+ if (Repository.class == adapter) {
+ return adapter.cast(commit.getRepository());
+ }
return super.getAdapter(adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
index 9492bbf8e..1113e1e6d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
@@ -466,7 +466,7 @@ public class CommitEditorPage extends FormPage
protected IAdaptable getDefaultTarget() {
return new PlatformObject() {
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return Platform.getAdapterManager().getAdapter(
getEditorInput(), adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java
index 916bb61b6..88269be58 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java
@@ -158,11 +158,8 @@ public class DiffEditorPage extends TextEditor
this(editor, "diffPage", UIText.DiffEditorPage_Title); //$NON-NLS-1$
}
- @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
- // TODO Switch to generified signature once EGit's base dependency is
- // Eclipse 4.6
+ public <T> T getAdapter(Class<T> adapter) {
if (IContentOutlinePage.class.equals(adapter)) {
if (outlinePage == null) {
outlinePage = createOutlinePage();
@@ -173,7 +170,7 @@ public class DiffEditorPage extends TextEditor
new StructuredSelection(currentFileDiffRange));
}
}
- return outlinePage;
+ return adapter.cast(outlinePage);
}
return super.getAdapter(adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
index b3bfbdb8b..58094c341 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
@@ -73,22 +73,23 @@ public class GitAdapterFactory implements IAdapterFactory {
.getRoot();
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType.isAssignableFrom(IHistoryPageSource.class)) {
- return GitHistoryPageSource.INSTANCE;
+ return adapterType.cast(GitHistoryPageSource.INSTANCE);
}
if (IWorkbenchAdapter.class == adapterType) {
if (adaptableObject instanceof RepositoryTreeNode) {
- return RepositoryTreeNodeWorkbenchAdapter.INSTANCE;
+ return adapterType
+ .cast(RepositoryTreeNodeWorkbenchAdapter.INSTANCE);
} else if (adaptableObject instanceof FileDiff) {
- return FileDiffWorkbenchAdapter.INSTANCE;
+ return adapterType.cast(FileDiffWorkbenchAdapter.INSTANCE);
}
if (gitModelWorkbenchAdapter == null) {
gitModelWorkbenchAdapter = new GitModelWorkbenchAdapter();
}
- return gitModelWorkbenchAdapter;
+ return adapterType.cast(gitModelWorkbenchAdapter);
}
if (adaptableObject instanceof IHistoryView
@@ -96,23 +97,25 @@ public class GitAdapterFactory implements IAdapterFactory {
IHistoryView historyView = (IHistoryView) adaptableObject;
IHistoryPage historyPage = historyView.getHistoryPage();
if (historyPage instanceof GitHistoryPage) {
- return historyPage;
+ return adapterType.cast(historyPage);
}
}
if (adaptableObject instanceof IURIEditorInput
&& adapterType == Repository.class) {
- return getRepository((IURIEditorInput) adaptableObject);
+ return adapterType
+ .cast(getRepository((IURIEditorInput) adaptableObject));
}
if (adaptableObject instanceof IURIEditorInput
&& adapterType == File.class) {
- return getFile((IURIEditorInput) adaptableObject);
+ return adapterType.cast(getFile((IURIEditorInput) adaptableObject));
}
if (adaptableObject instanceof GitModelObject
&& adapterType == ResourceMapping.class) {
- return GitObjectMapping.create((GitModelObject) adaptableObject);
+ return adapterType.cast(
+ GitObjectMapping.create((GitModelObject) adaptableObject));
}
if (adaptableObject instanceof GitModelObject
@@ -127,7 +130,7 @@ public class GitAdapterFactory implements IAdapterFactory {
res = getWorkspaceResourceFromGitPath(obj.getLocation());
}
- return res;
+ return adapterType.cast(res);
}
if (obj instanceof GitModelTree) {
@@ -136,7 +139,7 @@ public class GitAdapterFactory implements IAdapterFactory {
res = root.getFolder(obj.getLocation());
}
- return res;
+ return adapterType.cast(res);
}
}
@@ -144,7 +147,8 @@ public class GitAdapterFactory implements IAdapterFactory {
ResourceMapping m = AdapterUtils.adapt(adaptableObject,
ResourceMapping.class);
if (m != null) {
- return SelectionUtils.getRepository(new StructuredSelection(m));
+ return adapterType.cast(SelectionUtils
+ .getRepository(new StructuredSelection(m)));
}
}
@@ -208,8 +212,8 @@ public class GitAdapterFactory implements IAdapterFactory {
}
@Override
- public Class[] getAdapterList() {
- return new Class[] { IHistoryPageSource.class,
+ public Class<?>[] getAdapterList() {
+ return new Class<?>[] { IHistoryPageSource.class,
ISynchronizationCompareAdapter.class, ResourceMapping.class,
IResource.class, IWorkbenchAdapter.class, IShowInSource.class,
Repository.class, File.class, IHistoryPageSource.class};
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 62f77e34f..64a032b58 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -2133,7 +2133,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
}
@Override
- public Object getAdapter(final Class adapter) {
+ public <T> T getAdapter(final Class<T> adapter) {
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java
index e890c3f96..fa3337bbe 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java
@@ -49,11 +49,11 @@ class SWTCommit extends PlotCommit<SWTCommitList.SWTLane>
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter != Repository.class) {
return null;
}
- return getRepository();
+ return adapter.cast(getRepository());
}
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogItem.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogItem.java
index 6229465f9..355b3ef51 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogItem.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogItem.java
@@ -39,14 +39,12 @@ public class ReflogItem implements ReflogEntry, IAdaptable, IRepositoryObject {
this.commitMessage = commitMessage;
}
- @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
- // TODO generify once EGit base version is Eclipse 4.5
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter.isInstance(this)) {
- return this;
+ return adapter.cast(this);
} else if (Repository.class.equals(adapter)) {
- return getRepository();
+ return adapter.cast(getRepository());
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index 967abdccf..102a18258 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -400,14 +400,13 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
// integrate with Properties view
if (adapter == IPropertySheetPage.class) {
PropertySheetPage page = new PropertySheetPage();
- page
- .setPropertySourceProvider(new RepositoryPropertySourceProvider(
- page));
- return page;
+ page.setPropertySourceProvider(
+ new RepositoryPropertySourceProvider(page));
+ return adapter.cast(page);
}
return super.getAdapter(adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoryTreeNode.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoryTreeNode.java
index 9929074c9..ab6f46f37 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoryTreeNode.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoryTreeNode.java
@@ -414,13 +414,13 @@ public abstract class RepositoryTreeNode<T> extends PlatformObject implements Co
}
@Override
- public Object getAdapter(Class adapter) {
+ public <X> X getAdapter(Class<X> adapter) {
if (Repository.class == adapter && myRepository != null) {
- return myRepository;
+ return adapter.cast(myRepository);
}
if (myObject != null) {
if (adapter.isInstance(myObject)) {
- return myObject;
+ return adapter.cast(myObject);
}
}
return super.getAdapter(adapter);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
index dd3ad10bd..ad5fe3ec3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
@@ -78,7 +78,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
if (storage instanceof IFileState) {
return new IFileState() {
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return AdapterUtils.adapt(storage, adapter);
}
@@ -121,7 +121,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
return new IEncodedStorage() {
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return AdapterUtils.adapt(storage, adapter);
}
@@ -226,16 +226,16 @@ public class FileRevisionEditorInput extends PlatformObject implements
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IWorkbenchAdapter.class) {
- return this;
+ return adapter.cast(this);
}
if (adapter == IStorage.class) {
- return storage;
+ return adapter.cast(storage);
}
Object object = super.getAdapter(adapter);
if (object != null) {
- return object;
+ return adapter.cast(object);
}
return AdapterUtils.adapt(fileRevision, adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java
index c0e473e3e..ee7f29740 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java
@@ -57,13 +57,13 @@ public class FileRevisionTypedElement extends StorageTypedElement {
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
Object result = super.getAdapter(adapter);
if (result != null && adapter.isInstance(result)) {
- return result;
+ return adapter.cast(result);
}
if (adapter == Repository.class) {
- return AdapterUtils.adapt(fileRevision, Repository.class);
+ return AdapterUtils.adapt(fileRevision, adapter);
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/StorageTypedElement.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/StorageTypedElement.java
index 6e06b53b1..72c5c6f7e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/StorageTypedElement.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/StorageTypedElement.java
@@ -125,13 +125,13 @@ abstract class StorageTypedElement implements ITypedElement,
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == ISharedDocumentAdapter.class) {
synchronized (this) {
if (sharedDocumentAdapter == null) {
sharedDocumentAdapter = createSharedDocumentAdapter();
}
- return sharedDocumentAdapter;
+ return adapter.cast(sharedDocumentAdapter);
}
}
return Platform.getAdapterManager().getAdapter(this, adapter);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntryAdapterFactory.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntryAdapterFactory.java
index d45ae29bd..632897d89 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntryAdapterFactory.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntryAdapterFactory.java
@@ -22,26 +22,27 @@ import org.eclipse.jgit.lib.Repository;
public class StagingEntryAdapterFactory implements IAdapterFactory {
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adaptableObject != null) {
StagingEntry entry = (StagingEntry) adaptableObject;
if (adapterType == IResource.class) {
IResource resource = entry.getFile();
if (resource != null && resource.isAccessible()) {
- return resource;
+ return adapterType.cast(resource);
}
} else if (adapterType == IPath.class) {
- return entry.getLocation();
+ return adapterType.cast(entry.getLocation());
} else if (adapterType == Repository.class) {
- return entry.getRepository();
+ return adapterType.cast(entry.getRepository());
}
}
return null;
}
@Override
- public Class[] getAdapterList() {
- return new Class[] { IResource.class, IPath.class, Repository.class };
+ public Class<?>[] getAdapterList() {
+ return new Class<?>[] { IResource.class, IPath.class,
+ Repository.class };
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingFolderEntry.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingFolderEntry.java
index 078bee8d0..efed584f6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingFolderEntry.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingFolderEntry.java
@@ -69,11 +69,11 @@ public class StagingFolderEntry implements IAdaptable, IProblemDecoratable {
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IResource.class || adapter == IContainer.class)
- return getContainer();
+ return adapter.cast(getContainer());
else if (adapter == IPath.class)
- return getLocation();
+ return adapter.cast(getLocation());
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/compare/LocalNonWorkspaceTypedElement.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/compare/LocalNonWorkspaceTypedElement.java
index 730861596..756641917 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/compare/LocalNonWorkspaceTypedElement.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/compare/LocalNonWorkspaceTypedElement.java
@@ -359,12 +359,13 @@ public class LocalNonWorkspaceTypedElement extends LocalResourceTypedElement {
@Override
public Object getAdapter(Class adapter) {
if (adapter == ISharedDocumentAdapter.class) {
- if (isSharedDocumentsEnable())
+ if (isSharedDocumentsEnable()) {
return getSharedDocumentAdapter();
- else
- return null;
+ }
+ return null;
}
- return Platform.getAdapterManager().getAdapter(this, adapter);
+ return Platform.getAdapterManager().getAdapter(this,
+ (Class<?>) adapter);
}
@Override

Back to the top