aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-03-16 03:32:09 -0400
committerFred Bricon2018-03-16 10:26:12 -0400
commit488950756d0040364f3f035ad9082e7b8b5cc9f4 (patch)
treec312f5a3399dd55cb3c3b43ae7da962b85a20c64
parent3577a5b0ba689c14546546902057944b0287aae1 (diff)
downloadm2e-core-488950756d0040364f3f035ad9082e7b8b5cc9f4.zip
m2e-core-488950756d0040364f3f035ad9082e7b8b5cc9f4.tar.gz
m2e-core-488950756d0040364f3f035ad9082e7b8b5cc9f4.tar.xz
Generify getAdapter implementations.
Change-Id: Ib87da833039e5aa3d3d7ea01ab637e4100ecd4d0 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java6
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsolePageParticipant.java5
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java12
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexedArtifactFile.java7
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ArtifactKeyAdapterFactory.java13
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java153
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java15
-rw-r--r--org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/JavaUiElementsAdapterFactory.java14
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java6
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenFileEditorInput.java14
12 files changed, 121 insertions, 132 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java
index a20b3c7..6d2c6d3 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/OpenPomAction.java
@@ -374,8 +374,7 @@ public class OpenPomAction extends ActionDelegate implements IWorkbenchWindowAct
return null;
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
@@ -432,8 +431,7 @@ public class OpenPomAction extends ActionDelegate implements IWorkbenchWindowAct
return true;
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsolePageParticipant.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsolePageParticipant.java
index 0cb80ee..0b0d2f2 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsolePageParticipant.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/console/MavenConsolePageParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -69,8 +69,7 @@ public class MavenConsolePageParticipant implements IConsolePageParticipant {
public void deactivated() {
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java
index 2dcc4ee..25ff86f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -81,21 +81,21 @@ public class IndexedArtifactFileNode extends PlatformObject implements IMavenRep
private static final Class[] ADAPTERS = new Class[] {ArtifactKey.class, IndexedArtifactFile.class};
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if(adaptableObject instanceof IndexedArtifactFileNode) {
IndexedArtifactFileNode node = (IndexedArtifactFileNode) adaptableObject;
IndexedArtifactFile artifactFile = node.artifactFile;
if(ArtifactKey.class.equals(adapterType)) {
- return new ArtifactKey(artifactFile.group, artifactFile.artifact, artifactFile.version,
- artifactFile.classifier);
+ return adapterType.cast(new ArtifactKey(artifactFile.group, artifactFile.artifact, artifactFile.version,
+ artifactFile.classifier));
} else if(IndexedArtifactFile.class.equals(adapterType)) {
- return artifactFile;
+ return adapterType.cast(artifactFile);
}
}
return null;
}
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return ADAPTERS;
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
index 767aa15..db51dc1 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2014 Sonatype, Inc. and others.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -281,7 +281,7 @@ public class MavenPomSelectionComponent extends Composite {
ArtifactFilterManager filterManager = MavenPluginActivator.getDefault().getArifactFilterManager();
for(IndexedArtifactFile file : files) {
- ArtifactKey key = (ArtifactKey) file.getAdapter(ArtifactKey.class);
+ ArtifactKey key = file.getAdapter(ArtifactKey.class);
IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key);
if(!status.isOK()) {
setStatus(IStatus.ERROR, status.getMessage());
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexedArtifactFile.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexedArtifactFile.java
index 52cfc04..004a75c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexedArtifactFile.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexedArtifactFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -93,10 +93,9 @@ public class IndexedArtifactFile implements IAdaptable {
return new ArtifactKey(group, artifact, version, classifier);
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if(adapter == ArtifactKey.class) {
- return getArtifactKey();
+ return adapter.cast(getArtifactKey());
}
return null;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java
index 73e51d2..f945f3c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Sonatype, Inc.
+ * Copyright (c) 2010, 2018 Sonatype, Inc. 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
@@ -90,7 +90,7 @@ public class FilteredIndex implements IIndex {
IndexedArtifact result = new IndexedArtifact(original.getGroupId(), original.getArtifactId(),
original.getPackageName(), original.getClassname(), original.getPackaging());
for(IndexedArtifactFile file : original.getFiles()) {
- if(arifactFilterManager.filter(project, (ArtifactKey) file.getAdapter(ArtifactKey.class)).isOK()) {
+ if(arifactFilterManager.filter(project, file.getAdapter(ArtifactKey.class)).isOK()) {
result.addFile(file);
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ArtifactKeyAdapterFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ArtifactKeyAdapterFactory.java
index 1d29d8b..5263ea2 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ArtifactKeyAdapterFactory.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ArtifactKeyAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -28,12 +28,11 @@ import org.eclipse.m2e.core.project.IMavenProjectRegistry;
*
* @author Igor Fedorenko
*/
-@SuppressWarnings("rawtypes")
public class ArtifactKeyAdapterFactory implements IAdapterFactory {
- private static final Class[] ADAPTER_LIST = new Class[] {ArtifactKey.class,};
+ private static final Class<?>[] ADAPTER_LIST = new Class[] {ArtifactKey.class,};
- public Object getAdapter(Object adaptable, Class adapterType) {
+ public <T> T getAdapter(Object adaptable, Class<T> adapterType) {
if(!ArtifactKey.class.equals(adapterType)) {
return null;
}
@@ -43,14 +42,14 @@ public class ArtifactKeyAdapterFactory implements IAdapterFactory {
IProject project = (IProject) adaptable;
IMavenProjectFacade facade = projectManager.create(project, new NullProgressMonitor());
if(facade != null) {
- return facade.getArtifactKey();
+ return adapterType.cast(facade.getArtifactKey());
}
} else if(adaptable instanceof IFile) {
IFile file = (IFile) adaptable;
if(IMavenConstants.POM_FILE_NAME.equals(file.getName())) {
IMavenProjectFacade facade = projectManager.create(file, true, new NullProgressMonitor());
if(facade != null) {
- return facade.getArtifactKey();
+ return adapterType.cast(facade.getArtifactKey());
}
}
}
@@ -58,7 +57,7 @@ public class ArtifactKeyAdapterFactory implements IAdapterFactory {
return null;
}
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
// target type
return ADAPTER_LIST;
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
index 2a50d3c..622848b 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -158,7 +158,8 @@ public class DependenciesComposite extends Composite {
private List<DependenciesComposite.Dependency> manageddependencies;
- public DependenciesComposite(Composite composite, MavenPomEditorPage editorPage, int flags, MavenPomEditor pomEditor) {
+ public DependenciesComposite(Composite composite, MavenPomEditorPage editorPage, int flags,
+ MavenPomEditor pomEditor) {
super(composite, flags);
this.editorPage = editorPage;
this.pomEditor = pomEditor;
@@ -230,8 +231,8 @@ public class DependenciesComposite extends Composite {
Object selection = dependenciesEditor.getSelection().get(0);
if(selection instanceof Dependency) {
Dependency dependency = (Dependency) selection;
- EditDependencyDialog d = new EditDependencyDialog(getShell(), false, editorPage.getProject(), editorPage
- .getPomEditor().getMavenProject());
+ EditDependencyDialog d = new EditDependencyDialog(getShell(), false, editorPage.getProject(),
+ editorPage.getPomEditor().getMavenProject());
d.setDependency(toApacheDependency(dependency));
if(d.open() == Window.OK) {
try {
@@ -272,8 +273,8 @@ public class DependenciesComposite extends Composite {
dependenciesEditor.setAddButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final MavenRepositorySearchDialog addDepDialog = MavenRepositorySearchDialog.createSearchDependencyDialog(
- getShell(), Messages.DependenciesComposite_action_selectDependency, editorPage.getPomEditor()
- .getMavenProject(), editorPage.getProject(), false);
+ getShell(), Messages.DependenciesComposite_action_selectDependency,
+ editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), false);
if(addDepDialog.open() == Window.OK) {
final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
@@ -301,23 +302,23 @@ public class DependenciesComposite extends Composite {
ToolBarManager modulesToolBarManager = new ToolBarManager(SWT.FLAT);
- modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_sortAlphabetically,
- MavenEditorImages.SORT) {
- {
- setChecked(false);
- }
+ modulesToolBarManager
+ .add(new Action(Messages.DependenciesComposite_action_sortAlphabetically, MavenEditorImages.SORT) {
+ {
+ setChecked(false);
+ }
- @Override
- public int getStyle() {
- return AS_CHECK_BOX;
- }
+ @Override
+ public int getStyle() {
+ return AS_CHECK_BOX;
+ }
- @Override
- public void run() {
- dependenciesContentProvider.setShouldSort(isChecked());
- dependenciesEditor.getViewer().refresh();
- }
- });
+ @Override
+ public void run() {
+ dependenciesContentProvider.setShouldSort(isChecked());
+ dependenciesEditor.getViewer().refresh();
+ }
+ });
modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_showInheritedDependencies,
MavenEditorImages.SHOW_INHERITED_DEPENDENCIES) {
@@ -344,23 +345,23 @@ public class DependenciesComposite extends Composite {
}
});
- modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_showgroupid,
- MavenEditorImages.SHOW_GROUP) {
- {
- setChecked(false);
- dependenciesComparator.setSortByGroups(false);
- }
+ modulesToolBarManager
+ .add(new Action(Messages.DependenciesComposite_action_showgroupid, MavenEditorImages.SHOW_GROUP) {
+ {
+ setChecked(false);
+ dependenciesComparator.setSortByGroups(false);
+ }
- public int getStyle() {
- return AS_CHECK_BOX;
- }
+ public int getStyle() {
+ return AS_CHECK_BOX;
+ }
- public void run() {
- dependencyLabelProvider.setShowGroupId(isChecked());
- dependenciesComparator.setSortByGroups(isChecked());
- dependenciesEditor.getViewer().refresh();
- }
- });
+ public void run() {
+ dependencyLabelProvider.setShowGroupId(isChecked());
+ dependenciesComparator.setSortByGroups(isChecked());
+ dependenciesEditor.getViewer().refresh();
+ }
+ });
modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_filter, MavenEditorImages.FILTER) {
{
@@ -437,8 +438,8 @@ public class DependenciesComposite extends Composite {
dependencyManagementEditor.setPropertiesListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Dependency dependency = dependencyManagementEditor.getSelection().get(0);
- EditDependencyDialog d = new EditDependencyDialog(getShell(), true, editorPage.getProject(), editorPage
- .getPomEditor().getMavenProject());
+ EditDependencyDialog d = new EditDependencyDialog(getShell(), true, editorPage.getProject(),
+ editorPage.getPomEditor().getMavenProject());
d.setDependency(toApacheDependency(dependency));
if(d.open() == Window.OK) {
try {
@@ -469,8 +470,8 @@ public class DependenciesComposite extends Composite {
dependencyManagementEditor.setAddButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final MavenRepositorySearchDialog addDepDialog = MavenRepositorySearchDialog.createSearchDependencyDialog(
- getShell(), Messages.DependenciesComposite_action_selectDependency, editorPage.getPomEditor()
- .getMavenProject(), editorPage.getProject(), true);
+ getShell(), Messages.DependenciesComposite_action_selectDependency,
+ editorPage.getPomEditor().getMavenProject(), editorPage.getProject(), true);
if(addDepDialog.open() == Window.OK) {
final IndexedArtifactFile dep = (IndexedArtifactFile) addDepDialog.getFirstResult();
final String selectedScope = addDepDialog.getSelectedScope();
@@ -486,7 +487,8 @@ public class DependenciesComposite extends Composite {
setDependencyManagementInput();
List<Dependency> dlist = getManagedDependencies();
if(dlist.size() > 0) {
- dependencyManagementEditor.setSelection(Collections.<Dependency> singletonList(dlist.get(dlist.size() - 1)));
+ dependencyManagementEditor
+ .setSelection(Collections.<Dependency> singletonList(dlist.get(dlist.size() - 1)));
}
//refresh this one to update decorations..
dependenciesEditor.refresh();
@@ -498,42 +500,42 @@ public class DependenciesComposite extends Composite {
ToolBarManager modulesToolBarManager = new ToolBarManager(SWT.FLAT);
- modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_sortAlphabetically,
- MavenEditorImages.SORT) {
- {
- setChecked(false);
- dependencyManagementContentProvider.setShouldSort(false);
- }
+ modulesToolBarManager
+ .add(new Action(Messages.DependenciesComposite_action_sortAlphabetically, MavenEditorImages.SORT) {
+ {
+ setChecked(false);
+ dependencyManagementContentProvider.setShouldSort(false);
+ }
- @Override
- public int getStyle() {
- return AS_CHECK_BOX;
- }
+ @Override
+ public int getStyle() {
+ return AS_CHECK_BOX;
+ }
- @Override
- public void run() {
- dependencyManagementContentProvider.setShouldSort(isChecked());
- dependencyManagementEditor.getViewer().refresh();
- }
- });
+ @Override
+ public void run() {
+ dependencyManagementContentProvider.setShouldSort(isChecked());
+ dependencyManagementEditor.getViewer().refresh();
+ }
+ });
- modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_showgroupid,
- MavenEditorImages.SHOW_GROUP) {
- {
- setChecked(false);
- dependencyManagementComparator.setSortByGroups(false);
- }
+ modulesToolBarManager
+ .add(new Action(Messages.DependenciesComposite_action_showgroupid, MavenEditorImages.SHOW_GROUP) {
+ {
+ setChecked(false);
+ dependencyManagementComparator.setSortByGroups(false);
+ }
- public int getStyle() {
- return AS_CHECK_BOX;
- }
+ public int getStyle() {
+ return AS_CHECK_BOX;
+ }
- public void run() {
- dependencyManagementLabelProvider.setShowGroupId(isChecked());
- dependencyManagementComparator.setSortByGroups(isChecked());
- dependencyManagementEditor.getViewer().refresh();
- }
- });
+ public void run() {
+ dependencyManagementLabelProvider.setShowGroupId(isChecked());
+ dependencyManagementComparator.setSortByGroups(isChecked());
+ dependencyManagementEditor.getViewer().refresh();
+ }
+ });
modulesToolBarManager.add(new Action(Messages.DependenciesComposite_action_filter, MavenEditorImages.FILTER) {
{
@@ -939,7 +941,7 @@ public class DependenciesComposite extends Composite {
break;
}
}
- if (!manage.isDisposed()) {
+ if(!manage.isDisposed()) {
manage.setEnabled(!readOnly && hasNonManaged);
}
}
@@ -1010,10 +1012,9 @@ public class DependenciesComposite extends Composite {
public Dependency() {
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if(ArtifactKey.class.equals(adapter)) {
- return new ArtifactKey(groupId, artifactId, version, classifier);
+ return adapter.cast(new ArtifactKey(groupId, artifactId, version, classifier));
}
return null;
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index eb05117..86afabd 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -535,9 +535,9 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
return MavenPomEditor.this.getMavenProject();
}
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if(MavenProject.class.equals(adapter)) {
- return getMavenProject();
+ return adapter.cast(getMavenProject());
}
return null;
}
@@ -1048,17 +1048,16 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
}
@Override
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if(MavenProject.class.equals(adapter)) {
- return getMavenProject();
+ return adapter.cast(getMavenProject());
}
- Object result = super.getAdapter(adapter);
+ T result = super.getAdapter(adapter);
if(result != null && Display.getCurrent() == null) {
return result;
}
- return sourcePage.getAdapter(adapter);
+ return adapter.cast(sourcePage.getAdapter(adapter));
}
public IFile getPomFile() {
diff --git a/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/JavaUiElementsAdapterFactory.java b/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/JavaUiElementsAdapterFactory.java
index ad76ed4..5465b89 100644
--- a/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/JavaUiElementsAdapterFactory.java
+++ b/org.eclipse.m2e.jdt.ui/src/org/eclipse/m2e/jdt/ui/internal/JavaUiElementsAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -30,21 +30,21 @@ import org.eclipse.m2e.core.project.IMavenProjectRegistry;
* @author Eugene Kuleshov
* @author Miles Parker
*/
-@SuppressWarnings({"restriction", "rawtypes"})
+@SuppressWarnings({"restriction"})
public class JavaUiElementsAdapterFactory implements IAdapterFactory {
- private static final Class[] ADAPTER_LIST = new Class[] {ArtifactKey.class, IMavenProjectFacade.class};
+ private static final Class<?>[] ADAPTER_LIST = new Class[] {ArtifactKey.class, IMavenProjectFacade.class};
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return ADAPTER_LIST;
}
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if(adapterType == ArtifactKey.class) {
if(adaptableObject instanceof RequiredProjectWrapper) {
IMavenProjectFacade projectFacade = getProjectFacade(adaptableObject);
if(projectFacade != null) {
- return projectFacade.getArtifactKey();
+ return adapterType.cast(projectFacade.getArtifactKey());
}
}
@@ -54,7 +54,7 @@ public class JavaUiElementsAdapterFactory implements IAdapterFactory {
IProject project = container.getJavaProject().getProject();
IMavenProjectFacade projectFacade = getProjectFacade(project);
if(projectFacade != null) {
- return projectFacade;
+ return adapterType.cast(projectFacade);
}
}
}
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java
index 80209d0..d935ea2 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -286,8 +286,8 @@ public class ExecutePomAction implements ILaunchShortcut, IExecutableExtension {
for(ILaunchConfiguration configuration : launchConfigurations) {
try {
// substitute variables (may throw exceptions)
- String workDir = LaunchingUtils.substituteVar(configuration.getAttribute(MavenLaunchConstants.ATTR_POM_DIR,
- (String) null));
+ String workDir = LaunchingUtils
+ .substituteVar(configuration.getAttribute(MavenLaunchConstants.ATTR_POM_DIR, (String) null));
if(workDir == null) {
continue;
}
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenFileEditorInput.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenFileEditorInput.java
index 0bb3b97..e82d6db 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenFileEditorInput.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenFileEditorInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2018 Sonatype, Inc. 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
@@ -83,8 +83,7 @@ public class MavenFileEditorInput implements IStorageEditorInput {
return false;
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
};
@@ -104,14 +103,9 @@ public class MavenFileEditorInput implements IStorageEditorInput {
// };
}
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if(adapter == ILocationProvider.class) {
- return new ILocationProvider() {
- public IPath getPath(Object element) {
- return Path.fromOSString(fileName);
- }
- };
+ return adapter.cast((ILocationProvider) element -> Path.fromOSString(fileName));
}
return null;
}