Skip to main content
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 /org.eclipse.m2e.core
parent3577a5b0ba689c14546546902057944b0287aae1 (diff)
downloadm2e-core-488950756d0040364f3f035ad9082e7b8b5cc9f4.tar.gz
m2e-core-488950756d0040364f3f035ad9082e7b8b5cc9f4.tar.xz
m2e-core-488950756d0040364f3f035ad9082e7b8b5cc9f4.zip
Generify getAdapter implementations.
Change-Id: Ib87da833039e5aa3d3d7ea01ab637e4100ecd4d0 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-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
3 files changed, 11 insertions, 13 deletions
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 52cfc04e..004a75c6 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 73e51d2f..f945f3cc 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 1d29d8b8..5263ea23 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;
}

Back to the top