You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2017/11/05 23:01:38 UTC
[1/3] ant-ivyde git commit: Generics, JUnit 4
Repository: ant-ivyde
Updated Branches:
refs/heads/master ca1749189 -> f808b0b4f
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java
index 70fcbc5..935635a 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java
@@ -59,10 +59,9 @@ public class NewIvyDEContainerWizard extends Wizard {
JavaCore.setClasspathContainer(path, new IJavaProject[] {project},
new IClasspathContainer[] {ivycp}, null);
IClasspathEntry[] entries = project.getRawClasspath();
- List newEntries = new ArrayList(Arrays.asList(entries));
+ List<IClasspathEntry> newEntries = new ArrayList<>(Arrays.asList(entries));
newEntries.add(newEntry);
- entries = (IClasspathEntry[]) newEntries
- .toArray(new IClasspathEntry[newEntries.size()]);
+ entries = newEntries.toArray(new IClasspathEntry[newEntries.size()]);
project.setRawClasspath(entries, project.getOutputLocation(), null);
ivycp.launchResolve(false, null);
} catch (JavaModelException e) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java
index eaf1284..72ec5da 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java
@@ -20,7 +20,6 @@ package org.apache.ivyde.internal.eclipse.ui;
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivyde.eclipse.IvyDEException;
@@ -51,7 +50,7 @@ public class SettingsSetupEditor extends Composite {
public static final String TOOLTIP_PROPERTY_FILES = "Comma separated list of build property"
+ " files.\nExample: build.properties, override.properties";
- private final List listeners = new ArrayList();
+ private final List<SettingsEditorListener> listeners = new ArrayList<>();
private IvyDEException settingsError;
@@ -190,9 +189,8 @@ public class SettingsSetupEditor extends Composite {
void settingsUpdated() {
synchronized (listeners) {
SettingsSetup setup = getIvySettingsSetup();
- Iterator it = listeners.iterator();
- while (it.hasNext()) {
- ((SettingsEditorListener) it.next()).settingsEditorUpdated(setup);
+ for (SettingsEditorListener listener : listeners) {
+ listener.settingsEditorUpdated(setup);
}
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java
index 4db8f90..0f3a9c9 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java
@@ -266,11 +266,11 @@ public class IvyConsole extends MessageConsole implements MessageLogger {
}
// MessageLogger implementation
- private List problems = new ArrayList();
+ private final List<String> problems = new ArrayList<>();
- private List warns = new ArrayList();
+ private final List<String> warns = new ArrayList<>();
- private List errors = new ArrayList();
+ private final List<String> errors = new ArrayList<>();
private boolean showProgress = true;
@@ -308,7 +308,7 @@ public class IvyConsole extends MessageConsole implements MessageLogger {
getErrors().add(msg);
}
- public List getProblems() {
+ public List<String> getProblems() {
return problems;
}
@@ -323,11 +323,11 @@ public class IvyConsole extends MessageConsole implements MessageLogger {
errors.clear();
}
- public List getErrors() {
+ public List<String> getErrors() {
return errors;
}
- public List getWarns() {
+ public List<String> getWarns() {
return warns;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java
index 490b568..18dda87 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java
@@ -25,10 +25,13 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
+import java.util.Arrays;
+import java.util.List;
+
public class IvyConsoleFilterAction extends Action implements IMenuCreator {
- private static final String[] LOG_LEVEL_MESSAGES = {"error", "warning", "info", "verbose",
- "debug"};
+ private static final List<String> LOG_LEVEL_MESSAGES = Arrays.asList("error", "warning", "info", "verbose",
+ "debug");
private Menu fMenu;
@@ -58,25 +61,25 @@ public class IvyConsoleFilterAction extends Action implements IMenuCreator {
}
fMenu = new Menu(parent);
- for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) {
- final int logLevel = i;
- Action action = new Action(LOG_LEVEL_MESSAGES[i]) {
+ for (final String logLevelMessage : LOG_LEVEL_MESSAGES) {
+ final int logLevel = LOG_LEVEL_MESSAGES.indexOf(logLevelMessage);
+ Action action = new Action(logLevelMessage) {
public void run() {
console.setLogLevel(logLevel);
}
};
- action.setChecked(console.getLogLevel() == i);
+ action.setChecked(console.getLogLevel() == logLevel);
addActionToMenu(fMenu, action);
}
new Separator().fill(fMenu, -1);
- for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) {
- final int logLevel = i;
- Action action = new Action("IvyDE " + LOG_LEVEL_MESSAGES[i]) {
+ for (final String logLevelMessage : LOG_LEVEL_MESSAGES) {
+ final int logLevel = LOG_LEVEL_MESSAGES.indexOf(logLevelMessage);
+ Action action = new Action("IvyDE " + logLevelMessage) {
public void run() {
console.getIvyDEMessageLogger().setLogLevel(logLevel);
}
};
- action.setChecked(console.getIvyDEMessageLogger().getLogLevel() == i);
+ action.setChecked(console.getIvyDEMessageLogger().getLogLevel() == logLevel);
addActionToMenu(fMenu, action);
}
return fMenu;
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java
index 0d9258e..6c09361 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java
@@ -90,15 +90,15 @@ public class IvyDEMessageLogger implements MessageLogger {
// do nothing
}
- public List getProblems() {
+ public List<String> getProblems() {
return Collections.emptyList();
}
- public List getErrors() {
+ public List<String> getErrors() {
return Collections.emptyList();
}
- public List getWarns() {
+ public List<String> getWarns() {
return Collections.emptyList();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java
index 07fd208..ea60b66 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java
@@ -18,7 +18,6 @@
package org.apache.ivyde.internal.eclipse.ui.editors;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivyde.common.ivyfile.IvyModuleDescriptorModel;
@@ -66,9 +65,9 @@ public class IvyModuleDescriptorEditor extends FormEditor implements IResourceCh
private Browser browser;
- private List/* <IvyEditorPageDescriptor> */ivyEditorPageDescriptors = new ArrayList();
+ private final List<IvyEditorPageDescriptor> ivyEditorPageDescriptors = new ArrayList<>();
- private List/* <ModuleDescriptorExtensionDescriptor> */moduleDescriptorExtensionDescriptors = new ArrayList();
+ private final List<ModuleDescriptorExtensionDescriptor> moduleDescriptorExtensionDescriptors = new ArrayList<>();
/**
* Creates a multi-page editor example.
@@ -141,10 +140,7 @@ public class IvyModuleDescriptorEditor extends FormEditor implements IResourceCh
private IvyModuleDescriptorModel getIvyCompletionModel(IvyModelSettings ivyModelSettings) {
IvyModuleDescriptorModel ivyModuleDescriptorModel = new IvyModuleDescriptorModel(
ivyModelSettings);
- Iterator iterator = moduleDescriptorExtensionDescriptors.iterator();
- while (iterator.hasNext()) {
- ModuleDescriptorExtensionDescriptor descriptor = (ModuleDescriptorExtensionDescriptor) iterator
- .next();
+ for (ModuleDescriptorExtensionDescriptor descriptor : moduleDescriptorExtensionDescriptors) {
ModuleDescriptorExtension moduleDescriptorExtension = descriptor
.createModuleDescriptorExtension();
if (moduleDescriptorExtension != null) {
@@ -192,10 +188,7 @@ public class IvyModuleDescriptorEditor extends FormEditor implements IResourceCh
}
private void addIvyEditorPageExtensions() {
- Iterator iterator = ivyEditorPageDescriptors.iterator();
- while (iterator.hasNext()) {
- IvyEditorPageDescriptor ivyEditorPageDescriptor = (IvyEditorPageDescriptor) iterator
- .next();
+ for (IvyEditorPageDescriptor ivyEditorPageDescriptor : ivyEditorPageDescriptors) {
IvyEditorPage page = ivyEditorPageDescriptor.createPage();
try {
page.initialize(this);
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java
index 7543e90..f768f16 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java
@@ -17,13 +17,10 @@
*/
package org.apache.ivyde.internal.eclipse.ui.editors;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.ivyde.common.ivysettings.IvySettingsModel;
import org.apache.ivyde.common.model.IvyModel;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.apache.ivyde.internal.eclipse.ui.core.IvyFileEditorInput;
import org.apache.ivyde.internal.eclipse.ui.editors.xml.EclipseIvyModelSettings;
import org.apache.ivyde.internal.eclipse.ui.editors.xml.IvyContentAssistProcessor;
@@ -122,12 +119,9 @@ public class IvySettingsEditor extends FormEditor implements IResourceChangeList
public void doSave(IProgressMonitor monitor) {
xmlEditor.doSave(monitor);
IFile file = ((IvyFileEditorInput) getEditorInput()).getFile();
- List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper
- .getContainersFromIvySettings(file);
- Iterator/* <IvyClasspathContainer> */itContainers = containers.iterator();
- while (itContainers.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainers.next();
- ivycp.launchResolve(false, null);
+ for (IvyClasspathContainer container : IvyClasspathContainerHelper
+ .getContainersFromIvySettings(file)) {
+ container.launchResolve(false, null);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java
index f046480..e453ad9 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java
@@ -18,7 +18,6 @@
package org.apache.ivyde.internal.eclipse.ui.editors.xml;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.apache.ivyde.internal.eclipse.ui.preferences.PreferenceConstants;
@@ -30,16 +29,14 @@ import org.eclipse.swt.widgets.Display;
public class ColorManager {
- private Map fKeyTable = new HashMap();
+ private final Map<String, RGB> fKeyTable = new HashMap<>();
- private Map fDisplayTable = new HashMap();
+ private final Map<Display, Map<RGB, Color>> fDisplayTable = new HashMap<>();
public void dispose(Display display) {
- Map colorTable = (Map) fDisplayTable.get(display);
+ Map<RGB, Color> colorTable = fDisplayTable.get(display);
if (colorTable != null) {
- Iterator e = colorTable.values().iterator();
- while (e.hasNext()) {
- Color color = (Color) e.next();
+ for (Color color : colorTable.values()) {
if (color != null && !color.isDisposed()) {
color.dispose();
}
@@ -53,9 +50,9 @@ public class ColorManager {
}
final Display display = Display.getCurrent();
- Map colorTable = (Map) fDisplayTable.get(display);
+ Map<RGB, Color> colorTable = fDisplayTable.get(display);
if (colorTable == null) {
- colorTable = new HashMap();
+ colorTable = new HashMap<>();
fDisplayTable.put(display, colorTable);
display.disposeExec(new Runnable() {
public void run() {
@@ -64,7 +61,7 @@ public class ColorManager {
});
}
- Color color = (Color) colorTable.get(rgb);
+ Color color = colorTable.get(rgb);
if (color == null) {
color = new Color(Display.getCurrent(), rgb);
colorTable.put(rgb, color);
@@ -77,7 +74,7 @@ public class ColorManager {
if (key == null) {
return null;
}
- RGB rgb = (RGB) fKeyTable.get(key);
+ RGB rgb = fKeyTable.get(key);
return getColor(rgb);
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
index eec5f1e..1bb2fa8 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.ivy.Ivy;
import org.apache.ivyde.common.model.IvyModelSettings;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
@@ -40,8 +41,8 @@ public class EclipseIvyModelSettings implements IvyModelSettings {
this(IvyClasspathContainerHelper.getContainersFromIvyFile(ivyfile));
}
- private EclipseIvyModelSettings(List/* <IvyClasspathContainer> */containers) {
- this(containers.isEmpty() ? null : (IvyClasspathContainerImpl) containers.iterator().next());
+ private EclipseIvyModelSettings(List<IvyClasspathContainer> containers) {
+ this(containers.isEmpty() ? null : (IvyClasspathContainerImpl) containers.get(0));
}
private EclipseIvyModelSettings(IvyClasspathContainerImpl ivycp) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java
index 6f29f5d..eea7db0 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java
@@ -17,7 +17,6 @@
*/
package org.apache.ivyde.internal.eclipse.ui.menu;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -35,7 +34,7 @@ import org.eclipse.swt.widgets.Display;
public class CleanCacheAction extends Action {
- private final List/* <Cleanable> */cleanables;
+ private final List<Cleanable> cleanables;
private final String name;
@@ -89,13 +88,13 @@ public class CleanCacheAction extends Action {
}
}
- public CleanCacheAction(String name, List/* <Cleanable> */cleanables) {
+ public CleanCacheAction(String name, List<Cleanable> cleanables) {
this.name = name;
this.cleanables = cleanables;
}
public void run() {
- final boolean ok[] = new boolean[1];
+ final boolean[] ok = new boolean[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
ok[0] = MessageDialog.openConfirm(IvyPlugin.getActiveWorkbenchShell(), name,
@@ -104,9 +103,7 @@ public class CleanCacheAction extends Action {
}
});
if (ok[0]) {
- Iterator itCleanable = cleanables.iterator();
- while (itCleanable.hasNext()) {
- Cleanable cleanable = (Cleanable) itCleanable.next();
+ for (Cleanable cleanable : cleanables) {
cleanable.launchClean();
IvyDEMessage.info("Ivy cache cleaned: " + cleanable.getName());
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java
index e73a10d..e10d364 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -33,6 +32,7 @@ import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.RepositoryCacheManager;
import org.apache.ivy.core.cache.ResolutionCacheManager;
import org.apache.ivyde.eclipse.IvyNatureHelper;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
@@ -75,8 +75,7 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
}
protected IContributionItem[] getContributionItems() {
- ISelectionService selectionService = (ISelectionService) serviceLocator
- .getService(ISelectionService.class);
+ ISelectionService selectionService = (ISelectionService) serviceLocator.getService(ISelectionService.class);
if (selectionService == null) {
return new IContributionItem[0];
}
@@ -85,29 +84,26 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
return new IContributionItem[0];
}
- Map/* <IProject, Set<IvyClasspathContainer>> */containers = new HashMap();
+ Map<IProject, Set<IvyClasspathContainer>> containers = new HashMap<>();
- Map/* <IProject, Set<StandaloneRetrieveSetup>> */retrieveSetups = new HashMap();
+ Map<IProject, Set<StandaloneRetrieveSetup>> retrieveSetups = new HashMap<>();
// this give info about if the selection is only based of classpath containers
boolean onlyContainers = true;
int totalSelected = 0;
- Iterator it = ((IStructuredSelection) selection).iterator();
- while (it.hasNext()) {
+ for (Object element : ((IStructuredSelection) selection).toList()) {
totalSelected++;
- Object element = it.next();
boolean projectCollected = collectProject(containers, retrieveSetups, element);
if (projectCollected) {
onlyContainers = false;
} else {
- IWorkingSet workingSet = (IWorkingSet) IvyPlugin.adapt(element, IWorkingSet.class);
+ IWorkingSet workingSet = IvyPlugin.adapt(element, IWorkingSet.class);
if (workingSet != null) {
onlyContainers = false;
- IAdaptable[] elements = workingSet.getElements();
- for (int i = 0; i < elements.length; i++) {
- collectProject(containers, retrieveSetups, elements[i]);
+ for (IAdaptable elem : workingSet.getElements()) {
+ collectProject(containers, retrieveSetups, elem);
}
} else if (element instanceof ClassPathContainer) {
collectContainer(containers, (ClassPathContainer) element);
@@ -115,12 +111,12 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
}
}
- List/* <IContributionItem> */items;
+ List<MenuManager> items;
MenuManager menuManager;
if (onlyContainers) {
// we we have only containers, no need to have a root menu entry
menuManager = null;
- items = new ArrayList();
+ items = new ArrayList<>();
} else {
menuManager = new MenuManager("Ivy", IvyPlugin
.getImageDescriptor("icons/logo16x16.gif"), "org.apache.ivyde.eclipse.menu");
@@ -138,14 +134,9 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
// add retrieve
if (!retrieveSetups.isEmpty()) {
boolean oneProject = retrieveSetups.size() == 1 && totalSelected == 1;
- Iterator itProject = retrieveSetups.entrySet().iterator();
- while (itProject.hasNext()) {
- Entry entry = (Entry) itProject.next();
- IProject project = (IProject) entry.getKey();
- Iterator itSetup = ((Set) entry.getValue()).iterator();
- while (itSetup.hasNext()) {
- StandaloneRetrieveSetup retrieveSetup = (StandaloneRetrieveSetup) itSetup
- .next();
+ for (Entry<IProject, Set<StandaloneRetrieveSetup>> entry : retrieveSetups.entrySet()) {
+ IProject project = entry.getKey();
+ for (StandaloneRetrieveSetup retrieveSetup : entry.getValue()) {
RetrieveAction action = new RetrieveAction(retrieveSetup);
action.setText("Retrieve '" + retrieveSetup.getName()
+ (oneProject ? "'" : "' of " + project.getName()));
@@ -164,10 +155,10 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
// add clean cache
if (!containers.isEmpty()) {
if (totalSelected == 1 && containers.size() == 1
- && ((Set) containers.values().iterator().next()).size() == 1) {
+ && containers.values().iterator().next().size() == 1) {
// only one container
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) ((Set) containers.values()
- .iterator().next()).iterator().next();
+ IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) containers.values()
+ .iterator().next().iterator().next();
Ivy ivy = ivycp.getState().getCachedIvy();
if (ivy != null) {
addCleanableForSingleContainer(menuManager, items, ivy);
@@ -187,28 +178,28 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
// add remove ivy nature
addCommand(menuManager, items, RemoveIvyNatureHandler.COMMAND_ID);
- return (IContributionItem[]) items.toArray(new IContributionItem[items.size()]);
+ return items.toArray(new IContributionItem[items.size()]);
}
- private void addCommand(MenuManager menuManager, List/* <IContributionItem> */items,
+ private void addCommand(MenuManager menuManager, List<MenuManager> items,
String commandId) {
CommandContributionItemParameter parm = new CommandContributionItemParameter(
serviceLocator, null, commandId, CommandContributionItem.STYLE_PUSH);
fillMenu(menuManager, items, new CommandContributionItem(parm));
}
- private void fillMenu(MenuManager menuManager, List/* <IContributionItem> */items,
- IContributionItem item) {
+ private void fillMenu(MenuManager menuManager, List<MenuManager> items,
+ IContributionItem commandContributionItem) {
if (menuManager != null) {
- menuManager.add(item);
+ menuManager.add(commandContributionItem);
} else {
- items.add(item);
+ items.add((MenuManager) commandContributionItem);
}
}
- private boolean collectProject(Map/* <IProject, Set<IvyClasspathContainer>> */containers,
- Map/* <IProject, Set<StandaloneRetrieveSetup>> */retrieveSetups, Object element) {
- IProject project = (IProject) IvyPlugin.adapt(element, IProject.class);
+ private boolean collectProject(Map<IProject, Set<IvyClasspathContainer>> containers,
+ Map<IProject, Set<StandaloneRetrieveSetup>> retrieveSetups, Object element) {
+ IProject project = IvyPlugin.adapt(element, IProject.class);
if (project != null && project.isOpen() && IvyNatureHelper.hasNature(project)) {
doCollectProject(containers, retrieveSetups, project);
return true;
@@ -216,14 +207,14 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
return false;
}
- private void doCollectProject(Map/* <IProject, Set<IvyClasspathContainer>> */containers,
- Map/* <IProject, Set<StandaloneRetrieveSetup>> */retrieveSetups, IProject project) {
- List ivycps = IvyClasspathContainerHelper.getContainers(project);
- if (!ivycps.isEmpty()) {
- containers.put(project, new HashSet(ivycps));
+ private void doCollectProject(Map<IProject, Set<IvyClasspathContainer>> containers,
+ Map<IProject, Set<StandaloneRetrieveSetup>> retrieveSetups, IProject project) {
+ List<IvyClasspathContainer> containerList = IvyClasspathContainerHelper.getContainers(project);
+ if (!containerList.isEmpty()) {
+ containers.put(project, new HashSet<>(containerList));
}
RetrieveSetupManager manager = IvyPlugin.getDefault().getRetrieveSetupManager();
- List setupList;
+ List<StandaloneRetrieveSetup> setupList;
try {
setupList = manager.getSetup(project);
} catch (IOException e) {
@@ -232,11 +223,11 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
return;
}
if (!setupList.isEmpty()) {
- retrieveSetups.put(project, new HashSet(setupList));
+ retrieveSetups.put(project, new HashSet<>(setupList));
}
}
- private boolean collectContainer(Map/* <IProject, Set<IvyClasspathContainer>> */containers,
+ private boolean collectContainer(Map<IProject, Set<IvyClasspathContainer>> containers,
ClassPathContainer element) {
IvyClasspathContainerImpl ivycp = IvyClasspathUtil.jdt2IvyCPC(element);
if (ivycp == null) {
@@ -246,25 +237,25 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
return true;
}
- private void doCollectContainer(Map/* <IProject, Set<IvyClasspathContainer>> */containers,
+ private void doCollectContainer(Map<IProject, Set<IvyClasspathContainer>> containers,
IvyClasspathContainerImpl ivycp) {
IJavaProject javaProject = ivycp.getConf().getJavaProject();
if (javaProject == null) {
return;
}
- Set/* <IvyClasspathContainer> */cplist = (Set) containers.get(javaProject.getProject());
- if (cplist == null) {
- cplist = new HashSet();
- containers.put(javaProject.getProject(), cplist);
+ Set<IvyClasspathContainer> containerSet = containers.get(javaProject.getProject());
+ if (containerSet == null) {
+ containerSet = new HashSet<>();
+ containers.put(javaProject.getProject(), containerSet);
}
- cplist.add(ivycp);
+ containerSet.add(ivycp);
}
private void addCleanableForSingleContainer(MenuManager menuManager,
- List/* <IContributionItem> */items, Ivy ivy) {
- List/* <Cleanable> */allCleanables = new ArrayList();
- List/* <Cleanable> */repositoryCleanables = new ArrayList();
- List/* <Cleanable> */resolutionCleanables = new ArrayList();
+ List<MenuManager> items, Ivy ivy) {
+ List<Cleanable> allCleanables = new ArrayList<>();
+ List<Cleanable> repositoryCleanables = new ArrayList<>();
+ List<Cleanable> resolutionCleanables = new ArrayList<>();
addResolutionCleanable(allCleanables, ivy);
addResolutionCleanable(resolutionCleanables, ivy);
@@ -275,29 +266,21 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
addCleanable(menuManager, items, "Clean all caches", allCleanables);
addCleanable(menuManager, items, "Clean the resolution cache", resolutionCleanables);
addCleanable(menuManager, items, "Clean every repository cache", repositoryCleanables);
- Iterator itCleanable = resolutionCleanables.iterator();
- while (itCleanable.hasNext()) {
- Cleanable cleanable = (Cleanable) itCleanable.next();
+ for (Cleanable cleanable : resolutionCleanables) {
addCleanable(menuManager, items, "Clean the cache '" + cleanable.getName() + "'",
- Collections.singletonList(cleanable));
+ Collections.singletonList(cleanable));
}
}
private void addCleanableForManyContainers(MenuManager menuManager,
- List/* <IContributionItem> */items, Collection/*
- * <Set<IvyClasspathContainer >>
- */containerSets) {
- List/* <Cleanable> */allCleanables = new ArrayList();
- List/* <Cleanable> */repositoryCleanables = new ArrayList();
- List/* <Cleanable> */resolutionCleanables = new ArrayList();
-
- Iterator itSet = containerSets.iterator();
- while (itSet.hasNext()) {
- Set set = (Set) itSet.next();
- Iterator itContainer = set.iterator();
- while (itContainer.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainer.next();
- Ivy ivy = ivycp.getState().getCachedIvy();
+ List<MenuManager> items, Collection<Set<IvyClasspathContainer>> containerSets) {
+ List<Cleanable> allCleanables = new ArrayList<>();
+ List<Cleanable> repositoryCleanables = new ArrayList<>();
+ List<Cleanable> resolutionCleanables = new ArrayList<>();
+
+ for (Set<IvyClasspathContainer> containerSet : containerSets) {
+ for (IvyClasspathContainer container : containerSet) {
+ Ivy ivy = ((IvyClasspathContainerImpl) container).getState().getCachedIvy();
if (ivy != null) {
addResolutionCleanable(allCleanables, ivy);
addResolutionCleanable(resolutionCleanables, ivy);
@@ -312,20 +295,19 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements
addCleanable(menuManager, items, "Clean every repository cache", repositoryCleanables);
}
- private void addResolutionCleanable(List/* <Cleanable> */cleanables, Ivy ivy) {
+ private void addResolutionCleanable(List<Cleanable> cleanables, Ivy ivy) {
ResolutionCacheManager manager = ivy.getSettings().getResolutionCacheManager();
cleanables.add(new ResolutionCacheCleanable(manager));
}
- private void addRepositoryCleanable(List/* <Cleanable> */cleanables, Ivy ivy) {
- RepositoryCacheManager[] managers = ivy.getSettings().getRepositoryCacheManagers();
- for (int i = 0; i < managers.length; i++) {
- cleanables.add(new RepositoryCacheCleanable(managers[i]));
+ private void addRepositoryCleanable(List<Cleanable> cleanables, Ivy ivy) {
+ for (RepositoryCacheManager manager : ivy.getSettings().getRepositoryCacheManagers()) {
+ cleanables.add(new RepositoryCacheCleanable(manager));
}
}
- public void addCleanable(MenuManager menuManager, List/* <IContributionItem> */items,
- String name, List/* <Cleanable> */cleanables) {
+ public void addCleanable(MenuManager menuManager, List<MenuManager> items,
+ String name, List<Cleanable> cleanables) {
CleanCacheAction action = new CleanCacheAction(name, cleanables);
action.setText(name);
fillMenu(menuManager, items, new ActionContributionItem(action));
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java
index f1ff591..372b095 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java
@@ -41,7 +41,7 @@ public class RetrieveAction extends Action {
public void run() {
RetrieveSetup retrieveSetup = setup.getRetrieveSetup();
- List confs = IvyClasspathUtil.split(retrieveSetup.getRetrieveConfs());
+ List<String> confs = IvyClasspathUtil.split(retrieveSetup.getRetrieveConfs());
IvyResolver resolver = new IvyResolver(setup.getIvyXmlPath(), confs, setup.getProject());
resolver.setRetrievePattern(retrieveSetup.getRetrievePattern());
resolver.setRetrieveSync(retrieveSetup.isRetrieveSync());
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java
index 955bc7b..a8e9d99 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java
@@ -18,7 +18,6 @@
package org.apache.ivyde.internal.eclipse.ui.preferences;
import java.io.IOException;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
@@ -69,7 +68,7 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
- final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class);
+ final IProject project = IvyPlugin.adapt(getElement(), IProject.class);
Label label = new Label(composite, SWT.NONE);
label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 0));
@@ -104,12 +103,13 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP
newButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
newButton.setText("New...");
newButton.addSelectionListener(new SelectionAdapter() {
+ @SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent e) {
StandaloneRetrieveSetup setup = new StandaloneRetrieveSetup();
EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(
getShell(), project, setup);
if (editDialog.open() == Window.OK) {
- List list = ((List) table.getInput());
+ List<Object> list = (List<Object>) table.getInput();
list.add(editDialog.getStandaloneRetrieveSetup());
table.refresh();
}
@@ -129,12 +129,10 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP
removeButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
removeButton.setText("Remove");
removeButton.addSelectionListener(new SelectionAdapter() {
+ @SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent e) {
- List list = ((List) table.getInput());
- Iterator it = ((IStructuredSelection) table.getSelection()).iterator();
- while (it.hasNext()) {
- list.remove(it.next());
- }
+ List<Object> list = (List<Object>) table.getInput();
+ list.removeAll(((IStructuredSelection) table.getSelection()).toList());
table.refresh();
}
});
@@ -152,7 +150,7 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP
}
});
- List retrieveSetups;
+ List<StandaloneRetrieveSetup> retrieveSetups;
try {
retrieveSetups = retrieveSetupManager.getSetup(project);
} catch (IOException e) {
@@ -163,12 +161,13 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP
return composite;
}
+ @SuppressWarnings("unchecked")
private void openEdit(IStructuredSelection selection, IProject project) {
StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) selection.getFirstElement();
EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(getShell(),
project, setup);
if (editDialog.open() == Window.OK) {
- List list = ((List) table.getInput());
+ List<Object> list = (List<Object>) table.getInput();
list.set(list.indexOf(setup), editDialog.getStandaloneRetrieveSetup());
table.refresh();
}
@@ -200,10 +199,11 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP
}
+ @SuppressWarnings("unchecked")
public boolean performOk() {
- final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class);
+ final IProject project = IvyPlugin.adapt(getElement(), IProject.class);
- List/* <StandaloneRetrieveSetup> */retrieveSetups = (List) table.getInput();
+ List<StandaloneRetrieveSetup> retrieveSetups = (List<StandaloneRetrieveSetup>) table.getInput();
try {
retrieveSetupManager.save(project, retrieveSetups);
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java
index 62e81ba..aa5503d 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java
@@ -131,14 +131,13 @@ public final class PreferenceConstants {
public static final String ERROR_POPUP = "error.popup";
- public static final Set/*<String>*/ ALL = new HashSet();
+ public static final Set<String> ALL = new HashSet<>();
static {
- Field[] fields = PreferenceConstants.class.getFields();
- for (int i = 0; i < fields.length; i++) {
- if (Modifier.isStatic(fields[i].getModifiers())) {
+ for (Field field : PreferenceConstants.class.getFields()) {
+ if (Modifier.isStatic(field.getModifiers())) {
try {
- ALL.add(fields[i].get(null));
+ ALL.add((String) field.get(null));
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException(e);
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java
index d255d14..c38b350 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java
@@ -55,11 +55,11 @@ public class ReportView extends ViewPart implements ISelectionListener {
public void selectionChanged(IWorkbenchPart part, ISelection sel) {
if (sel instanceof IStructuredSelection) {
- IvyClasspathContainer ivycp = IvyClasspathContainerHelper
+ IvyClasspathContainer container = IvyClasspathContainerHelper
.getContainer((IStructuredSelection) sel);
- if (ivycp != null) {
+ if (container != null) {
browser.setText("<html></html>");
- URL report = ivycp.getReportUrl();
+ URL report = container.getReportUrl();
if (report == null || !browser.setUrl(report.toExternalForm())) {
browser.setText("<html></html>");
IvyDEMessage.warn("Impossible to set report view url to " + report.toExternalForm());
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java
index 2c815e7..d992863 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java
@@ -17,8 +17,8 @@
*/
package org.apache.ivyde.internal.eclipse.ui.views;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.apache.ivyde.internal.eclipse.handlers.OpenIvyFileHandler;
import org.apache.ivyde.internal.eclipse.revdepexplorer.IvyUtil;
import org.apache.ivyde.internal.eclipse.revdepexplorer.MultiRevDependencyDescriptor;
@@ -156,8 +156,8 @@ public class ReverseDependencyExplorerView extends ViewPart {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Object element = selection.getFirstElement();
if (element instanceof CPDependencyDescriptor) {
- IvyClasspathContainerImpl cp = ((CPDependencyDescriptor) element).container;
- OpenIvyFileHandler.open(cp);
+ IvyClasspathContainer container = ((CPDependencyDescriptor) element).container;
+ OpenIvyFileHandler.open(container);
}
}
});
@@ -326,7 +326,7 @@ public class ReverseDependencyExplorerView extends ViewPart {
public Object[] getChildren(Object parent) {
if (parent instanceof MultiRevDependencyDescriptor) {
MultiRevDependencyDescriptor mrdd = (MultiRevDependencyDescriptor) parent;
- IvyClasspathContainerImpl[] containers = mrdd.getIvyClasspathContainers();
+ IvyClasspathContainer[] containers = mrdd.getIvyClasspathContainers();
Object[] wrappedProjects = new Object[containers.length];
for (int i = 0; i < containers.length; i++) {
@@ -357,11 +357,11 @@ public class ReverseDependencyExplorerView extends ViewPart {
}
class CPDependencyDescriptor {
- private final IvyClasspathContainerImpl container;
+ private final IvyClasspathContainer container;
private final MultiRevDependencyDescriptor multiRevisionDescriptor;
- public CPDependencyDescriptor(IvyClasspathContainerImpl container,
+ public CPDependencyDescriptor(IvyClasspathContainer container,
MultiRevDependencyDescriptor multiRevisionDescriptor) {
this.container = container;
this.multiRevisionDescriptor = multiRevisionDescriptor;
@@ -374,7 +374,7 @@ public class ReverseDependencyExplorerView extends ViewPart {
return multiRevisionDescriptor.getRevisions(container);
}
- public IvyClasspathContainerImpl getIvyClasspathContainer() {
+ public IvyClasspathContainer getIvyClasspathContainer() {
return container;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java
index 1604e65..efc9415 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java
@@ -31,10 +31,10 @@ import org.apache.ivy.plugins.version.VersionMatcher;
*/
public class IvyDEStrategy extends ComparatorLatestStrategy {
- final class MridComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- String rev1 = ((ModuleRevisionId) o1).getRevision();
- String rev2 = ((ModuleRevisionId) o2).getRevision();
+ final class MridComparator implements Comparator<ModuleRevisionId> {
+ public int compare(ModuleRevisionId o1, ModuleRevisionId o2) {
+ String rev1 = o1.getRevision();
+ String rev2 = o2.getRevision();
boolean latestRev1 = rev1.startsWith("latest") || rev1.startsWith("working");
boolean latestRev2 = rev2.startsWith("latest") || rev2.startsWith("working");
@@ -89,10 +89,10 @@ public class IvyDEStrategy extends ComparatorLatestStrategy {
* inspired by PHP version_compare one, unless a dynamic revision is given, in which case the
* version matcher is used to perform the comparison.
*/
- final class ArtifactInfoComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- String rev1 = ((ArtifactInfo) o1).getRevision();
- String rev2 = ((ArtifactInfo) o2).getRevision();
+ final class ArtifactInfoComparator implements Comparator<ArtifactInfo> {
+ public int compare(ArtifactInfo o1, ArtifactInfo o2) {
+ String rev1 = o1.getRevision();
+ String rev2 = o2.getRevision();
/*
* The revisions can still be not resolved, so we use the current version matcher to
@@ -117,9 +117,9 @@ public class IvyDEStrategy extends ComparatorLatestStrategy {
}
}
- private final Comparator mridComparator = new MridComparator();
+ private final Comparator<ModuleRevisionId> mridComparator = new MridComparator();
- private final Comparator artifactInfoComparator = new ArtifactInfoComparator();
+ private final Comparator<ArtifactInfo> artifactInfoComparator = new ArtifactInfoComparator();
public IvyDEStrategy() {
setComparator(artifactInfoComparator);
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java
index 1f89e3c..9ff8674 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java
@@ -203,8 +203,7 @@ public class WorkspaceResolver extends AbstractResolver {
continue;
}
for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(p)) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container;
- ModuleDescriptor md = ivycp.getState().getCachedModuleDescriptor();
+ ModuleDescriptor md = ((IvyClasspathContainerImpl) container).getState().getCachedModuleDescriptor();
if (md == null) {
continue;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
index bf99d1a..bc0f910 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java
@@ -19,16 +19,14 @@ package org.apache.ivyde.internal.eclipse.workspaceresolver;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import org.apache.ivyde.eclipse.IvyNatureHelper;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -92,7 +90,7 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
private void projectClosed(final IProject project) {
// Check if one of Ivy projects is being removed
- List containers = IvyClasspathContainerHelper.getContainers(project);
+ List<IvyClasspathContainer> containers = IvyClasspathContainerHelper.getContainers(project);
if (containers.isEmpty()) {
return;
}
@@ -100,12 +98,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
// Found an Ivy container in this project -- notify dependent projects
// to perform fresh resolve
- List affectedContainers = getAffectedContainers(project.getFullPath());
-
- Iterator it = affectedContainers.iterator();
- while (it.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next();
- ivycp.launchResolve(false, null);
+ for (IvyClasspathContainer affectedContainer : getAffectedContainers(project.getFullPath())) {
+ affectedContainer.launchResolve(false, null);
}
}
@@ -117,14 +111,12 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
return;
}
- final Collection projects = new LinkedHashSet();
- IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED);
- for (int i = 0; i < projDeltas.length; ++i) {
- IResourceDelta projDelta = projDeltas[i];
- if ((projDelta.getFlags() & IResourceDelta.OPEN) == 0) {
+ final Collection<IResource> projects = new LinkedHashSet<>();
+ for (IResourceDelta projectDelta : delta.getAffectedChildren(IResourceDelta.CHANGED)) {
+ if ((projectDelta.getFlags() & IResourceDelta.OPEN) == 0) {
continue;
}
- IResource resource = projDeltas[i].getResource();
+ IResource resource = projectDelta.getResource();
if (!(resource instanceof IProject)) {
continue;
}
@@ -139,12 +131,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
// Let's try to be nice and use the workspace method to schedule resolves in
// dependent projects after the open operation has finished.
- List allContainers = getAllContainersExcludingProjects(projects);
-
- Iterator it = allContainers.iterator();
- while (it.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next();
- ivycp.launchResolve(false, null);
+ for (IvyClasspathContainer container : getAllContainersExcludingProjects(projects)) {
+ container.launchResolve(false, null);
}
}
@@ -154,8 +142,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
* @param projectPath IPath
* @return List<IvyClasspathContainer>
*/
- private List getAffectedContainers(IPath projectPath) {
- List/* <IvyClasspathContainer> */allContainers = new ArrayList();
+ private List<IvyClasspathContainer> getAffectedContainers(IPath projectPath) {
+ List<IvyClasspathContainer> allContainers = new ArrayList<>();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IJavaProject[] projects;
@@ -167,16 +155,10 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
return allContainers;
}
- for (int i = 0; i < projects.length; i++) {
- IJavaProject javaProject = projects[i];
- List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper
- .getContainers(javaProject);
- Iterator/* <IvyClasspathContainer> */itContainer = containers.iterator();
- while (itContainer.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainer.next();
- IClasspathEntry[] containerEntries = ivycp.getClasspathEntries();
- for (int j = 0; j < containerEntries.length; j++) {
- IClasspathEntry containerEntry = containerEntries[j];
+ for (IJavaProject javaProject : projects) {
+ for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(javaProject)) {
+ IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container;
+ for (IClasspathEntry containerEntry : ivycp.getClasspathEntries()) {
if (containerEntry == null
|| containerEntry.getEntryKind() != IClasspathEntry.CPE_PROJECT
|| !containerEntry.getPath().equals(projectPath)) {
@@ -191,8 +173,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener
return allContainers;
}
- private List getAllContainersExcludingProjects(Collection openedProjects) {
- List/* <IvyClasspathContainer> */allContainers = new ArrayList();
+ private List<IvyClasspathContainer> getAllContainersExcludingProjects(Collection<IResource> openedProjects) {
+ List<IvyClasspathContainer> allContainers = new ArrayList<>();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IJavaProject[] projects;
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java
index 58d5a5d..6aaae12 100644
--- a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java
+++ b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java
@@ -20,16 +20,18 @@ package org.apache.ivyde.common.ivyfile;
import java.io.File;
import java.io.IOException;
-import junit.framework.TestCase;
-
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.util.FileUtil;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
-public class IvyFileUpdaterTest extends TestCase {
- private IvyFileUpdater updater = new IvyFileUpdater();
+public class IvyFileUpdaterTest {
+ private final IvyFileUpdater updater = new IvyFileUpdater();
- public void testAddDependency() throws Exception {
+ @Test
+ public void testAddDependency() throws IOException {
testAddDependency("addDependency1");
testAddDependency("addDependency2");
testAddDependency("addDependency3");
@@ -50,8 +52,8 @@ public class IvyFileUpdaterTest extends TestCase {
FileUtil.readEntirely(IvyFileUpdaterTest.class.getResourceAsStream(test + "/expected.xml")),
FileUtil.readEntirely(dest));
}
-
- public void testRemoveDependency() throws Exception {
+ @Test
+ public void testRemoveDependency() throws IOException {
testRemoveDependency("removeDependency1");
testRemoveDependency("removeDependency2");
testRemoveDependency("removeDependency3");
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java
index ab8446d..a0a6054 100644
--- a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java
+++ b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java
@@ -17,25 +17,27 @@
*/
package org.apache.ivyde.common.model;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.ivyde.common.ivyfile.IvyModuleDescriptorFile;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
-public class IvyFileUtilTest extends TestCase {
- String hibContentStr;
+public class IvyFileUtilTest {
+ private static String hibContentStr;
- public IvyFileUtilTest(String name) {
- super(name);
- byte content[];
- try {
- RandomAccessFile accessFile = new RandomAccessFile(getClass().getResource(
- "/ivy-hibernate.xml").getFile(), "r");
- content = new byte[(int) accessFile.length()];
+ @BeforeClass
+ public static void setUp() throws IOException {
+ try (RandomAccessFile accessFile = new RandomAccessFile(IvyFileUtilTest.class.getResource(
+ "/ivy-hibernate.xml").getFile(), "r")) {
+ byte[] content = new byte[(int) accessFile.length()];
accessFile.read(content);
hibContentStr = new String(content);
} catch (IOException e) {
@@ -44,25 +46,28 @@ public class IvyFileUtilTest extends TestCase {
}
}
+ @Test
public void testInTag() {
IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", hibContentStr);
- boolean b = ivyFile.inTag(200);
+ boolean b = ivyFile.inTag(1000);
assertEquals(b, true);
}
+ @Test
public void testGetTagName() {
IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", hibContentStr);
- String tag = ivyFile.getTagName(200);
+ String tag = ivyFile.getTagName(1000);
assertEquals("info", tag);
- tag = ivyFile.getTagName(864);
+ tag = ivyFile.getTagName(1600);
assertEquals("description", tag);
// tag = IvyFileUtil.getTagName(1000);
}
+ @Test
public void testGetAllAttsValues() {
String test = "<test att1=\"value1\" att2 =\"value 2 \" att3 =\" value3 \" att4 = \" 4 \"";
IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", test);
- Map all = ivyFile.getAllAttsValues(1);
+ Map<String, String> all = ivyFile.getAllAttsValues(1);
assertNotNull(all);
assertEquals(4, all.size());
assertEquals("value1", all.get("att1"));
@@ -71,12 +76,13 @@ public class IvyFileUtilTest extends TestCase {
assertEquals(" 4 ", all.get("att4"));
}
+ @Test
public void testGetAttributeName() {
String test = "<test nospace=\"\" 1Space =\"\" 2Space = \"\" lotofSpace = \" \"";
IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", test);
String name = ivyFile.getAttributeName(15);
assertEquals("nospace", name);
- name = ivyFile.getAttributeName(28);
+ name = ivyFile.getAttributeName(26);
assertEquals("1Space", name);
name = ivyFile.getAttributeName(39);
assertEquals("2Space", name);
@@ -84,26 +90,33 @@ public class IvyFileUtilTest extends TestCase {
assertEquals("lotofSpace", name);
}
+ @Test
public void testGetParentTagName() {
IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", hibContentStr);
- String tag = ivyFile.getParentTagName(200);
+ String tag = ivyFile.getParentTagName(1000);
assertEquals("ivy-module", tag);
- tag = ivyFile.getParentTagName(2000);
+ tag = ivyFile.getParentTagName(2600);
assertEquals("configurations", tag);
- tag = ivyFile.getParentTagName(1981);
+ tag = ivyFile.getParentTagName(2493);
assertEquals("configurations", tag);
- tag = ivyFile.getParentTagName(1000);
+ tag = ivyFile.getParentTagName(1700);
assertEquals("description", tag);
- tag = ivyFile.getParentTagName(5015);
+ tag = ivyFile.getParentTagName(5585);
assertNull(tag);
}
+ @Test
+ @Ignore
public void testReadyForValue() {
}
+ @Test
+ @Ignore
public void testGetStringIndex() {
}
+ @Test
+ @Ignore
public void testGetQualifier() {
}
}
[2/3] ant-ivyde git commit: Generics, JUnit 4
Posted by gi...@apache.org.
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerSerializer.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
index 45bbd17..20ab071 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
@@ -38,6 +37,7 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.IvyDEMessage;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
@@ -101,7 +101,7 @@ public class IvyClasspathContainerSerializer {
}
public void save(IJavaProject project) {
- List/* <IvyClasspathContainer> */ivycps = IvyClasspathContainerHelper
+ List<IvyClasspathContainer> containers = IvyClasspathContainerHelper
.getContainers(project);
try {
File file = new File(containersStateDir, project.getProject().getName() + ".xml");
@@ -109,7 +109,7 @@ public class IvyClasspathContainerSerializer {
+ project.getProject().getName() + " into " + file);
FileOutputStream out = new FileOutputStream(file);
try {
- write(out, ivycps);
+ write(out, containers);
} finally {
try {
out.close();
@@ -123,7 +123,7 @@ public class IvyClasspathContainerSerializer {
}
}
- public Map/* <IPath, IvyClasspathContainer> */read(IJavaProject project) {
+ public Map<IPath, IvyClasspathContainer> read(IJavaProject project) {
File file = new File(containersStateDir, project.getProject().getName() + ".xml");
IvyDEMessage.verbose("Loading the state of the containers of the project "
+ project.getProject().getName() + " from " + file);
@@ -150,7 +150,7 @@ public class IvyClasspathContainerSerializer {
}
}
- private void write(OutputStream out, List/* <IvyClasspathContainer> */containers)
+ private void write(OutputStream out, List<IvyClasspathContainer> containers)
throws IOException {
try {
StreamResult result = new StreamResult(out);
@@ -161,9 +161,8 @@ public class IvyClasspathContainerSerializer {
Node root = document.createElement(ROOT);
document.appendChild(root);
- Iterator it = containers.iterator();
- while (it.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next();
+ for (IvyClasspathContainer container : containers) {
+ IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container;
Node node = document.createElement(IVYCP);
root.appendChild(node);
@@ -281,7 +280,7 @@ public class IvyClasspathContainerSerializer {
}
}
- public Map/* <IPath, IvyClasspathContainer> */read(InputStream in) throws IOException,
+ public Map<IPath, IvyClasspathContainer> read(InputStream in) throws IOException,
SAXException {
try {
InputSource source = new InputSource(in);
@@ -292,7 +291,7 @@ public class IvyClasspathContainerSerializer {
NodeList elements = document.getElementsByTagName(IVYCP);
- Map/* <IPath, IvyClasspathContainer> */ivycps = new HashMap();
+ Map<IPath, IvyClasspathContainer> containers = new HashMap<>();
int count = elements.getLength();
for (int i = 0; i != count; i++) {
@@ -320,9 +319,9 @@ public class IvyClasspathContainerSerializer {
IvyClasspathContainerImpl ivycp = new IvyClasspathContainerImpl(project, path, cpEntries,
cpAttributes);
- ivycps.put(path, ivycp);
+ containers.put(path, ivycp);
}
- return ivycps;
+ return containers;
} catch (ParserConfigurationException e) {
throw new RuntimeException(e.getMessage(), e);
}
@@ -330,7 +329,7 @@ public class IvyClasspathContainerSerializer {
}
private IClasspathEntry[] readCpEntries(Node cpEntries) throws IOException {
- List/* <IClasspathEntry> */entries = new ArrayList();
+ List<IClasspathEntry> entries = new ArrayList<>();
NodeList children = cpEntries.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node item = children.item(i);
@@ -341,7 +340,7 @@ public class IvyClasspathContainerSerializer {
}
}
}
- return (IClasspathEntry[]) entries.toArray(new IClasspathEntry[entries.size()]);
+ return entries.toArray(new IClasspathEntry[entries.size()]);
}
private IClasspathEntry readCpEntry(Node cpEntryNode) throws IOException {
@@ -385,7 +384,7 @@ public class IvyClasspathContainerSerializer {
}
private IAccessRule[] readAccessRules(Node accessRulesNode) throws IOException {
- List/* <IAccessRule> */rules = new ArrayList();
+ List<IAccessRule> rules = new ArrayList<>();
NodeList children = accessRulesNode.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node item = children.item(i);
@@ -396,7 +395,7 @@ public class IvyClasspathContainerSerializer {
}
}
}
- return (IAccessRule[]) rules.toArray(new IAccessRule[rules.size()]);
+ return rules.toArray(new IAccessRule[rules.size()]);
}
private IAccessRule readAccessRule(Node ruleNode) throws IOException {
@@ -407,7 +406,7 @@ public class IvyClasspathContainerSerializer {
}
private IClasspathAttribute[] readCpAttr(Node cpAttrsNode) throws IOException {
- List/* <IClasspathAttribute> */attrs = new ArrayList();
+ List<IClasspathAttribute> attrs = new ArrayList<>();
NodeList children = cpAttrsNode.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node item = children.item(i);
@@ -418,7 +417,7 @@ public class IvyClasspathContainerSerializer {
}
}
}
- return (IClasspathAttribute[]) attrs.toArray(new IClasspathAttribute[attrs.size()]);
+ return attrs.toArray(new IClasspathAttribute[attrs.size()]);
}
private IClasspathAttribute readAttr(Node attrNode) throws IOException {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerState.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerState.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerState.java
index 1537637..d7fb2dc 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerState.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerState.java
@@ -54,7 +54,7 @@ public class IvyClasspathContainerState extends CachedIvy {
return conf.getProject();
}
- protected Collection getPropertyFiles() throws IvyDEException {
+ protected Collection<String> getPropertyFiles() throws IvyDEException {
return conf.getInheritedSettingsSetup().getResolvedPropertyFiles();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathInitializer.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathInitializer.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathInitializer.java
index 7ac3f92..0253982 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathInitializer.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathInitializer.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.IvyDEMessage;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
@@ -96,10 +97,10 @@ public class IvyClasspathInitializer extends ClasspathContainerInitializer {
// try what the IvyDE plugin saved
IvyClasspathContainerSerializer serializer = IvyPlugin.getDefault()
.getIvyClasspathContainerSerializer();
- Map ivycps = serializer.read(project);
- if (ivycps != null) {
+ Map<IPath, IvyClasspathContainer> containers = serializer.read(project);
+ if (containers != null) {
IvyDEMessage.debug("Found serialized containers");
- ivycp = (IvyClasspathContainerImpl) ivycps.get(containerPath);
+ ivycp = (IvyClasspathContainerImpl) containers.get(containerPath);
}
if (ivycp == null) {
IvyDEMessage.debug("No serialized containers match the expected container path");
@@ -169,18 +170,16 @@ public class IvyClasspathInitializer extends ClasspathContainerInitializer {
// update the classpath of the project by updating the IvyDE container
IClasspathEntry newEntry = JavaCore.newContainerEntry(updatedPath, null,
attributes, exported);
- IClasspathEntry[] entries;
- entries = project.getRawClasspath();
- List newEntries = new ArrayList(Arrays.asList(entries));
+ IClasspathEntry[] entries = project.getRawClasspath();
+ List<IClasspathEntry> newEntries = new ArrayList<>(Arrays.asList(entries));
for (int i = 0; i < newEntries.size(); i++) {
- IClasspathEntry e = (IClasspathEntry) newEntries.get(i);
+ IClasspathEntry e = newEntries.get(i);
if (e == entry) {
newEntries.set(i, newEntry);
break;
}
}
- entries = (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries
- .size()]);
+ entries = newEntries.toArray(new IClasspathEntry[newEntries.size()]);
project.setRawClasspath(entries, project.getOutputLocation(), null);
} catch (JavaModelException e) {
IvyPlugin.logError("Unable to update the container path", e);
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathUtil.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathUtil.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathUtil.java
index 19aae09..7ebd1fd 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathUtil.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathUtil.java
@@ -23,7 +23,6 @@ import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
@@ -70,11 +69,10 @@ public final class IvyClasspathUtil {
return null;
}
- public static List split(String str) {
- String[] terms = str.split(",");
- List ret = new ArrayList();
- for (int i = 0; i < terms.length; i++) {
- String t = terms[i].trim();
+ public static List<String> split(String str) {
+ List<String> ret = new ArrayList<>();
+ for (String term : str.split(",")) {
+ String t = term.trim();
if (t.length() > 0) {
ret.add(t);
}
@@ -82,17 +80,16 @@ public final class IvyClasspathUtil {
return ret;
}
- public static String concat(Collection/* <String> */list) {
+ public static String concat(Collection<String> list) {
if (list == null) {
return "";
}
StringBuilder b = new StringBuilder();
- Iterator it = list.iterator();
- while (it.hasNext()) {
- b.append(it.next());
- if (it.hasNext()) {
+ for (String item : list) {
+ if (b.length() > 0) {
b.append(",");
}
+ b.append(item);
}
return b.toString();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvydeContainerPage.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvydeContainerPage.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvydeContainerPage.java
index 6430030..5d9f700 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvydeContainerPage.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvydeContainerPage.java
@@ -19,11 +19,11 @@ package org.apache.ivyde.internal.eclipse.cpcontainer;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerConfiguration;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.eclipse.cp.SettingsSetup;
@@ -86,7 +86,7 @@ public class IvydeContainerPage extends NewElementWizardPage implements IClasspa
private String oldIvyFile = null;
- private List oldConfs = null;
+ private List<String> oldConfs = null;
private IvyClasspathContainerState state;
@@ -132,18 +132,16 @@ public class IvydeContainerPage extends NewElementWizardPage implements IClasspa
String error = null;
String ivyFilePath = ivyFilePathText.getIvyFilePath();
- List selectedConfigurations = confTableViewer.getSelectedConfigurations();
+ List<String> selectedConfigurations = confTableViewer.getSelectedConfigurations();
- List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper
+ List<IvyClasspathContainer> containers = IvyClasspathContainerHelper
.getContainers(project);
if (containers == null) {
return null;
}
- Iterator/* <IvyClasspathContainer> */itContainers = containers.iterator();
- while (error == null && itContainers.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainers.next();
- IvyClasspathContainerConfiguration cpc = ivycp.getConf();
+ for (IvyClasspathContainer container : containers) {
+ IvyClasspathContainerConfiguration cpc = container.getConf();
// first check that this is not the one we are editing
if (oldIvyFile != null && cpc.getIvyXmlPath().equals(oldIvyFile) && oldConfs != null
@@ -157,12 +155,14 @@ public class IvydeContainerPage extends NewElementWizardPage implements IClasspa
|| cpc.getConfs().isEmpty() || cpc.getConfs().contains("*")) {
error = "A container already exists for the selected conf of "
+ "the module descriptor";
+ break;
} else {
- ArrayList list = new ArrayList(cpc.getConfs());
+ List<String> list = new ArrayList<>(cpc.getConfs());
list.retainAll(selectedConfigurations);
if (!list.isEmpty()) {
error = "A container already exists for the selected conf of "
+ "the module descriptor";
+ break;
}
}
}
@@ -185,7 +185,7 @@ public class IvydeContainerPage extends NewElementWizardPage implements IClasspa
}
public boolean finish() {
- List confs = confTableViewer.getSelectedConfigurations();
+ List<String> confs = confTableViewer.getSelectedConfigurations();
if (confs.isEmpty()) {
confs = Collections.singletonList("*");
}
@@ -356,7 +356,7 @@ public class IvydeContainerPage extends NewElementWizardPage implements IClasspa
confTableViewer = new ConfTableViewer(configComposite, SWT.NONE);
confTableViewer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
confTableViewer.addListener(new ConfTableListener() {
- public void confTableUpdated(List confs) {
+ public void confTableUpdated(List<String> confs) {
checkCompleted();
}
});
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AbstractIvyDEHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AbstractIvyDEHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AbstractIvyDEHandler.java
index e755add..055ecc8 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AbstractIvyDEHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AbstractIvyDEHandler.java
@@ -19,12 +19,12 @@ package org.apache.ivyde.internal.eclipse.handlers;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathUtil;
@@ -48,8 +48,7 @@ public abstract class AbstractIvyDEHandler extends AbstractHandler {
return null;
}
- // Map<IProject, Set<IvyClasspathContainer>>
- Map projects = getProjectAndContainers((IStructuredSelection) selection);
+ Map<IProject, Set<IvyClasspathContainer>> projects = getProjectAndContainers((IStructuredSelection) selection);
if (projects.size() > 0) {
handleProjects(projects);
@@ -58,30 +57,27 @@ public abstract class AbstractIvyDEHandler extends AbstractHandler {
return null;
}
- public static Map/* <IProject, Set<IvyClasspathContainer>> */getProjectAndContainers(
+ public static Map<IProject, Set<IvyClasspathContainer>> getProjectAndContainers(
IStructuredSelection selection) {
- Map/* <IProject, Set<IvyClasspathContainer>> */projects = new HashMap();
+ Map<IProject, Set<IvyClasspathContainer>> projects = new HashMap<>();
- Iterator it = selection.iterator();
- while (it.hasNext()) {
- Object element = it.next();
+ for (Object element : selection.toList()) {
if (element instanceof IWorkingSet) {
- IAdaptable[] elements = ((IWorkingSet) element).getElements();
- for (int i = 0; i < elements.length; i++) {
- addElement(projects, elements[i]);
+ for (IAdaptable elem : ((IWorkingSet) element).getElements()) {
+ addElement(projects, elem);
}
} else if (element instanceof ClassPathContainer) {
IvyClasspathContainerImpl ivycp = IvyClasspathUtil
.jdt2IvyCPC(((ClassPathContainer) element));
IJavaProject javaProject = ivycp.getConf().getJavaProject();
if (javaProject != null) {
- Set/* <IvyClasspathContainer> */cplist = (Set) projects.get(javaProject
+ Set<IvyClasspathContainer> containers = projects.get(javaProject
.getProject());
- if (cplist == null) {
- cplist = new HashSet();
- projects.put(javaProject.getProject(), cplist);
+ if (containers == null) {
+ containers = new HashSet<>();
+ projects.put(javaProject.getProject(), containers);
}
- cplist.add(ivycp);
+ containers.add(ivycp);
}
} else {
addElement(projects, element);
@@ -90,7 +86,7 @@ public abstract class AbstractIvyDEHandler extends AbstractHandler {
return projects;
}
- private static void addElement(Map/* <IProject, Set<IvyClasspathContainer>> */projects,
+ private static void addElement(Map<IProject, Set<IvyClasspathContainer>> projects,
Object adaptableProject) {
IProject project = null;
if (adaptableProject instanceof IProject) {
@@ -100,26 +96,23 @@ public abstract class AbstractIvyDEHandler extends AbstractHandler {
}
if (project != null) {
// check that there is an IvyDE container
- List containers = IvyClasspathContainerHelper.getContainers(project);
+ List<IvyClasspathContainer> containers = IvyClasspathContainerHelper.getContainers(project);
if (!containers.isEmpty()) {
- projects.put(project, new HashSet(containers));
+ projects.put(project, new HashSet<>(containers));
}
}
}
- protected void handleProjects(Map projects) {
- Iterator it = projects.entrySet().iterator();
- while (it.hasNext()) {
- Entry entry = (Entry) it.next();
- Iterator itContainers = ((Set) entry.getValue()).iterator();
- while (itContainers.hasNext()) {
- handleContainer((IProject) entry.getKey(),
- (IvyClasspathContainerImpl) itContainers.next());
+ protected void handleProjects(Map<IProject, Set<IvyClasspathContainer>> projects) {
+ for (Entry<IProject, Set<IvyClasspathContainer>> entry : projects.entrySet()) {
+ IProject project = entry.getKey();
+ for (IvyClasspathContainer container : entry.getValue()) {
+ handleContainer(project, container);
}
}
}
- protected void handleContainer(IProject project, IvyClasspathContainerImpl cp) {
+ protected void handleContainer(IProject project, IvyClasspathContainer container) {
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AddIvyNatureHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AddIvyNatureHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AddIvyNatureHandler.java
index a16ff35..5041f76 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AddIvyNatureHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/AddIvyNatureHandler.java
@@ -17,7 +17,6 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -39,11 +38,8 @@ public class AddIvyNatureHandler extends AbstractHandler {
return null;
}
- List/* <IProject> */projects = new LinkedList();
- IStructuredSelection newSelection = (IStructuredSelection) selection;
- Iterator iter = newSelection.iterator();
- while (iter.hasNext()) {
- Object object = iter.next();
+ List<IProject> projects = new LinkedList<>();
+ for (Object object : ((IStructuredSelection) selection).toList()) {
if (object instanceof IAdaptable) {
IProject project = (IProject) ((IAdaptable) object).getAdapter(IProject.class);
if (project != null) {
@@ -57,9 +53,7 @@ public class AddIvyNatureHandler extends AbstractHandler {
}
if (projects.size() > 0) {
- Iterator itProject = projects.iterator();
- while (itProject.hasNext()) {
- IProject project = (IProject) itProject.next();
+ for (IProject project : projects) {
IvyNatureHelper.addNature(project);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/OpenIvyFileHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/OpenIvyFileHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/OpenIvyFileHandler.java
index 36c5dc1..647c10b 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/OpenIvyFileHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/OpenIvyFileHandler.java
@@ -17,8 +17,8 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerConfiguration;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -36,12 +36,12 @@ public class OpenIvyFileHandler extends AbstractIvyDEHandler {
public static final String COMMAND_ID = "org.apache.ivyde.commands.openivyfile";
- protected void handleContainer(IProject project, IvyClasspathContainerImpl cp) {
- open(cp);
+ protected void handleContainer(IProject project, IvyClasspathContainer container) {
+ open(container);
}
- public static void open(IvyClasspathContainerImpl cp) {
- IvyClasspathContainerConfiguration conf = cp.getConf();
+ public static void open(IvyClasspathContainer container) {
+ IvyClasspathContainerConfiguration conf = container.getConf();
if (conf.getJavaProject() == null) {
return;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RefreshHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RefreshHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RefreshHandler.java
index 2a07091..c637a37 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RefreshHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RefreshHandler.java
@@ -17,15 +17,15 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.eclipse.core.resources.IProject;
public class RefreshHandler extends AbstractIvyDEHandler {
public static final String COMMAND_ID = "org.apache.ivyde.commands.refresh";
- protected void handleContainer(IProject project, IvyClasspathContainerImpl ivycp) {
- ivycp.launchResolve(true, null);
+ protected void handleContainer(IProject project, IvyClasspathContainer container) {
+ container.launchResolve(true, null);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ReloadSettingsHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ReloadSettingsHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ReloadSettingsHandler.java
index a19908e..8812c25 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ReloadSettingsHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ReloadSettingsHandler.java
@@ -17,15 +17,15 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.eclipse.core.resources.IProject;
public class ReloadSettingsHandler extends AbstractIvyDEHandler {
public static final String COMMAND_ID = "org.apache.ivyde.commands.reloadsettings";
- protected void handleContainer(IProject project, IvyClasspathContainerImpl cp) {
- cp.reloadSettings();
+ protected void handleContainer(IProject project, IvyClasspathContainer container) {
+ container.reloadSettings();
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RemoveIvyNatureHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RemoveIvyNatureHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RemoveIvyNatureHandler.java
index aaae115..18dc9e3 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RemoveIvyNatureHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/RemoveIvyNatureHandler.java
@@ -17,7 +17,6 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -44,11 +43,8 @@ public class RemoveIvyNatureHandler extends AbstractHandler {
return null;
}
- List/* <IProject> */projects = new LinkedList();
- IStructuredSelection newSelection = (IStructuredSelection) selection;
- Iterator iter = newSelection.iterator();
- while (iter.hasNext()) {
- Object object = iter.next();
+ List<IProject> projects = new LinkedList<>();
+ for (Object object : ((IStructuredSelection) selection).toList()) {
if (object instanceof IAdaptable) {
IProject project = (IProject) ((IAdaptable) object).getAdapter(IProject.class);
if (project != null) {
@@ -71,9 +67,7 @@ public class RemoveIvyNatureHandler extends AbstractHandler {
+ "The configuration of the classpath containers will be lost.\n"
+ "This operation cannot be undone.");
if (doRemove) {
- Iterator itProject = projects.iterator();
- while (itProject.hasNext()) {
- IProject project = (IProject) itProject.next();
+ for (IProject project : projects) {
IvyNatureHelper.removeNature(project);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java
index 95a2cb2..8994189 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveAllHandler.java
@@ -17,10 +17,8 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
-import java.util.Iterator;
-
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -42,11 +40,9 @@ public class ResolveAllHandler extends AbstractHandler {
return null;
}
- for (int i = 0; i < projects.length; i++) {
- Iterator it = IvyClasspathContainerHelper.getContainers(projects[i]).iterator();
- while (it.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next();
- ivycp.launchResolve(false, null);
+ for (IJavaProject project : projects) {
+ for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(project)) {
+ container.launchResolve(false, null);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveHandler.java
index 1b27da0..6801f8d 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ResolveHandler.java
@@ -17,15 +17,15 @@
*/
package org.apache.ivyde.internal.eclipse.handlers;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.eclipse.core.resources.IProject;
public class ResolveHandler extends AbstractIvyDEHandler {
public static final String COMMAND_ID = "org.apache.ivyde.commands.resolve";
- protected void handleContainer(IProject project, IvyClasspathContainerImpl ivycp) {
- ivycp.launchResolve(false, null);
+ protected void handleContainer(IProject project, IvyClasspathContainer container) {
+ container.launchResolve(false, null);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ViewReverseDependenciesHandler.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ViewReverseDependenciesHandler.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ViewReverseDependenciesHandler.java
index 85864d9..a1aee01 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ViewReverseDependenciesHandler.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/handlers/ViewReverseDependenciesHandler.java
@@ -18,7 +18,9 @@
package org.apache.ivyde.internal.eclipse.handlers;
import java.util.Map;
+import java.util.Set;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
import org.apache.ivyde.internal.eclipse.ui.views.ReverseDependencyExplorerView;
import org.eclipse.core.resources.IProject;
@@ -29,10 +31,9 @@ public class ViewReverseDependenciesHandler extends AbstractIvyDEHandler {
public static final String COMMAND_ID = "org.apache.ivyde.commands.revdepexplorer";
- protected void handleProjects(Map projects) {
+ protected void handleProjects(Map<IProject, Set<IvyClasspathContainer>> projects) {
try {
- ReverseDependencyExplorerView.setSelectedProjects((IProject[]) projects.keySet()
- .toArray(new IProject[0]));
+ ReverseDependencyExplorerView.setSelectedProjects(projects.keySet().toArray(new IProject[0]));
IWorkbenchPage page = IvyPlugin.getActivePage();
page.showView("org.apache.ivyde.eclipse.ui.views.ReverseDependencyExplorer");
ReverseDependencyExplorerView.refresh(true);
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolveJob.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolveJob.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolveJob.java
index 90ebfc4..84f7044 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolveJob.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolveJob.java
@@ -19,7 +19,6 @@ package org.apache.ivyde.internal.eclipse.resolve;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -57,7 +56,7 @@ public class IvyResolveJob extends Job {
private static final int WAIT_BEFORE_LAUNCH = 1000;
- private final List resolveQueue = new ArrayList();
+ private final List<ResolveRequest> resolveQueue = new ArrayList<>();
public IvyResolveJob() {
super("IvyDE resolve");
@@ -92,9 +91,9 @@ public class IvyResolveJob extends Job {
private IStatus doRun(IProgressMonitor monitor) {
IvyDEMessage.info("Resolve job starting...");
- List toResolve;
+ List<ResolveRequest> toResolve;
synchronized (resolveQueue) {
- toResolve = new ArrayList(resolveQueue);
+ toResolve = new ArrayList<>(resolveQueue);
resolveQueue.clear();
}
@@ -107,10 +106,10 @@ public class IvyResolveJob extends Job {
monitor.beginTask("Loading ivy descriptors", MONITOR_LENGTH);
- Map/* <ModuleDescriptor, List<ResolveRequest>> */inworkspaceModules = new LinkedHashMap();
- List/* <ResolveRequest> */otherModules = new ArrayList();
- Map/* <ResolveRequest, Ivy> */ivys = new HashMap();
- Map/* <ResolveRequest, ModuleDescriptor> */mds = new HashMap();
+ Map<ModuleDescriptor, List<ResolveRequest>> inworkspaceModules = new LinkedHashMap<>();
+ List<ResolveRequest> otherModules = new ArrayList<>();
+ Map<ResolveRequest, Ivy> ivys = new HashMap<>();
+ Map<ResolveRequest, ModuleDescriptor> mds = new HashMap<>();
final MultiStatus errorsStatus = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
"Some projects fail to be resolved", null);
@@ -124,10 +123,7 @@ public class IvyResolveJob extends Job {
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(IvyResolveJob.class.getClassLoader());
try {
- Iterator itRequests = toResolve.iterator();
- while (itRequests.hasNext()) {
- ResolveRequest request = (ResolveRequest) itRequests.next();
-
+ for (ResolveRequest request : toResolve) {
IvyDEMessage.info("Processing resolve request " + request.toString());
forceFailOnError = forceFailOnError || request.isForceFailOnError();
@@ -174,9 +170,9 @@ public class IvyResolveJob extends Job {
cachedIvy.setErrorMarker(null);
mds.put(request, md);
if (request.isInWorkspace()) {
- List requests = (List) inworkspaceModules.get(md);
+ List<ResolveRequest> requests = inworkspaceModules.get(md);
if (requests == null) {
- requests = new ArrayList();
+ requests = new ArrayList<>();
inworkspaceModules.put(md, requests);
}
requests.add(request);
@@ -199,30 +195,22 @@ public class IvyResolveJob extends Job {
// we resolve them in the correct order
// The version matcher used will be the one configured for the first project
- ResolveRequest request = (ResolveRequest) ((List) inworkspaceModules.values()
- .iterator().next()).get(0);
- VersionMatcher versionMatcher = ((Ivy) ivys.get(request)).getSettings()
- .getVersionMatcher();
+ ResolveRequest request = inworkspaceModules.values().iterator().next().get(0);
+ VersionMatcher versionMatcher = ivys.get(request).getSettings().getVersionMatcher();
WarningNonMatchingVersionReporter vReporter = new WarningNonMatchingVersionReporter();
CircularDependencyStrategy circularDependencyStrategy = WarnCircularDependencyStrategy
.getInstance();
ModuleDescriptorSorter sorter = new ModuleDescriptorSorter(inworkspaceModules.keySet(),
versionMatcher, vReporter, circularDependencyStrategy);
- List sortedModuleDescriptors = sorter.sortModuleDescriptors();
- Iterator it = sortedModuleDescriptors.iterator();
- while (it.hasNext()) {
- ModuleDescriptor module = (ModuleDescriptor) it.next();
- List requests = (List) inworkspaceModules.get(module);
+ for (ModuleDescriptor module : sorter.sortModuleDescriptors()) {
+ List<ResolveRequest> requests = inworkspaceModules.get(module);
IvyDEMessage.info(requests.size() + " container(s) of module " + module
+ " to resolve in workspace");
- for (int i = 0; i < requests.size(); i++) {
- request = (ResolveRequest) requests.get(i);
- Ivy ivy = (Ivy) ivys.get(request);
- ModuleDescriptor md = (ModuleDescriptor) mds.get(request);
- boolean canceled = launchResolveThread(request, monitor, step, errorsStatus,
- ivy, md);
+ for (ResolveRequest req : requests) {
+ boolean canceled = launchResolveThread(req, monitor, step, errorsStatus,
+ ivys.get(req), mds.get(req));
if (canceled) {
IvyDEMessage.warn("Resolve job canceled");
return Status.CANCEL_STATUS;
@@ -236,13 +224,9 @@ public class IvyResolveJob extends Job {
} else {
IvyDEMessage.info(otherModules.size() + " module(s) to resolve outside the workspace");
- Iterator it = otherModules.iterator();
- while (it.hasNext()) {
- ResolveRequest request = (ResolveRequest) it.next();
- Ivy ivy = (Ivy) ivys.get(request);
- ModuleDescriptor md = (ModuleDescriptor) mds.get(request);
- boolean canceled = launchResolveThread(request, monitor, step, errorsStatus, ivy,
- md);
+ for (ResolveRequest request : otherModules) {
+ boolean canceled = launchResolveThread(request, monitor, step, errorsStatus,
+ ivys.get(request), mds.get(request));
if (canceled) {
IvyDEMessage.warn("Resolve job canceled");
return Status.CANCEL_STATUS;
@@ -255,9 +239,7 @@ public class IvyResolveJob extends Job {
monitor.setTaskName("Post resolve");
// launch every post batch resolve
- Iterator itRequests = toResolve.iterator();
- while (itRequests.hasNext()) {
- ResolveRequest request = (ResolveRequest) itRequests.next();
+ for (ResolveRequest request : toResolve) {
if (!request.isResolveFailed()) {
monitor.setTaskName(request.getResolver().toString());
request.getResolver().postBatchResolve();
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolver.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolver.java
index 6f96bcf..531289b 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolver.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/resolve/IvyResolver.java
@@ -21,7 +21,6 @@ import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,7 +67,7 @@ public class IvyResolver {
private final IProject project;
- private final List confInput;
+ private final List<String> confInput;
private String retrievePattern = null;
@@ -84,7 +83,7 @@ public class IvyResolver {
private boolean transitiveResolve = true;
- public IvyResolver(String ivyXmlPath, List confInput, IProject project) {
+ public IvyResolver(String ivyXmlPath, List<String> confInput, IProject project) {
this.ivyXmlPath = ivyXmlPath;
this.confInput = confInput;
this.project = project;
@@ -175,9 +174,9 @@ public class IvyResolver {
if (!result.getProblemMessages().isEmpty()) {
MultiStatus multiStatus = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
"Impossible to resolve dependencies of " + md.getModuleRevisionId(), null);
- for (Iterator iter = result.getProblemMessages().iterator(); iter.hasNext();) {
+ for (String s : result.getProblemMessages()) {
multiStatus.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
- (String) iter.next(), null));
+ s, null));
}
return multiStatus;
}
@@ -196,14 +195,14 @@ public class IvyResolver {
// nothing to do by default
}
- private void computeConfs(List/* <String> */confInput, ModuleDescriptor md) {
- Set configurations = new HashSet();
+ private void computeConfs(List<String> confInput, ModuleDescriptor md) {
+ Set<String> configurations = new HashSet<>();
configurations.addAll(confInput);
if (configurations.contains("*")) {
confs = md.getConfigurationsNames();
} else {
- confs = (String[]) configurations.toArray(new String[configurations.size()]);
+ confs = configurations.toArray(new String[configurations.size()]);
}
}
@@ -243,6 +242,7 @@ public class IvyResolver {
return result;
}
+ @SuppressWarnings("unchecked")
private ResolveResult doResolve(Ivy ivy, ModuleDescriptor md) throws ParseException,
IOException {
IvyDEMessage.debug("Doing a full resolve...");
@@ -264,14 +264,13 @@ public class IvyResolver {
ArtifactDownloadReport[] artifactReports = report.getArtifactsReports(null, false);
- Map/* <Artifact, ArtifactDownloadReport> */workspaceArtifacts = IvyContext
- .getContext().get(WorkspaceResolver.IVYDE_WORKSPACE_ARTIFACT_REPORTS);
+ Map<Artifact, ArtifactDownloadReport> workspaceArtifacts = IvyContext.getContext()
+ .get(WorkspaceResolver.IVYDE_WORKSPACE_ARTIFACT_REPORTS);
if (workspaceArtifacts != null) {
// some artifact were 'forced' by the dependency declaration, whereas they should be
// switch by the eclipse project reference
for (int i = 0; i < artifactReports.length; i++) {
- ArtifactDownloadReport eclipseArtifactReport = (ArtifactDownloadReport) workspaceArtifacts
- .get(artifactReports[i].getArtifact());
+ ArtifactDownloadReport eclipseArtifactReport = workspaceArtifacts.get(artifactReports[i].getArtifact());
if (eclipseArtifactReport != null) {
// let's switch.
artifactReports[i] = eclipseArtifactReport;
@@ -320,9 +319,8 @@ public class IvyResolver {
}
}
- private void collectArtifactsByDependency(ResolveReport r, ResolveResult result) {
- for (Iterator it = r.getDependencies().iterator(); it.hasNext();) {
- IvyNode node = (IvyNode) it.next();
+ private void collectArtifactsByDependency(ResolveReport rr, ResolveResult result) {
+ for (IvyNode node : rr.getDependencies()) {
if (node.getDescriptor() != null) {
result.putArtifactsForDep(node.getResolvedId(), node.getDescriptor()
.getAllArtifacts());
@@ -363,7 +361,7 @@ public class IvyResolver {
}
options.setConfs(confs).setDestArtifactPattern(pattern);
if (retrieveTypes != null && !retrieveTypes.equals("*")) {
- List typeList = IvyClasspathUtil.split(retrieveTypes);
+ List<String> typeList = IvyClasspathUtil.split(retrieveTypes);
options.setArtifactFilter(new ArtifactTypeFilter(typeList));
}
options.setResolveId(IvyClasspathUtil.buildResolveId(useExtendedResolveId, md));
@@ -404,7 +402,7 @@ public class IvyResolver {
.getVariables());
try {
// FIXME same as above
- Map retrievedArtifacts = ivy.getRetrieveEngine().determineArtifactsToCopy(
+ Map<ArtifactDownloadReport, Set<String>> retrievedArtifacts = ivy.getRetrieveEngine().determineArtifactsToCopy(
md.getModuleRevisionId(), resolvedPattern, options);
result.setRetrievedArtifacts(retrievedArtifacts);
} catch (ParseException e) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/RetrieveSetupManager.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/RetrieveSetupManager.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/RetrieveSetupManager.java
index 9b43b93..db1465e 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/RetrieveSetupManager.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/RetrieveSetupManager.java
@@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -41,13 +40,13 @@ public class RetrieveSetupManager implements ISaveParticipant {
private static final String PREF_ID = "org.apache.ivyde.eclipse.standaloneretrieve";
- private Map/* <IProject, IEclipsePreferences> */projectPrefs = new HashMap();
+ private final Map<IProject, IEclipsePreferences> projectPrefs = new HashMap<>();
- public List/* <StandaloneRetrieveSetup> */getSetup(IProject project) throws IOException {
+ public List<StandaloneRetrieveSetup> getSetup(IProject project) throws IOException {
IEclipsePreferences pref;
synchronized (projectPrefs) {
- pref = (IEclipsePreferences) projectPrefs.get(project);
+ pref = projectPrefs.get(project);
}
if (pref == null) {
IScopeContext projectScope = new ProjectScope(project);
@@ -55,9 +54,9 @@ public class RetrieveSetupManager implements ISaveParticipant {
}
String retrieveSetup = pref.get(PREF_ID, null);
if (retrieveSetup == null) {
- return new ArrayList();
+ return new ArrayList<>();
}
- List/* <StandaloneRetrieveSetup> */retrieveSetups;
+ List<StandaloneRetrieveSetup> retrieveSetups;
StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
ByteArrayInputStream in = new ByteArrayInputStream(retrieveSetup.getBytes());
@@ -73,7 +72,7 @@ public class RetrieveSetupManager implements ISaveParticipant {
return retrieveSetups;
}
- public void save(final IProject project, List/* <StandaloneRetrieveSetup> */retrieveSetups)
+ public void save(final IProject project, List<StandaloneRetrieveSetup> retrieveSetups)
throws IOException {
StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -90,7 +89,7 @@ public class RetrieveSetupManager implements ISaveParticipant {
final String retrieveSetup = new String(out.toByteArray());
synchronized (projectPrefs) {
- IEclipsePreferences pref = (IEclipsePreferences) projectPrefs.get(project);
+ IEclipsePreferences pref = projectPrefs.get(project);
if (pref == null) {
IScopeContext projectScope = new ProjectScope(project);
pref = projectScope.getNode(IvyPlugin.ID);
@@ -105,19 +104,17 @@ public class RetrieveSetupManager implements ISaveParticipant {
}
public void saving(ISaveContext context) throws CoreException {
- Map toFlush = new HashMap();
+ Map<IProject, IEclipsePreferences> toFlush = new HashMap<>();
synchronized (projectPrefs) {
toFlush.putAll(projectPrefs);
projectPrefs.clear();
}
- Iterator itPrefs = toFlush.entrySet().iterator();
- while (itPrefs.hasNext()) {
- Entry entry = (Entry) itPrefs.next();
+ for (Entry<IProject, IEclipsePreferences> entry : toFlush.entrySet()) {
try {
- ((IEclipsePreferences) entry.getValue()).flush();
+ entry.getValue().flush();
} catch (BackingStoreException e) {
IvyPlugin.logError("Failed to save the state of the Ivy preferences of "
- + ((IProject) entry.getKey()).getName(), e);
+ + entry.getKey().getName(), e);
}
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java
index 64a810a..4c671d1 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSerializer.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
@@ -81,7 +80,7 @@ public class StandaloneRetrieveSerializer {
private static final String RESOLVE_IN_WORKSPACE = "resolveInWorkspace";
- public void write(OutputStream out, List/* <StandaloneRetrieveSetup> */setuplist)
+ public void write(OutputStream out, List<StandaloneRetrieveSetup> setuplist)
throws IOException {
try {
StreamResult result = new StreamResult(out);
@@ -92,9 +91,7 @@ public class StandaloneRetrieveSerializer {
Node root = document.createElement(ROOT);
document.appendChild(root);
- Iterator it = setuplist.iterator();
- while (it.hasNext()) {
- StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) it.next();
+ for (StandaloneRetrieveSetup setup : setuplist) {
Node node = document.createElement(SETUP);
root.appendChild(node);
@@ -155,9 +152,7 @@ public class StandaloneRetrieveSerializer {
attr.setValue(settingsSetup.getRawIvyUserDir());
attributes.setNamedItem(attr);
- Iterator it = settingsSetup.getRawPropertyFiles().iterator();
- while (it.hasNext()) {
- String file = (String) it.next();
+ for (String file : settingsSetup.getRawPropertyFiles()) {
Node pathNode = document.createElement(PROPERTYFILE);
settingsNode.appendChild(pathNode);
attributes = pathNode.getAttributes();
@@ -195,7 +190,7 @@ public class StandaloneRetrieveSerializer {
attributes.setNamedItem(attr);
}
- public List/* <StandaloneRetrieveSetup> */read(InputStream in, IProject project)
+ public List<StandaloneRetrieveSetup> read(InputStream in, IProject project)
throws IOException {
try {
InputSource source = new InputSource(in);
@@ -206,7 +201,7 @@ public class StandaloneRetrieveSerializer {
NodeList elements = document.getElementsByTagName(SETUP);
- List/* <StandaloneRetrieveSetup> */setupList = new ArrayList();
+ List<StandaloneRetrieveSetup> setupList = new ArrayList<>();
int count = elements.getLength();
for (int i = 0; i != count; i++) {
@@ -279,7 +274,7 @@ public class StandaloneRetrieveSerializer {
String ivyUserDir = getAttribute(attributes, IVY_USER_DIR);
settingsSetup.setIvyUserDir(ivyUserDir);
- List/* <String> */propertyFiles = new ArrayList();
+ List<String> propertyFiles = new ArrayList<>();
NodeList children = node.getChildNodes();
for (int j = 0; j != children.getLength(); j++) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetupState.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetupState.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetupState.java
index d56a0a9..db9bbd4 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetupState.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/retrieve/StandaloneRetrieveSetupState.java
@@ -48,7 +48,7 @@ public class StandaloneRetrieveSetupState extends CachedIvy {
return setup.getInheritedSettingSetup().getResolvedIvyUserDir(setup.getProject());
}
- protected Collection getPropertyFiles() throws IvyDEException {
+ protected Collection<String> getPropertyFiles() throws IvyDEException {
return setup.getInheritedSettingSetup().getResolvedPropertyFiles();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/IvyUtil.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/IvyUtil.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/IvyUtil.java
index fc8c70f..3e7ebd2 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/IvyUtil.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/IvyUtil.java
@@ -21,12 +21,13 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.eclipse.core.resources.IProject;
@@ -37,24 +38,18 @@ public final class IvyUtil {
// utility class
}
- public static MultiRevDependencyDescriptor[] getDependencyDescriptorsByProjects(
- IProject[] projects) {
+ public static MultiRevDependencyDescriptor[] getDependencyDescriptorsByProjects(IProject[] projects) {
// a temporary cache of multi-revision dependency descriptors
- Map/* <ModuleId, MultiRevisionDependencyDescriptor> */mdMap = new HashMap();
+ Map<ModuleId, MultiRevDependencyDescriptor> mdMap = new HashMap<>();
- for (int i = 0; i < projects.length; i++) {
- List containers = IvyClasspathContainerHelper.getContainers(projects[i]);
- Iterator containerIter = containers.iterator();
-
- while (containerIter.hasNext()) {
- IvyClasspathContainerImpl container = (IvyClasspathContainerImpl) containerIter.next();
- ModuleDescriptor md = container.getState().getCachedModuleDescriptor();
+ for (IProject project : projects) {
+ for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(project)) {
+ ModuleDescriptor md = ((IvyClasspathContainerImpl) container).getState().getCachedModuleDescriptor();
if (md == null) {
continue;
}
for (DependencyDescriptor descriptor : md.getDependencies()) {
- MultiRevDependencyDescriptor syncabledd = (MultiRevDependencyDescriptor)
- mdMap.get(descriptor.getDependencyId());
+ MultiRevDependencyDescriptor syncabledd = mdMap.get(descriptor.getDependencyId());
if (syncabledd == null) {
syncabledd = new MultiRevDependencyDescriptor(
@@ -68,14 +63,10 @@ public final class IvyUtil {
}
}
- List/* <MultiRevisionDependencyDescriptor> */sorted = new ArrayList(mdMap
- .values());
-
- Collections.sort(sorted, new Comparator/* <MultiRevisionDependencyDescriptor> */() {
- public int compare(Object o1, Object o2) {
- MultiRevDependencyDescriptor desc1 = (MultiRevDependencyDescriptor) o1;
- MultiRevDependencyDescriptor desc2 = (MultiRevDependencyDescriptor) o2;
+ List<MultiRevDependencyDescriptor> sorted = new ArrayList<>(mdMap.values());
+ Collections.sort(sorted, new Comparator<MultiRevDependencyDescriptor>() {
+ public int compare(MultiRevDependencyDescriptor desc1, MultiRevDependencyDescriptor desc2) {
int equal = desc1.getOrganization().compareTo(desc2.getOrganization());
if (equal == 0) {
equal = desc1.getModule().compareTo(desc2.getModule());
@@ -84,8 +75,7 @@ public final class IvyUtil {
}
});
- return (MultiRevDependencyDescriptor[]) sorted
- .toArray(new MultiRevDependencyDescriptor[sorted.size()]);
+ return sorted.toArray(new MultiRevDependencyDescriptor[sorted.size()]);
}
/**
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/MultiRevDependencyDescriptor.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/MultiRevDependencyDescriptor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/MultiRevDependencyDescriptor.java
index ecd7d25..861e6b5 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/MultiRevDependencyDescriptor.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/MultiRevDependencyDescriptor.java
@@ -20,21 +20,17 @@ package org.apache.ivyde.internal.eclipse.revdepexplorer;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
public class MultiRevDependencyDescriptor {
private final ModuleId moduleId;
- /**
- * Map<IvyClasspathContainer, Collection<DependencyDescriptor>>
- */
- private final Map dependenciesByContainer = new HashMap();
+ private final Map<IvyClasspathContainer, Collection<DependencyDescriptor>> dependenciesByContainer = new HashMap<>();
private String newRevision;
@@ -71,13 +67,12 @@ public class MultiRevDependencyDescriptor {
* @param dependencyDescriptor
* current descriptor
*/
- public void addDependencyDescriptor(IvyClasspathContainerImpl container,
+ public void addDependencyDescriptor(IvyClasspathContainer container,
DependencyDescriptor dependencyDescriptor) {
- Collection/* <DependencyDescriptor> */dependencies = (Collection) dependenciesByContainer
- .get(container);
+ Collection<DependencyDescriptor> dependencies = dependenciesByContainer.get(container);
if (dependencies == null) {
- dependencies = new HashSet/* <DependencyDescriptor> */();
+ dependencies = new HashSet<>();
dependenciesByContainer.put(container, dependencies);
}
@@ -102,22 +97,15 @@ public class MultiRevDependencyDescriptor {
* @return all revisions
*/
public String[] getRevisions() {
- Set/* <String> */revisions = new HashSet/* <String> */();
-
- /* Collection<Collection<DependencyDescriptor>> */
- Collection projectDependencyDescriptors = dependenciesByContainer.values();
+ Set<String> revisions = new HashSet<>();
- Iterator it = projectDependencyDescriptors.iterator();
- while (it.hasNext()) {
- Collection/* <DependencyDescriptor> */projectCollection = (Collection) it.next();
- Iterator descriptorIter = projectCollection.iterator();
- while (descriptorIter.hasNext()) {
- DependencyDescriptor descriptor = (DependencyDescriptor) descriptorIter.next();
+ for (Collection<DependencyDescriptor> projectCollection : dependenciesByContainer.values()) {
+ for (DependencyDescriptor descriptor : projectCollection) {
revisions.add(descriptor.getDependencyRevisionId().getRevision());
}
}
- return (String[]) revisions.toArray(new String[revisions.size()]);
+ return revisions.toArray(new String[revisions.size()]);
}
/**
@@ -145,10 +133,9 @@ public class MultiRevDependencyDescriptor {
/**
* @return all projects
*/
- public IvyClasspathContainerImpl[] getIvyClasspathContainers() {
- Collection containers = dependenciesByContainer.keySet();
- return (IvyClasspathContainerImpl[]) containers.toArray(new IvyClasspathContainerImpl[containers
- .size()]);
+ public IvyClasspathContainer[] getIvyClasspathContainers() {
+ Collection<IvyClasspathContainer> containers = dependenciesByContainer.keySet();
+ return containers.toArray(new IvyClasspathContainer[containers.size()]);
}
/**
@@ -156,10 +143,8 @@ public class MultiRevDependencyDescriptor {
* classpath container
* @return true if there is a project match
*/
- public boolean isForContainer(IvyClasspathContainerImpl container) {
- IvyClasspathContainerImpl[] containers = getIvyClasspathContainers();
- for (int i = 0; i < containers.length; i++) {
- IvyClasspathContainerImpl currentContainer = containers[i];
+ public boolean isForContainer(IvyClasspathContainer container) {
+ for (IvyClasspathContainer currentContainer : getIvyClasspathContainers()) {
if (currentContainer.equals(container)) {
return true;
}
@@ -181,23 +166,20 @@ public class MultiRevDependencyDescriptor {
* container
* @return revision
*/
- public String[] getRevisions(IvyClasspathContainerImpl container) {
- /* Collection<DependencyDescriptor> */
- Collection containerDependencyDescriptors = (Collection) dependenciesByContainer
+ public String[] getRevisions(IvyClasspathContainer container) {
+ Collection<DependencyDescriptor> containerDependencyDescriptors = dependenciesByContainer
.get(container);
if (containerDependencyDescriptors == null) {
return new String[0];
}
- Set/* <String> */revisions = new HashSet/* <String> */();
+ Set<String> revisions = new HashSet<>();
- Iterator iter = containerDependencyDescriptors.iterator();
- while (iter.hasNext()) {
- DependencyDescriptor descriptor = (DependencyDescriptor) iter.next();
+ for (DependencyDescriptor descriptor : containerDependencyDescriptors) {
revisions.add(descriptor.getDependencyRevisionId().getRevision());
}
- return (String[]) revisions.toArray(new String[revisions.size()]);
+ return revisions.toArray(new String[revisions.size()]);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/SyncIvyFilesJob.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/SyncIvyFilesJob.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/SyncIvyFilesJob.java
index 2191b81..070e566 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/SyncIvyFilesJob.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/revdepexplorer/SyncIvyFilesJob.java
@@ -38,9 +38,11 @@ import org.apache.ivy.plugins.namespace.NamespaceTransformer;
import org.apache.ivy.plugins.parser.xml.UpdateOptions;
import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorUpdater;
import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerConfiguration;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
+import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerState;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.WorkspaceJob;
@@ -106,28 +108,23 @@ public class SyncIvyFilesJob extends WorkspaceJob {
MultiStatus errorStatuses = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
"Failed to update one or more Ivy files. See details.", null);
- IvyClasspathContainerImpl[] containers = getIvyClasspathContainers();
- for (int i = 0; i < containers.length; i++) {
- IvyClasspathContainerImpl container = containers[i];
+ for (IvyClasspathContainer container : getIvyClasspathContainers()) {
+ IvyClasspathContainerState ivycps = ((IvyClasspathContainerImpl) container).getState();
- ModuleDescriptor md = container.getState().getCachedModuleDescriptor();
+ ModuleDescriptor md = ivycps.getCachedModuleDescriptor();
if (md == null) {
continue;
}
- Map/* <ModuleRevisionId, String> */newRevisions = new HashMap();
-
- DependencyDescriptor[] dependencies = md.getDependencies();
- for (int j = 0; j < dependencies.length; j++) {
- for (int k = 0; k < multiRevisionDependencies.length; k++) {
- MultiRevDependencyDescriptor multiRevision = multiRevisionDependencies[k];
- ModuleRevisionId dependencyRevisionId = dependencies[j]
- .getDependencyRevisionId();
- if (dependencies[j].getDependencyId().equals(multiRevision.getModuleId())
+ Map<ModuleRevisionId, String> newRevisions = new HashMap<>();
+ for (DependencyDescriptor dependency : md.getDependencies()) {
+ for (MultiRevDependencyDescriptor multiRevision : multiRevisionDependencies) {
+ ModuleRevisionId dependencyRevisionId = dependency.getDependencyRevisionId();
+ if (dependency.getDependencyId().equals(multiRevision.getModuleId())
&& multiRevision.hasNewRevision()
&& multiRevision.isForContainer(container)) {
newRevisions.put(dependencyRevisionId,
- multiRevisionDependencies[k].getNewRevision());
+ multiRevision.getNewRevision());
break; // move on to the next dependency
}
}
@@ -139,7 +136,7 @@ public class SyncIvyFilesJob extends WorkspaceJob {
File ivyFile;
try {
- ivyFile = container.getState().getIvyFile();
+ ivyFile = ivycps.getIvyFile();
} catch (IvyDEException e) {
errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
"Fail to resolve the ivy file", e));
@@ -180,21 +177,19 @@ public class SyncIvyFilesJob extends WorkspaceJob {
return status;
}
- private IvyClasspathContainerImpl[] getIvyClasspathContainers() {
- Collection/* <IvyClasspathContainer> */containers = new HashSet();
+ private Collection<IvyClasspathContainer> getIvyClasspathContainers() {
+ Collection<IvyClasspathContainer> containers = new HashSet<>();
- for (int i = 0; i < multiRevisionDependencies.length; i++) {
- MultiRevDependencyDescriptor multiRevision = multiRevisionDependencies[i];
+ for (MultiRevDependencyDescriptor multiRevision : multiRevisionDependencies) {
if (multiRevision.hasNewRevision()) {
containers.addAll(Arrays.asList(multiRevision.getIvyClasspathContainers()));
}
}
- return (IvyClasspathContainerImpl[]) containers.toArray(new IvyClasspathContainerImpl[containers
- .size()]);
+ return containers;
}
- private void saveChanges(IvyClasspathContainerImpl container, File permanentSaveTarget,
+ private void saveChanges(IvyClasspathContainer container, File permanentSaveTarget,
File temporaryChanges) throws IOException {
IvyClasspathContainerConfiguration conf = container.getConf();
IFile virtualIvyFile = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/AdvancedSetupTab.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/AdvancedSetupTab.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/AdvancedSetupTab.java
index c368c74..ad29bd6 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/AdvancedSetupTab.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/AdvancedSetupTab.java
@@ -53,4 +53,4 @@ public class AdvancedSetupTab extends AbstractSetupTab {
return advancedSetupEditor;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/ConfTableViewer.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/ConfTableViewer.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/ConfTableViewer.java
index d9e9092..9eb50eb 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/ConfTableViewer.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/ConfTableViewer.java
@@ -18,8 +18,7 @@
package org.apache.ivyde.internal.eclipse.ui;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.List;
import org.apache.ivy.core.module.descriptor.Configuration;
@@ -45,7 +44,7 @@ public class ConfTableViewer extends Composite {
private CheckboxTableViewer confTableViewer;
- private final List listeners = new ArrayList();
+ private final List<ConfTableListener> listeners = new ArrayList<>();
private final Button selectAll;
@@ -191,22 +190,21 @@ public class ConfTableViewer extends Composite {
confTableViewer.setInput(orderedConfigurations);
}
- public void init(List/* <String> */confs) {
+ public void init(List<String> confs) {
boolean enabled;
if (confs.size() == 1 && "*".equals(confs.get(0))) {
enabled = true;
selectAll.setSelection(true);
- for (int i = 0; i < orderedConfigurations.length; i++) {
- confTableViewer.setChecked(orderedConfigurations[i], true);
+ for (Configuration orderedConfiguration : orderedConfigurations) {
+ confTableViewer.setChecked(orderedConfiguration, true);
}
} else {
enabled = false;
selectAll.setSelection(false);
- for (int i = 0; i < confs.size(); i++) {
- String c = (String) confs.get(i);
- for (int j = 0; j < orderedConfigurations.length; j++) {
- if (orderedConfigurations[j].getName().equals(c)) {
- confTableViewer.setChecked(orderedConfigurations[j], true);
+ for (String conf : confs) {
+ for (Configuration orderedConfiguration : orderedConfigurations) {
+ if (orderedConfiguration.getName().equals(conf)) {
+ confTableViewer.setChecked(orderedConfiguration, true);
break;
}
}
@@ -217,15 +215,13 @@ public class ConfTableViewer extends Composite {
updateUpDownEnableButtons(enabled);
}
- public List getSelectedConfigurations() {
+ public List<String> getSelectedConfigurations() {
if (selectAll.getSelection()) {
- return Arrays.asList(new String[] {"*"});
+ return Collections.singletonList("*");
}
- Object[] confs = confTableViewer.getCheckedElements();
- List confList = new ArrayList();
- for (int i = 0; i < confs.length; i++) {
- Configuration c = (Configuration) confs[i];
- confList.add(c.getName());
+ List<String> confList = new ArrayList<>();
+ for (Object conf : confTableViewer.getCheckedElements()) {
+ confList.add(((Configuration) conf).getName());
}
return confList;
}
@@ -245,7 +241,7 @@ public class ConfTableViewer extends Composite {
}
public interface ConfTableListener {
- void confTableUpdated(List confs);
+ void confTableUpdated(List<String> confs);
}
public void addListener(ConfTableListener listener) {
@@ -260,11 +256,10 @@ public class ConfTableViewer extends Composite {
}
}
- void confTableUpdated() {
+ private void confTableUpdated() {
synchronized (listeners) {
- Iterator it = listeners.iterator();
- while (it.hasNext()) {
- ((ConfTableListener) it.next()).confTableUpdated(getSelectedConfigurations());
+ for (ConfTableListener listener : listeners) {
+ listener.confTableUpdated(getSelectedConfigurations());
}
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/FileListEditor.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/FileListEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/FileListEditor.java
index e91c6f7..e642f70 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/FileListEditor.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/FileListEditor.java
@@ -41,7 +41,7 @@ public class FileListEditor extends Composite {
private final ListViewer filelist;
- private List/* <String> */files = new ArrayList();
+ private List<String> files = new ArrayList<>();
private Button edit;
@@ -120,8 +120,9 @@ public class FileListEditor extends Composite {
remove.setText("Remove");
remove.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
remove.addSelectionListener(new SelectionAdapter() {
+ @SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent e) {
- List selection = ((IStructuredSelection) filelist.getSelection()).toList();
+ List<String> selection = ((IStructuredSelection) filelist.getSelection()).toList();
files.removeAll(selection);
filelist.refresh();
fileListUpdated();
@@ -136,7 +137,7 @@ public class FileListEditor extends Composite {
up.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int i = getSelectedConfigurationIndex();
- String f = (String) files.get(i);
+ String f = files.get(i);
files.set(i, files.get(i - 1));
files.set(i - 1, f);
filelist.refresh();
@@ -151,7 +152,7 @@ public class FileListEditor extends Composite {
down.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int i = getSelectedConfigurationIndex();
- String f = (String) files.get(i);
+ String f = files.get(i);
files.set(i, files.get(i + 1));
files.set(i + 1, f);
filelist.refresh();
@@ -168,12 +169,7 @@ public class FileListEditor extends Composite {
}
private int getSelectedConfigurationIndex(String file) {
- for (int i = 0; i < files.size(); i++) {
- if (files.get(i) == file) {
- return i;
- }
- }
- return -1;
+ return files.indexOf(file);
}
private void updateUpDownEnableButtons(boolean enabled) {
@@ -183,7 +179,7 @@ public class FileListEditor extends Composite {
down.setEnabled(enabled && selected && i < files.size() - 1);
}
- public void init(List/* <String> */files) {
+ public void init(List<String> files) {
this.files = files;
filelist.setInput(files);
remove.setEnabled(false);
@@ -194,7 +190,7 @@ public class FileListEditor extends Composite {
// to be override to listen to changes
}
- public List getFiles() {
+ public List<String> getFiles() {
return files;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/IvyFilePathText.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/IvyFilePathText.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/IvyFilePathText.java
index 17764f1..2299118 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/IvyFilePathText.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/IvyFilePathText.java
@@ -20,7 +20,6 @@ package org.apache.ivyde.internal.eclipse.ui;
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivyde.eclipse.IvyDEException;
@@ -47,7 +46,7 @@ public class IvyFilePathText extends PathEditor {
private IvyDEException ivyXmlError;
- private final List listeners = new ArrayList();
+ private final List<IvyXmlPathListener> listeners = new ArrayList<>();
private FieldDecoration errorDecoration;
@@ -124,9 +123,8 @@ public class IvyFilePathText extends PathEditor {
void ivyXmlPathUpdated() {
synchronized (listeners) {
- Iterator it = listeners.iterator();
- while (it.hasNext()) {
- ((IvyXmlPathListener) it.next()).ivyXmlPathUpdated(ivyFilePathText.getText());
+ for (IvyXmlPathListener listener : listeners) {
+ listener.ivyXmlPathUpdated(ivyFilePathText.getText());
}
}
}
[3/3] ant-ivyde git commit: Generics, JUnit 4
Posted by gi...@apache.org.
Generics, JUnit 4
Project: http://git-wip-us.apache.org/repos/asf/ant-ivyde/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivyde/commit/f808b0b4
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivyde/tree/f808b0b4
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivyde/diff/f808b0b4
Branch: refs/heads/master
Commit: f808b0b4f178c2c77a8fe03b22e3e4299a83cb4b
Parents: ca17491
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Mon Nov 6 00:00:03 2017 +0100
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Mon Nov 6 00:00:03 2017 +0100
----------------------------------------------------------------------
org.apache.ivyde.eclipse/.classpath | 2 +-
.../completion/IvyCodeCompletionProcessor.java | 24 ++--
.../common/ivyfile/IvyFileResourceListener.java | 14 +-
.../common/ivyfile/IvyModuleDescriptorFile.java | 22 ++-
.../ivyfile/IvyModuleDescriptorModel.java | 102 +++++++-------
.../common/ivysettings/IvySettingsFile.java | 12 +-
.../common/ivysettings/IvySettingsModel.java | 47 +++----
.../org/apache/ivyde/common/model/IvyFile.java | 10 +-
.../org/apache/ivyde/common/model/IvyModel.java | 27 ++--
.../org/apache/ivyde/common/model/IvyTag.java | 31 ++---
.../apache/ivyde/eclipse/NopMessageLogger.java | 6 +-
.../apache/ivyde/eclipse/cp/ClasspathSetup.java | 6 +-
.../cp/IvyClasspathContainerConfiguration.java | 8 +-
.../eclipse/cp/IvyClasspathContainerHelper.java | 11 +-
.../apache/ivyde/eclipse/cp/SettingsSetup.java | 15 +-
.../ivyde/internal/eclipse/CachedIvy.java | 9 +-
.../ivyde/internal/eclipse/IvyDEMessage.java | 2 +-
.../IvyDERuntimeClasspathEntryResolver.java | 33 ++---
.../ivyde/internal/eclipse/IvyNature.java | 10 +-
.../ivyde/internal/eclipse/IvyPlugin.java | 32 ++---
.../cpcontainer/ClasspathEntriesResolver.java | 21 +--
.../IvyClasspathContainerConfAdapter.java | 6 +-
.../cpcontainer/IvyClasspathContainerImpl.java | 8 +-
.../IvyClasspathContainerMapper.java | 17 +--
.../IvyClasspathContainerSerializer.java | 35 +++--
.../cpcontainer/IvyClasspathContainerState.java | 2 +-
.../cpcontainer/IvyClasspathInitializer.java | 17 ++-
.../eclipse/cpcontainer/IvyClasspathUtil.java | 19 ++-
.../eclipse/cpcontainer/IvydeContainerPage.java | 22 +--
.../eclipse/handlers/AbstractIvyDEHandler.java | 49 +++----
.../eclipse/handlers/AddIvyNatureHandler.java | 12 +-
.../eclipse/handlers/OpenIvyFileHandler.java | 10 +-
.../eclipse/handlers/RefreshHandler.java | 6 +-
.../eclipse/handlers/ReloadSettingsHandler.java | 6 +-
.../handlers/RemoveIvyNatureHandler.java | 12 +-
.../eclipse/handlers/ResolveAllHandler.java | 12 +-
.../eclipse/handlers/ResolveHandler.java | 6 +-
.../ViewReverseDependenciesHandler.java | 7 +-
.../internal/eclipse/resolve/IvyResolveJob.java | 60 +++-----
.../internal/eclipse/resolve/IvyResolver.java | 32 ++---
.../eclipse/retrieve/RetrieveSetupManager.java | 25 ++--
.../retrieve/StandaloneRetrieveSerializer.java | 17 +--
.../retrieve/StandaloneRetrieveSetupState.java | 2 +-
.../eclipse/revdepexplorer/IvyUtil.java | 34 ++---
.../MultiRevDependencyDescriptor.java | 56 +++-----
.../eclipse/revdepexplorer/SyncIvyFilesJob.java | 39 +++---
.../internal/eclipse/ui/AdvancedSetupTab.java | 2 +-
.../internal/eclipse/ui/ConfTableViewer.java | 41 +++---
.../internal/eclipse/ui/FileListEditor.java | 20 ++-
.../internal/eclipse/ui/IvyFilePathText.java | 8 +-
.../eclipse/ui/NewIvyDEContainerWizard.java | 5 +-
.../eclipse/ui/SettingsSetupEditor.java | 8 +-
.../internal/eclipse/ui/console/IvyConsole.java | 12 +-
.../ui/console/IvyConsoleFilterAction.java | 23 ++--
.../eclipse/ui/console/IvyDEMessageLogger.java | 6 +-
.../ui/editors/IvyModuleDescriptorEditor.java | 15 +-
.../eclipse/ui/editors/IvySettingsEditor.java | 14 +-
.../eclipse/ui/editors/xml/ColorManager.java | 19 ++-
.../ui/editors/xml/EclipseIvyModelSettings.java | 5 +-
.../eclipse/ui/menu/CleanCacheAction.java | 11 +-
.../ui/menu/IvyMenuContributionItem.java | 136 ++++++++-----------
.../eclipse/ui/menu/RetrieveAction.java | 2 +-
.../ui/preferences/IvyDEProjectPreferences.java | 24 ++--
.../ui/preferences/PreferenceConstants.java | 9 +-
.../internal/eclipse/ui/views/ReportView.java | 6 +-
.../ui/views/ReverseDependencyExplorerView.java | 14 +-
.../workspaceresolver/IvyDEStrategy.java | 20 +--
.../workspaceresolver/WorkspaceResolver.java | 3 +-
.../WorkspaceResourceChangeListener.java | 54 +++-----
.../common/ivyfile/IvyFileUpdaterTest.java | 16 ++-
.../ivyde/common/model/IvyFileUtilTest.java | 57 +++++---
71 files changed, 651 insertions(+), 834 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/.classpath
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/.classpath b/org.apache.ivyde.eclipse/.classpath
index 74f2f57..09c139e 100644
--- a/org.apache.ivyde.eclipse/.classpath
+++ b/org.apache.ivyde.eclipse/.classpath
@@ -21,7 +21,7 @@
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java
index 958f144..9859e57 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java
@@ -20,7 +20,6 @@ package org.apache.ivyde.common.completion;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -47,7 +46,7 @@ public class IvyCodeCompletionProcessor {
*/
public CodeCompletionProposal[] computeCompletionProposals(IvyFile ivyfile, int caretOffset) {
model.refreshIfNeeded(ivyfile);
- List propList = new ArrayList();
+ List<CodeCompletionProposal> propList = new ArrayList<>();
if (ivyfile.inTag()) {
String tagName = ivyfile.getTagName();
if (ivyfile.readyForValue()) {
@@ -60,8 +59,7 @@ public class IvyCodeCompletionProcessor {
computeStructureProposals(ivyfile, propList, caretOffset);
}
- return (CodeCompletionProposal[]) propList.toArray(
- new CodeCompletionProposal[propList.size()]);
+ return propList.toArray(new CodeCompletionProposal[propList.size()]);
}
/**
@@ -73,7 +71,7 @@ public class IvyCodeCompletionProcessor {
* @param propList List<CodeCompletionProposal>
* @param caretOffset ditto
*/
- private void computeTagAttributeProposals(String tagName, IvyFile ivyfile, List propList,
+ private void computeTagAttributeProposals(String tagName, IvyFile ivyfile, List<CodeCompletionProposal> propList,
int caretOffset) {
String qualifier = ivyfile.getQualifier();
int qlen = qualifier.length();
@@ -90,11 +88,9 @@ public class IvyCodeCompletionProcessor {
return;
}
errorMessage = null;
- List atts = tag.getAttributes();
- Map existingAtts = ivyfile.getAllAttsValues();
+ Map<String, String> existingAtts = ivyfile.getAllAttsValues();
// Loop through all proposals
- for (Iterator iter = atts.iterator(); iter.hasNext();) {
- IvyTagAttribute att = (IvyTagAttribute) iter.next();
+ for (IvyTagAttribute att : tag.getAttributes()) {
if (att.getName().startsWith(qualifier)
&& !existingAtts.containsKey(att.getName())) {
// Yes -- compute whole proposal text
@@ -120,7 +116,7 @@ public class IvyCodeCompletionProcessor {
* @param propList List<CodeCompletionProposal>
* @param caretOffset ditto
*/
- private void computeValueProposals(String tagName, IvyFile ivyfile, List propList,
+ private void computeValueProposals(String tagName, IvyFile ivyfile, List<CodeCompletionProposal> propList,
int caretOffset) {
String parent = null;
String tag = ivyfile.getTagName();
@@ -157,7 +153,7 @@ public class IvyCodeCompletionProcessor {
* @param propList List<CodeCompletionProposal>
* @param caretOffset int
*/
- private void computeStructureProposals(IvyFile ivyfile, List propList, int caretOffset) {
+ private void computeStructureProposals(IvyFile ivyfile, List<CodeCompletionProposal> propList, int caretOffset) {
String parent = ivyfile.getParentTagName();
String qualifier = ivyfile.getQualifier();
int qlen = qualifier.length();
@@ -183,7 +179,7 @@ public class IvyCodeCompletionProcessor {
}
}
- List childs = null;
+ List<IvyTag> childs = null;
if (parent != null) {
String parentParent = ivyfile.getParentTagName(ivyfile.getStringIndexBackward("<"
@@ -199,9 +195,7 @@ public class IvyCodeCompletionProcessor {
childs = Collections.singletonList(model.getRootIvyTag());
}
errorMessage = null;
- for (Iterator iter = childs.iterator(); iter.hasNext();) {
- IvyTag child = (IvyTag) iter.next();
-
+ for (IvyTag child : childs) {
// Check if proposal matches qualifier
if (child.getStartTag().startsWith(qualifier)) {
for (Proposal prop : child.getProposals()) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
index b191369..ef0455e 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
@@ -18,10 +18,9 @@
package org.apache.ivyde.common.ivyfile;
import java.io.File;
-import java.util.Iterator;
-import java.util.List;
import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
@@ -67,15 +66,12 @@ public class IvyFileResourceListener implements IResourceChangeListener {
if (javaProject == null) {
return;
}
- List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper
- .getContainers(javaProject);
- Iterator containerIter = containers.iterator();
- while (containerIter.hasNext()) {
- IvyClasspathContainerImpl container = (IvyClasspathContainerImpl) containerIter.next();
+ for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(javaProject)) {
+ IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container;
try {
- File containerIvyFile = container.getState().getIvyFile();
+ File containerIvyFile = ivycp.getState().getIvyFile();
if (containerIvyFile.equals(resourceFile.getLocation().toFile())) {
- container.launchResolve(false, null);
+ ivycp.launchResolve(false, null);
return;
}
} catch (IvyDEException e) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java
index 47d6277..16268aa 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java
@@ -45,23 +45,20 @@ public class IvyModuleDescriptorFile extends IvyFile {
}
public String[] getConfigurationNames() {
- Pattern p = CONFIGURATIONS_START_PATTERN;
- Matcher m = p.matcher(getDoc());
+ Matcher m = CONFIGURATIONS_START_PATTERN.matcher(getDoc());
if (m.find()) {
int start = m.end();
- p = CONFIGURATIONS_END_PATTERN;
- m = p.matcher(getDoc());
+ m = CONFIGURATIONS_END_PATTERN.matcher(getDoc());
int end = getDoc().length();
if (m.find(start)) {
end = m.start();
}
- p = CONF_PATTERN;
- m = p.matcher(getDoc());
- List ret = new ArrayList();
+ m = CONF_PATTERN.matcher(getDoc());
+ List<String> ret = new ArrayList<>();
for (boolean found = m.find(start); found && m.end() < end; found = m.find()) {
ret.add(m.group(1));
}
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
} else {
return new String[] {"default"};
}
@@ -77,13 +74,12 @@ public class IvyModuleDescriptorFile extends IvyFile {
}
public String getDependencyOrganisation() {
- Map otherAttValues = getAllAttsValues();
+ Map<String, String> otherAttValues = getAllAttsValues();
return getDependencyOrganisation(otherAttValues);
}
- public String getDependencyOrganisation(Map otherAttValues) {
- return otherAttValues != null && otherAttValues.get("org") != null ? (String) otherAttValues
- .get("org")
- : getOrganisation();
+ public String getDependencyOrganisation(Map<String, String> otherAttValues) {
+ return (otherAttValues != null && otherAttValues.get("org") != null)
+ ? otherAttValues.get("org") : getOrganisation();
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java
index a51f5f7..631f521 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java
@@ -20,7 +20,10 @@ package org.apache.ivyde.common.ivyfile;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -101,13 +104,13 @@ public class IvyModuleDescriptorModel extends IvyModel {
"the name of the organisation of the parent module.", false);
parentOrgAtt.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- List ret = listDependencyTokenValues(att.getName(), ivyFile);
+ List<String> ret = listDependencyTokenValues(att.getName(), ivyFile);
ret.add(getSettings().getDefaultOrganization());
String org = ((IvyModuleDescriptorFile) ivyFile).getOrganisation();
if (org != null) {
ret.add(org);
}
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
}
});
extend.addAttribute(parentOrgAtt);
@@ -115,8 +118,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
"the module name of the parent module", true);
parentModuleAtt.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- List ret = listDependencyTokenValues(att.getName(), ivyFile);
- return (String[]) ret.toArray(new String[ret.size()]);
+ List<String> ret = listDependencyTokenValues(att.getName(), ivyFile);
+ return ret.toArray(new String[ret.size()]);
}
});
extend.addAttribute(parentModuleAtt);
@@ -158,9 +161,9 @@ public class IvyModuleDescriptorModel extends IvyModel {
child.addAttribute(new IvyTagAttribute("url", "an url pointing to the repository.", true,
new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- Map allAttsValues = ivyFile.getAllAttsValues();
+ Map<String, String> allAttsValues = ivyFile.getAllAttsValues();
if (allAttsValues != null) {
- String name = (String) allAttsValues.get("name");
+ String name = allAttsValues.get("name");
if ("ibiblio".equals(name)) {
return new String[] {"http://www.ibiblio.org/maven/"};
} else if ("ivyrep".equals(name)) {
@@ -175,9 +178,9 @@ public class IvyModuleDescriptorModel extends IvyModel {
"an ivy pattern to find modules on this repository", false);
reppatternTagAttribute.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- Map allAttsValues = ivyFile.getAllAttsValues();
+ Map<String, String> allAttsValues = ivyFile.getAllAttsValues();
if (allAttsValues != null) {
- String name = (String) allAttsValues.get("name");
+ String name = allAttsValues.get("name");
if ("ibiblio".equals(name)) {
return new String[] {"[module]/[type]s/[artifact]-[revision].[ext]"};
} else if ("ivyrep".equals(name)) {
@@ -259,7 +262,7 @@ public class IvyModuleDescriptorModel extends IvyModel {
});
conf.addAttribute(deprecatedTagAttribute);
configurations.addChildIvyTag(conf);
- List allConf = new ArrayList();
+ List<IvyTag> allConf = new ArrayList<>();
allConf.add(conf);
addTag(conf.getName(), allConf);
ivyTag.addChildIvyTag(configurations);
@@ -302,8 +305,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
public String[] getPossibleValuesForAttribute(String att, IvyFile ivyfile) {
String[] r = super.getPossibleValuesForAttribute(att, ivyfile);
if (r == null) { // listing can be used even for extra attributes
- List ret = listDependencyTokenValues(att, ivyfile);
- return (String[]) ret.toArray(new String[ret.size()]);
+ List<String> ret = listDependencyTokenValues(att, ivyfile);
+ return ret.toArray(new String[ret.size()]);
} else {
return r;
}
@@ -313,13 +316,13 @@ public class IvyModuleDescriptorModel extends IvyModel {
"the name of the organisation of the dependency.", false);
orgAtt.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- List ret = listDependencyTokenValues(att.getName(), ivyFile);
+ List<String> ret = listDependencyTokenValues(att.getName(), ivyFile);
ret.add(getSettings().getDefaultOrganization());
String org = ((IvyModuleDescriptorFile) ivyFile).getOrganisation();
if (org != null) {
ret.add(org);
}
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
}
});
@@ -328,8 +331,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
true);
module.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- List ret = listDependencyTokenValues(att.getName(), ivyFile);
- return (String[]) ret.toArray(new String[ret.size()]);
+ List<String> ret = listDependencyTokenValues(att.getName(), ivyFile);
+ return ret.toArray(new String[ret.size()]);
}
});
dependency.addAttribute(module);
@@ -337,8 +340,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
"the branch of the dependency. \nDo not set if not needed.", false);
branch.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- List ret = listDependencyTokenValues(att.getName(), ivyFile);
- return (String[]) ret.toArray(new String[ret.size()]);
+ List<String> ret = listDependencyTokenValues(att.getName(), ivyFile);
+ return ret.toArray(new String[ret.size()]);
}
});
dependency.addAttribute(branch);
@@ -348,9 +351,9 @@ public class IvyModuleDescriptorModel extends IvyModel {
+ " matching revision.", true);
rev.setValueProvider(new IValueProvider() {
public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
- List ret = listDependencyTokenValues(att.getName(), ivyFile);
+ List<String> ret = listDependencyTokenValues(att.getName(), ivyFile);
ret.add("latest.integration");
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
}
});
dependency.addAttribute(rev);
@@ -373,17 +376,17 @@ public class IvyModuleDescriptorModel extends IvyModel {
if (arrowIndex > -1) {
// we are looking for a dep conf
String org = ((IvyModuleDescriptorFile) ivyFile).getDependencyOrganisation();
- Map otherAttValues = ivyFile.getAllAttsValues();
+ Map<String, String> otherAttValues = ivyFile.getAllAttsValues();
if (org != null && otherAttValues != null && otherAttValues.get("name") != null
&& otherAttValues.get("rev") != null) {
otherAttValues.remove("org");
- String branch = (String) otherAttValues.remove("branch");
+ String branch = otherAttValues.remove("branch");
otherAttValues.remove("conf");
otherAttValues.remove("force");
otherAttValues.remove("transitive");
otherAttValues.remove("changing");
- return getDependencyConfs(org, (String) otherAttValues.remove("name"),
- branch, (String) otherAttValues.remove("rev"), otherAttValues,
+ return getDependencyConfs(org, otherAttValues.remove("name"),
+ branch, otherAttValues.remove("rev"), otherAttValues,
qualifier, base, arrowIndex);
}
@@ -409,13 +412,13 @@ public class IvyModuleDescriptorModel extends IvyModel {
for (int i = 0; i < confs.length; i++) {
confs[i] = base + confs[i];
}
- List ret = new ArrayList(Arrays.asList(confs));
+ List<String> ret = new ArrayList<>(Arrays.asList(confs));
ret.add("*");
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
}
private String[] getDependencyConfs(String org, String name, String branch, String rev,
- Map otherAtts, String qualifier, StringBuffer base, int arrowIndex) {
+ Map<String, String> otherAtts, String qualifier, StringBuffer base, int arrowIndex) {
Ivy ivy = getIvy();
if (ivy == null) {
return null;
@@ -431,8 +434,7 @@ public class IvyModuleDescriptorModel extends IvyModel {
qualifier = qualifier.substring(1);
}
ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
- ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev,
- otherAtts);
+ ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev, otherAtts);
DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false);
try {
DependencyResolver resolver = ivy.getSettings().getResolver(mrid);
@@ -447,9 +449,9 @@ public class IvyModuleDescriptorModel extends IvyModel {
for (int i = 0; i < confs.length; i++) {
confs[i] = base + confs[i];
}
- List ret = new ArrayList(Arrays.asList(confs));
+ List<String> ret = new ArrayList<>(Arrays.asList(confs));
ret.add("*");
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
} catch (ParseException e) {
getSettings().logError("The dependencies of " + mrid + " could not be parsed",
e);
@@ -472,7 +474,7 @@ public class IvyModuleDescriptorModel extends IvyModel {
Ivy ivy = getIvy();
int[] indexes = ivyFile.getParentTagIndex();
if (indexes != null && ivy != null) {
- Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
+ Map<String, String> otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
String org = ((IvyModuleDescriptorFile) ivyFile)
.getDependencyOrganisation(otherAttValues);
if (org != null && otherAttValues != null
@@ -491,8 +493,7 @@ public class IvyModuleDescriptorModel extends IvyModel {
ResolveData data = new ResolveData(ivy.getResolveEngine(),
new ResolveOptions());
ModuleRevisionId mrid = ModuleRevisionId.newInstance(org,
- (String) otherAttValues.get("name"), (String) otherAttValues
- .get("rev"));
+ otherAttValues.get("name"), otherAttValues.get("rev"));
DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(
mrid, false);
try {
@@ -502,9 +503,9 @@ public class IvyModuleDescriptorModel extends IvyModel {
for (int i = 0; i < confs.length; i++) {
confs[i] = base + confs[i];
}
- List ret = new ArrayList(Arrays.asList(confs));
+ List<String> ret = new ArrayList<>(Arrays.asList(confs));
ret.add("*");
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
} catch (ParseException e) {
getSettings().logError(
"The dependencies of " + mrid + " could not be parsed", e);
@@ -533,7 +534,7 @@ public class IvyModuleDescriptorModel extends IvyModel {
if (indexes == null) {
return new String[] {"*"};
}
- Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
+ Map<String, String> otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
String org = ((IvyModuleDescriptorFile) ivyFile)
.getDependencyOrganisation(otherAttValues);
if (org == null || otherAttValues == null || otherAttValues.get("name") == null
@@ -543,14 +544,14 @@ public class IvyModuleDescriptorModel extends IvyModel {
ResolveData data = new ResolveData(ivy.getResolveEngine(),
new ResolveOptions());
ModuleRevisionId mrid = ModuleRevisionId.newInstance(org,
- (String) otherAttValues.get("name"), (String) otherAttValues.get("rev"));
+ otherAttValues.get("name"), otherAttValues.get("rev"));
DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false);
try {
String[] confs = ivy.getSettings().getResolver(mrid)
.getDependency(ddd, data).getDescriptor().getConfigurationsNames();
- List ret = new ArrayList(Arrays.asList(confs));
+ List<String> ret = new ArrayList<>(Arrays.asList(confs));
ret.add("*");
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
} catch (ParseException e) {
getSettings().logError("The dependencies of " + mrid
+ " could not be parsed", e);
@@ -561,12 +562,12 @@ public class IvyModuleDescriptorModel extends IvyModel {
conf3.addChildIvyTag(mapped);
addTag(mapped);
- String[] matcherNames = new String[0];
+ Collection<String> matcherNames = Collections.emptySet();
Ivy ivy = getIvy();
if (ivy != null) {
- matcherNames = ivy.getSettings().getMatcherNames().toArray(new String[0]);
+ matcherNames = ivy.getSettings().getMatcherNames();
}
- ListValueProvider matcherNamesProvider = new ListValueProvider(matcherNames);
+ ListValueProvider matcherNamesProvider = new ListValueProvider(matcherNames.toArray(new String[matcherNames.size()]));
IvyTag artifact2 = new IvyTag("artifact", "defines artifacts restriction \n"
+ "use only if you do not control dependency ivy file");
@@ -698,8 +699,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
return "ivy-module";
}
- List listDependencyTokenValues(String att, IvyFile ivyfile) {
- Map allAttsValues = ivyfile.getAllAttsValues();
+ private List<String> listDependencyTokenValues(String att, IvyFile ivyfile) {
+ Map<String, String> allAttsValues = ivyfile.getAllAttsValues();
String org = ((IvyModuleDescriptorFile) ivyfile).getOrganisation();
if (org != null && !allAttsValues.containsKey("org")) {
allAttsValues.put("org", org);
@@ -707,8 +708,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
return listDependencyTokenValues(att, allAttsValues);
}
- private List listDependencyTokenValues(String att, Map otherAttValues) {
- List ret = new ArrayList();
+ private List<String> listDependencyTokenValues(String att, Map<String, String> otherAttValues) {
+ List<String> ret = new ArrayList<>();
Ivy ivy = getIvy();
if (ivy != null) {
replaceToken(otherAttValues, "org", IvyPatternHelper.ORGANISATION_KEY);
@@ -722,7 +723,10 @@ public class IvyModuleDescriptorModel extends IvyModel {
String stdAtt = standardiseDependencyAttribute(att);
otherAttValues.remove(stdAtt);
- String[] revs = ivy.listTokenValues(stdAtt, otherAttValues);
+ // transform otherAttValues into Map required by Ivy
+ Map<String, Object> ivyAttrs = new HashMap<>();
+ ivyAttrs.putAll(otherAttValues);
+ String[] revs = ivy.listTokenValues(stdAtt, ivyAttrs);
if (revs != null) {
ret.addAll(Arrays.asList(revs));
}
@@ -730,8 +734,8 @@ public class IvyModuleDescriptorModel extends IvyModel {
return ret;
}
- private void replaceToken(Map otherAttValues, String oldToken, String newToken) {
- String val = (String) otherAttValues.remove(oldToken);
+ private void replaceToken(Map<String, String> otherAttValues, String oldToken, String newToken) {
+ String val = otherAttValues.remove(oldToken);
if (val != null) {
otherAttValues.put(newToken, val);
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java
index c3e3711..8636859 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java
@@ -54,7 +54,7 @@ public class IvySettingsFile extends IvyFile {
}
public URL[] getClasspathUrls() {
- List urls = new ArrayList();
+ List<URL> urls = new ArrayList<>();
Matcher m = CLASSPATH_URL_PATTERN.matcher(getDoc());
while (m.find()) {
try {
@@ -75,11 +75,11 @@ public class IvySettingsFile extends IvyFile {
}
}
}
- return (URL[]) urls.toArray(new URL[urls.size()]);
+ return urls.toArray(new URL[urls.size()]);
}
private String substitute(String str) {
- Map variables = new HashMap();
+ Map<String, String> variables = new HashMap<>();
if (file.getParentFile() != null) {
URI settingsDirUri = file.getParentFile().toURI();
variables.put("ivy.settings.dir", settingsDirUri.toString());
@@ -87,8 +87,8 @@ public class IvySettingsFile extends IvyFile {
return IvyPatternHelper.substituteVariables(str, variables);
}
- public Map/* <String,String> */getTypedefs() {
- Map p = getDefaultTypedefs();
+ public Map<Object, Object> getTypedefs() {
+ Map<Object, Object> p = getDefaultTypedefs();
Matcher m = TYPEDEF_PATTERN.matcher(getDoc());
while (m.find()) {
p.put(substitute(m.group(1)), substitute(m.group(2)));
@@ -96,7 +96,7 @@ public class IvySettingsFile extends IvyFile {
return p;
}
- public static Map/* <String,String> */getDefaultTypedefs() {
+ public static Map<Object, Object> getDefaultTypedefs() {
Properties p = new Properties();
try {
p.load(XmlSettingsParser.class.getResourceAsStream("typedef.properties"));
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java
index b2baa53..7ed1af4 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java
@@ -21,7 +21,6 @@ import java.io.File;
import java.lang.reflect.Method;
import java.net.URLClassLoader;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -50,7 +49,7 @@ public class IvySettingsModel extends IvyModel {
private String loaded = null;
private final File file;
private ClassLoader cl;
- private Map typedefClasses;
+ private Map<String, Class<?>> typedefClasses;
public IvySettingsModel(IvyModelSettings settings, File file) {
super(settings);
@@ -225,26 +224,23 @@ public class IvySettingsModel extends IvyModel {
addTag(ivyTag);
}
- private void addTypedefChildren(IvyTag tag, Map children) {
- for (Iterator it = children.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
- Class clazz = (Class) entry.getValue();
- String childName = (String) entry.getKey();
- tag.addChildIvyTag(typedefedTag(childName, clazz));
+ private void addTypedefChildren(IvyTag tag, Map<String, Class<?>> children) {
+ for (Entry<String, Class<?>> entry : children.entrySet()) {
+ tag.addChildIvyTag(typedefedTag(entry.getKey(), entry.getValue()));
}
}
- private IvyTag typedefedTag(String tagName, final Class clazz) {
- IvyTag child = new IvyTag(tagName) {
+ private IvyTag typedefedTag(String tagName, final Class<?> clazz) {
+ return new IvyTag(tagName) {
// we lazy load children, since we may have a loop in children (chain can contain chain)
// causing a stack overflow if we try to recursively add typedefed children
private boolean init = false;
- public List getAttributes() {
+ public List<IvyTagAttribute> getAttributes() {
init();
return super.getAttributes();
}
- public List getChilds() {
+ public List<IvyTag> getChilds() {
init();
return super.getChilds();
}
@@ -307,10 +303,9 @@ public class IvySettingsModel extends IvyModel {
}
}
};
- return child;
}
- protected boolean isSupportedChildType(Class type) {
+ protected boolean isSupportedChildType(Class<?> type) {
return !Void.TYPE.equals(type)
&& !String.class.equals(type)
&& !Character.class.equals(type) && !char.class.equals(type)
@@ -321,7 +316,7 @@ public class IvySettingsModel extends IvyModel {
&& !Class.class.equals(type);
}
- private boolean isSupportedAttributeType(Class type) {
+ private boolean isSupportedAttributeType(Class<?> type) {
if (String.class.isAssignableFrom(type)
|| Character.class.equals(type) || char.class.equals(type)
|| Boolean.class.equals(type) || boolean.class.equals(type)
@@ -348,17 +343,16 @@ public class IvySettingsModel extends IvyModel {
}
}
- private Map/*<String,Class>*/ getTypedefClasses(IvySettingsFile file, ClassLoader cl) {
- Map typedefs = file.getTypedefs();
+ private Map<String, Class<?>> getTypedefClasses(IvySettingsFile file, ClassLoader cl) {
+ Map<Object, Object> typedefs = file.getTypedefs();
return getTypedefClasses(cl, typedefs);
}
- private Map getTypedefClasses(ClassLoader cl, Map typedefs) {
- Map/*<String,Class>*/ classes = new LinkedHashMap();
- for (Iterator it = typedefs.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
+ private Map<String, Class<?>> getTypedefClasses(ClassLoader cl, Map<Object, Object> typedefs) {
+ Map<String, Class<?>> classes = new LinkedHashMap<>();
+ for (Entry<Object, Object> entry : typedefs.entrySet()) {
try {
- classes.put(entry.getKey(), cl.loadClass((String) entry.getValue()));
+ classes.put((String) entry.getKey(), cl.loadClass((String) entry.getValue()));
} catch (ClassNotFoundException e) {
// ignored
}
@@ -366,11 +360,10 @@ public class IvySettingsModel extends IvyModel {
return classes;
}
- private Map/*<String,Class>*/ getChildClasses(Map/*<String,Class>*/ classes, Class type) {
- Map/*<String,Class>*/ childClasses = new LinkedHashMap();
- for (Iterator it = classes.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
- if (type.isAssignableFrom((Class) entry.getValue())) {
+ private Map<String, Class<?>> getChildClasses(Map<String, Class<?>> classes, Class<?> type) {
+ Map<String, Class<?>> childClasses = new LinkedHashMap<>();
+ for (Entry<String, Class<?>> entry : classes.entrySet()) {
+ if (type.isAssignableFrom(entry.getValue())) {
childClasses.put(entry.getKey(), entry.getValue());
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java
index 9a73c68..88273f7 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java
@@ -143,12 +143,12 @@ public abstract class IvyFile {
return doc.indexOf(string, documentOffset);
}
- public Map getAllAttsValues() {
+ public Map<String, String> getAllAttsValues() {
return getAllAttsValues(currentOffset);
}
- public Map getAllAttsValues(int documentOffset) {
- Map result = new HashMap();
+ public Map<String, String> getAllAttsValues(int documentOffset) {
+ Map<String, String> result = new HashMap<>();
int start = reversed.indexOf('<', getReverseOffset(documentOffset));
if (start != -1) {
@@ -285,7 +285,7 @@ public abstract class IvyFile {
int parentEndTagIndex = -1;
boolean parentEndTagReached = false;
boolean inSimpleTag = false;
- Stack stack = new Stack();
+ Stack<String> stack = new Stack<>();
while (offset > 0) {
char c = doc.charAt(--offset);
if (c == '>' && doc.charAt(offset - 1) != '-') {
@@ -313,7 +313,7 @@ public abstract class IvyFile {
if (doc.charAt(offset + 1) != '!' && doc.charAt(offset + 1) != '?') {
// not a doc tag or xml
if (!stack.isEmpty()) { // we found the closing tag before
- String closedName = (String) stack.peek();
+ String closedName = stack.peek();
if (closedName.equalsIgnoreCase(doc.substring(offset + 1, offset + 1
+ closedName.length()))) {
stack.pop();
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java
index 0b1d8a8..7b6e2d6 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java
@@ -18,8 +18,8 @@
package org.apache.ivyde.common.model;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -27,7 +27,7 @@ import java.util.Properties;
import org.apache.ivy.Ivy;
public abstract class IvyModel {
- private final Map model = new HashMap();
+ private final Map<String, List<IvyTag>> model = new HashMap<>();
private Properties defaults;
@@ -39,18 +39,12 @@ public abstract class IvyModel {
}
public IvyTag getIvyTag(String tagName, String parentName) {
- Object tag = model.get(tagName);
- if (tag instanceof List) {
- List all = (List) tag;
- for (Iterator iter = all.iterator(); iter.hasNext();) {
- IvyTag t = (IvyTag) iter.next();
- if (t.getParent() != null && t.getParent().getName().equals(parentName)) {
- return t;
- }
+ for (IvyTag tag : model.get(tagName)) {
+ if (tag.getParent() != null && tag.getParent().getName().equals(parentName)) {
+ return tag;
}
- return null;
}
- return (IvyTag) tag;
+ return null;
}
private void loadDefaults() {
@@ -77,15 +71,16 @@ public abstract class IvyModel {
return settings;
}
- protected void addTag(String name, List list) {
+ protected void addTag(String name, List<IvyTag> list) {
model.put(name, list);
}
public void addTag(IvyTag ivyTag) {
if (!model.containsKey(ivyTag.getName())) {
- model.put(ivyTag.getName(), ivyTag);
- for (Iterator it = ivyTag.getChilds().iterator(); it.hasNext();) {
- IvyTag child = (IvyTag) it.next();
+ List<IvyTag> list = new ArrayList<>();
+ list.add(ivyTag);
+ model.put(ivyTag.getName(), list);
+ for (IvyTag child : ivyTag.getChilds()) {
addTag(child);
}
} else {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java
index 1a79d2d..1f34749 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java
@@ -36,9 +36,9 @@ public class IvyTag {
private String doc;
- private Map attributes = new HashMap();
+ private final Map<String, IvyTagAttribute> attributes = new HashMap<>();
- private List childs = new ArrayList();
+ private final List<IvyTag> childs = new ArrayList<>();
private boolean allowNoChild = true;
@@ -53,8 +53,8 @@ public class IvyTag {
public IvyTag(String name, IvyTagAttribute[] atts) {
super();
this.name = name;
- for (int i = 0; i < atts.length; i++) {
- addAttribute(atts[i]);
+ for (IvyTagAttribute att : atts) {
+ addAttribute(att);
}
}
@@ -66,8 +66,8 @@ public class IvyTag {
public IvyTag(String name, String doc, IvyTagAttribute[] atts) {
this.name = name;
this.doc = doc;
- for (int i = 0; i < atts.length; i++) {
- addAttribute(atts[i]);
+ for (IvyTagAttribute att : atts) {
+ addAttribute(att);
}
}
@@ -94,11 +94,11 @@ public class IvyTag {
return childs.size() > 0;
}
- public List getAttributes() {
- return new ArrayList(attributes.values());
+ public List<IvyTagAttribute> getAttributes() {
+ return new ArrayList<>(attributes.values());
}
- public List getChilds() {
+ public List<IvyTag> getChilds() {
return childs;
}
@@ -149,7 +149,7 @@ public class IvyTag {
}
public String[] getPossibleValuesForAttribute(String att, IvyFile ivyfile) {
- IvyTagAttribute ivyTagAttribute = (IvyTagAttribute) attributes.get(att);
+ IvyTagAttribute ivyTagAttribute = attributes.get(att);
if (ivyTagAttribute == null) {
return null;
}
@@ -158,13 +158,13 @@ public class IvyTag {
String qualifier = ivyfile.getAttributeValueQualifier();
String[] values = provider.getValuesfor(ivyTagAttribute, ivyfile);
if (values != null) {
- Set ret = new HashSet(values.length);
+ Set<String> ret = new HashSet<>(values.length);
for (String value : values) {
if (value.startsWith(qualifier)) {
ret.add(value);
}
}
- return (String[]) ret.toArray(new String[ret.size()]);
+ return ret.toArray(new String[ret.size()]);
} else {
return null;
}
@@ -175,8 +175,7 @@ public class IvyTag {
}
public String getPossibleDocForValue(String value, IvyFile ivyfile) {
- IvyTagAttribute ivyTagAttribute = (IvyTagAttribute) attributes.get(ivyfile
- .getAttributeName());
+ IvyTagAttribute ivyTagAttribute = attributes.get(ivyfile.getAttributeName());
if (ivyTagAttribute == null) {
return null;
}
@@ -196,7 +195,7 @@ public class IvyTag {
}
public Proposal[] getProposals() {
- List ret = new ArrayList();
+ List<Proposal> ret = new ArrayList<>();
// Yes -- compute whole proposal text
String text = getStartTag() + getEndTag();
// Derive cursor position
@@ -206,7 +205,7 @@ public class IvyTag {
if (allowNoChild && getChilds().size() > 0) {
ret.add(new Proposal("<" + getName() + " />", cursor, getDoc()));
}
- return (Proposal[]) ret.toArray(new Proposal[ret.size()]);
+ return ret.toArray(new Proposal[ret.size()]);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java
index 37a88a2..84934dd 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java
@@ -62,15 +62,15 @@ public class NopMessageLogger implements MessageLogger {
// no nothing
}
- public List getProblems() {
+ public List<String> getProblems() {
return Collections.emptyList();
}
- public List getWarns() {
+ public List<String> getWarns() {
return Collections.emptyList();
}
- public List getErrors() {
+ public List<String> getErrors() {
return Collections.emptyList();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java
index 90fb6ed..b6dfc0a 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java
@@ -24,7 +24,7 @@ public class ClasspathSetup {
private boolean resolveInWorkspace;
- private List/* <String> */acceptedTypes;
+ private List<String> acceptedTypes;
private boolean alphaOrder;
@@ -61,11 +61,11 @@ public class ClasspathSetup {
this.resolveInWorkspace = resolveInWorkspace;
}
- public List getAcceptedTypes() {
+ public List<String> getAcceptedTypes() {
return acceptedTypes;
}
- public void setAcceptedTypes(List acceptedTypes) {
+ public void setAcceptedTypes(List<String> acceptedTypes) {
this.acceptedTypes = acceptedTypes;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java
index 76eebd9..d1e2983 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java
@@ -17,7 +17,7 @@
*/
package org.apache.ivyde.eclipse.cp;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
@@ -37,7 +37,7 @@ public class IvyClasspathContainerConfiguration {
private String ivyXmlPath;
- private List/* <String> */confs = Arrays.asList(new String[] {"*"});
+ private List<String> confs = Collections.singletonList("*");
private SettingsSetup settingsSetup = new SettingsSetup();
@@ -111,11 +111,11 @@ public class IvyClasspathContainerConfiguration {
this.ivyXmlPath = ivyXmlPath;
}
- public List getConfs() {
+ public List<String> getConfs() {
return confs;
}
- public void setConfs(List confs) {
+ public void setConfs(List<String> confs) {
this.confs = confs;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java
index 5f07f24..0d64c52 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java
@@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivyde.internal.eclipse.IvyPlugin;
@@ -56,13 +55,11 @@ public final class IvyClasspathContainerHelper {
if (selection == null) {
return null;
}
- for (@SuppressWarnings("unchecked")
- Iterator<Object> it = selection.iterator(); it.hasNext();) {
- Object element = it.next();
- IvyClasspathContainerImpl cp = (IvyClasspathContainerImpl) IvyPlugin.adapt(element,
+ for (Object element : selection.toList()) {
+ IvyClasspathContainerImpl ivycp = IvyPlugin.adapt(element,
IvyClasspathContainerImpl.class);
- if (cp != null) {
- return cp;
+ if (ivycp != null) {
+ return ivycp;
}
if (element instanceof ClassPathContainer) {
// FIXME: we shouldn't check against internal JDT API but they are not adaptable to
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java
index ae9c0b9..0f86a0d 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java
@@ -18,7 +18,6 @@
package org.apache.ivyde.eclipse.cp;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivyde.eclipse.IvyDEException;
@@ -35,7 +34,7 @@ public class SettingsSetup {
private String ivySettingsPath;
- private List/* <String> */propertyFiles = new ArrayList();
+ private List<String> propertyFiles = new ArrayList<>();
private boolean loadSettingsOnDemand = false;
@@ -67,17 +66,15 @@ public class SettingsSetup {
this.ivySettingsPath = ivySettingsPath;
}
- public List getRawPropertyFiles() {
+ public List<String> getRawPropertyFiles() {
return propertyFiles;
}
- public List getResolvedPropertyFiles() throws IvyDEException {
- List resolvedProps = new ArrayList();
+ public List<String> getResolvedPropertyFiles() throws IvyDEException {
+ List<String> resolvedProps = new ArrayList<>();
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
try {
- Iterator it = propertyFiles.iterator();
- while (it.hasNext()) {
- String propFile = (String) it.next();
+ for (String propFile : propertyFiles) {
String resolvedProp = manager.performStringSubstitution(propFile, false);
resolvedProps.add(resolvedProp);
}
@@ -88,7 +85,7 @@ public class SettingsSetup {
return resolvedProps;
}
- public void setPropertyFiles(List propertyFiles) {
+ public void setPropertyFiles(List<String> propertyFiles) {
this.propertyFiles = propertyFiles;
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java
index 5d2ab2e..ae54c64 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Properties;
import org.apache.ivy.Ivy;
@@ -88,7 +87,7 @@ public abstract class CachedIvy {
protected abstract ResolvedPath getIvyUserDir();
- protected abstract Collection getPropertyFiles() throws IvyDEException;
+ protected abstract Collection<String> getPropertyFiles() throws IvyDEException;
protected abstract boolean isResolveInWorkspace();
@@ -248,14 +247,12 @@ public abstract class CachedIvy {
if (ivyUserDir.isSet()) {
ivySettings.setDefaultIvyUserDir(ivyUserDir.getFile());
}
- Collection propFiles = getPropertyFiles();
+ Collection<String> propFiles = getPropertyFiles();
if (propFiles == null || propFiles.isEmpty()) {
IvyDEMessage.verbose("No property files to load");
} else {
IvyDEMessage.verbose(propFiles.size() + " property file(s) to load");
- Iterator iter = propFiles.iterator();
- while (iter.hasNext()) {
- String file = (String) iter.next();
+ for (String file : propFiles) {
InputStream is;
Path p = new Path(file);
IvyDEMessage.debug("Loading property file " + p);
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java
index 8ad228b..9ec0ed4 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java
@@ -90,7 +90,7 @@ public class IvyDEMessage {
}
}
- public static List getProblems() {
+ public static List<String> getProblems() {
return getLogger().getProblems();
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java
index 8e63c79..d85161c 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java
@@ -18,7 +18,7 @@
package org.apache.ivyde.internal.eclipse;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.apache.ivyde.internal.eclipse.cpcontainer.ClasspathEntriesResolver;
@@ -106,10 +106,9 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr
} else {
cpes = ivycp.getClasspathEntries();
}
- List resolved = new ArrayList(cpes.length);
- List projects = new ArrayList();
- for (int i = 0; i < cpes.length; i++) {
- IClasspathEntry cpe = cpes[i];
+ List<IRuntimeClasspathEntry> resolved = new ArrayList<>(cpes.length);
+ List<IJavaProject> projects = new ArrayList<>();
+ for (IClasspathEntry cpe : cpes) {
if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
IProject p = ResourcesPlugin.getWorkspace().getRoot()
.getProject(cpe.getPath().segment(0));
@@ -120,11 +119,10 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr
.newProjectRuntimeClasspathEntry(jp);
resolved.add(classpath);
IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspathEntry(
- classpath, jp);
- for (int j = 0; j < entries.length; j++) {
- IRuntimeClasspathEntry e = entries[j];
+ classpath, jp);
+ for (IRuntimeClasspathEntry e : entries) {
if (!resolved.contains(e)) {
- resolved.add(entries[j]);
+ resolved.add(e);
}
}
}
@@ -139,7 +137,7 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr
// set classpath property
IRuntimeClasspathEntry[] result = new IRuntimeClasspathEntry[resolved.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = (IRuntimeClasspathEntry) resolved.get(i);
+ result[i] = resolved.get(i);
result[i].setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
}
return result;
@@ -154,16 +152,13 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr
return new IRuntimeClasspathEntry[] {entry};
}
- IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
- IRuntimeClasspathEntry[] entries = entry2.getRuntimeClasspathEntries(null);
- List resolved = new ArrayList();
- for (int i = 0; i < entries.length; i++) {
- IRuntimeClasspathEntry[] temp = JavaRuntime.resolveRuntimeClasspathEntry(entries[i],
- project);
- resolved.addAll(Arrays.asList(temp));
+ IRuntimeClasspathEntry[] entries = ((IRuntimeClasspathEntry2) entry).getRuntimeClasspathEntries(null);
+ List<IRuntimeClasspathEntry> resolved = new ArrayList<>();
+ for (IRuntimeClasspathEntry ent : entries) {
+ IRuntimeClasspathEntry[] temp = JavaRuntime.resolveRuntimeClasspathEntry(ent, project);
+ Collections.addAll(resolved, temp);
}
- return (IRuntimeClasspathEntry[]) resolved.toArray(new IRuntimeClasspathEntry[resolved
- .size()]);
+ return resolved.toArray(new IRuntimeClasspathEntry[resolved.size()]);
}
public IVMInstall resolveVMInstall(IClasspathEntry entry) throws CoreException {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java
index 39a77e7..ee6267c 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java
@@ -50,16 +50,16 @@ public class IvyNature implements IProjectNature {
return;
}
IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
- List newEntries = new ArrayList();
+ List<IClasspathEntry> newEntries = new ArrayList<>();
- for (int i = 0; i < classpathEntries.length; i++) {
- if (!IvyClasspathContainerHelper.isIvyClasspathContainer(classpathEntries[i].getPath())) {
- newEntries.add(classpathEntries[i]);
+ for (IClasspathEntry classpathEntry : classpathEntries) {
+ if (!IvyClasspathContainerHelper.isIvyClasspathContainer(classpathEntry.getPath())) {
+ newEntries.add(classpathEntry);
}
}
if (newEntries.size() != classpathEntries.length) {
- IClasspathEntry[] newClasspathEntries = (IClasspathEntry[]) newEntries
+ IClasspathEntry[] newClasspathEntries = newEntries
.toArray(new IClasspathEntry[newEntries.size()]);
javaProject.setRawClasspath(newClasspathEntries, null);
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java
index ea5dce0..952d88e 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java
@@ -20,8 +20,6 @@ package org.apache.ivyde.internal.eclipse;
import java.io.File;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
@@ -33,7 +31,6 @@ import org.apache.ivyde.eclipse.IvyDEsecurityHelper;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyAttachmentManager;
-import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl;
import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerSerializer;
import org.apache.ivyde.internal.eclipse.resolve.IvyResolveJob;
import org.apache.ivyde.internal.eclipse.retrieve.RetrieveSetupManager;
@@ -270,15 +267,11 @@ public class IvyPlugin extends AbstractUIPlugin {
void prefStoreChanged() throws JavaModelException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IJavaModel javaModel = JavaCore.create(workspace.getRoot());
- IJavaProject[] projects = javaModel.getJavaProjects();
- for (int i = 0; i < projects.length; i++) {
- List<IvyClasspathContainer> containers = IvyClasspathContainerHelper
- .getContainers(projects[i]);
- Iterator<IvyClasspathContainer> itContainers = containers.iterator();
- while (itContainers.hasNext()) {
- IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainers.next();
- if (!ivycp.getConf().isSettingsProjectSpecific()) {
- ivycp.launchResolve(false, null);
+ for (IJavaProject project : javaModel.getJavaProjects()) {
+ for (IvyClasspathContainer container : IvyClasspathContainerHelper
+ .getContainers(project)) {
+ if (!container.getConf().isSettingsProjectSpecific()) {
+ container.launchResolve(false, null);
}
}
}
@@ -405,6 +398,7 @@ public class IvyPlugin extends AbstractUIPlugin {
* Returns the string from the plugin's resource bundle, or 'key' if not found.
*
* @param key String
+ * @return String
*/
public static String getResourceString(String key) {
ResourceBundle bundle = IvyPlugin.getDefault().getResourceBundle();
@@ -418,6 +412,7 @@ public class IvyPlugin extends AbstractUIPlugin {
/**
* Utility class that tries to adapt a non null object to the specified type
*
+ * @param <T> type
* @param object
* the object to adapt
* @param type
@@ -425,13 +420,14 @@ public class IvyPlugin extends AbstractUIPlugin {
* @return the adapted object
*/
- public static/* <T> T */Object adapt(Object object, Class/* <T> */type) {
+ @SuppressWarnings("unchecked")
+ public static <T> T adapt(Object object, Class<T> type) {
if (type.isInstance(object)) {
- return /* (T) */object;
+ return (T) object;
} else if (object instanceof IAdaptable) {
- return /* (T) */((IAdaptable) object).getAdapter(type);
+ return (T) ((IAdaptable) object).getAdapter(type);
}
- return /* (T) */Platform.getAdapterManager().getAdapter(object, type);
+ return (T) Platform.getAdapterManager().getAdapter(object, type);
}
/**
@@ -451,8 +447,8 @@ public class IvyPlugin extends AbstractUIPlugin {
return null;
}
- public Enumeration getKeys() {
- return Collections.enumeration(Collections.EMPTY_LIST);
+ public Enumeration<String> getKeys() {
+ return Collections.emptyEnumeration();
}
};
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java
index aa82ac0..f256995 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java
@@ -23,9 +23,11 @@ import java.util.Set;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivyde.eclipse.cp.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cp.IvyClasspathContainerConfiguration;
import org.apache.ivyde.eclipse.cp.RetrieveSetup;
import org.apache.ivyde.internal.eclipse.IvyDEMessage;
@@ -45,11 +47,11 @@ public class ClasspathEntriesResolver extends IvyResolver {
private ResolveReport resolveReport;
- public ClasspathEntriesResolver(IvyClasspathContainerImpl ivycp, boolean usePreviousResolveIfExist) {
- super(ivycp.getConf().getIvyXmlPath(), ivycp.getConf().getConfs(), ivycp.getConf()
- .getJavaProject() == null ? null : ivycp.getConf().getJavaProject().getProject());
- this.conf = ivycp.getConf();
- setUsePreviousResolveIfExist(ivycp.getConf().getInheritedAdvancedSetup().isUseExtendedResolveId());
+ public ClasspathEntriesResolver(IvyClasspathContainer container, boolean usePreviousResolveIfExist) {
+ super(container.getConf().getIvyXmlPath(), container.getConf().getConfs(), container.getConf()
+ .getJavaProject() == null ? null : container.getConf().getJavaProject().getProject());
+ this.conf = container.getConf();
+ setUsePreviousResolveIfExist(conf.getInheritedAdvancedSetup().isUseExtendedResolveId());
setUsePreviousResolveIfExist(usePreviousResolveIfExist);
setTransitiveResolve(conf.getInheritedClasspathSetup().isTransitiveResolve());
if (conf.getInheritedClasspathSetup().isRetrievedClasspath()) {
@@ -88,11 +90,10 @@ public class ClasspathEntriesResolver extends IvyResolver {
* @param mapper IvyClasspathContainerMapper
* @param artifactReports Set<ArtifactDownloadReport>
*/
- private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper, Set artifactReports) {
- ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) artifactReports
- .toArray(new ArtifactDownloadReport[0]);
+ private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper, Set<ArtifactDownloadReport> artifactReports) {
+ ArtifactDownloadReport[] reports = artifactReports.toArray(new ArtifactDownloadReport[0]);
- Set duplicates = new HashSet();
+ Set<ModuleId> duplicates = new HashSet<>();
for (int i = 0; i < reports.length - 1; i++) {
if (!mapper.accept(reports[i].getArtifact())) {
@@ -121,7 +122,7 @@ public class ClasspathEntriesResolver extends IvyResolver {
StringBuilder buffer = new StringBuilder("There are some duplicates entries due to conflicts"
+ " between the resolved configurations " + conf.getConfs());
buffer.append(":\n - ");
- Iterator it = duplicates.iterator();
+ Iterator<ModuleId> it = duplicates.iterator();
while (it.hasNext()) {
buffer.append(it.next());
if (it.hasNext()) {
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
index 8ec1d60..1a26aad 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
@@ -88,7 +88,7 @@ public final class IvyClasspathContainerConfAdapter {
private static void loadV0(IvyClasspathContainerConfiguration conf, IPath path) {
// load some configuration that can be loaded
conf.setIvyXmlPath(path.removeFirstSegments(1).removeLastSegments(1).toString());
- List confs = IvyClasspathUtil.split(path.lastSegment());
+ List<String> confs = IvyClasspathUtil.split(path.lastSegment());
if (confs.isEmpty()) {
confs = Collections.singletonList("*");
}
@@ -315,7 +315,7 @@ public final class IvyClasspathContainerConfAdapter {
RetrieveSetupManager manager = IvyPlugin.getDefault().getRetrieveSetupManager();
IProject project = conf.getJavaProject().getProject();
- List retrieveSetups;
+ List<StandaloneRetrieveSetup> retrieveSetups;
try {
retrieveSetups = manager.getSetup(project);
} catch (IOException e) {
@@ -485,7 +485,7 @@ public final class IvyClasspathContainerConfAdapter {
path.append(URLEncoder.encode(value, "UTF-8"));
}
- private static void append(StringBuffer path, String name, List values)
+ private static void append(StringBuffer path, String name, List<String> values)
throws UnsupportedEncodingException {
append(path, name, IvyClasspathUtil.concat(values));
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java
index 68f0a16..2af1b6c 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java
@@ -147,10 +147,10 @@ public class IvyClasspathContainerImpl implements IClasspathContainer, IvyClassp
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (conf.getInheritedClasspathSetup().isAlphaOrder()) {
- Arrays.sort(entries, new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((IClasspathEntry) o1).getPath().lastSegment()
- .compareTo(((IClasspathEntry) o2).getPath().lastSegment());
+ Arrays.sort(entries, new Comparator<IClasspathEntry>() {
+ public int compare(IClasspathEntry o1, IClasspathEntry o2) {
+ return (o1.getPath().lastSegment()
+ .compareTo(o2.getPath().lastSegment()));
}
});
}
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java
----------------------------------------------------------------------
diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java
index 7e9ceb6..f6cde60 100644
--- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java
+++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java
@@ -103,7 +103,6 @@ public class IvyClasspathContainerMapper {
}
public IClasspathEntry[] map() {
- IClasspathEntry[] classpathEntries;
Collection<IClasspathEntry> paths = new LinkedHashSet<>();
IvyDEMessage.verbose("Building classpath from " + all.size() + " resolved artifact(s)");
@@ -168,9 +167,8 @@ public class IvyClasspathContainerMapper {
}
}
- classpathEntries = paths.toArray(new IClasspathEntry[paths.size()]);
- return classpathEntries;
+ return paths.toArray(new IClasspathEntry[paths.size()]);
}
private IClasspathEntry buildEntry(ArtifactDownloadReport artifact, IAccessRule[] rules,
@@ -228,16 +226,15 @@ public class IvyClasspathContainerMapper {
if (bundleInfo == null || !classpathSetup.isReadOSGiMetadata()) {
return null;
}
- IAccessRule[] rules = new IAccessRule[bundleInfo.getExports().size() + 1];
- int i = 0;
+ List<IAccessRule> rules = new ArrayList<>(bundleInfo.getExports().size() + 1);
for (ExportPackage exportPackage : bundleInfo.getExports()) {
- rules[i++] = JavaCore.newAccessRule(
+ rules.add(JavaCore.newAccessRule(
new Path(exportPackage.getName().replace('.', IPath.SEPARATOR) + "/*"),
- IAccessRule.K_ACCESSIBLE);
+ IAccessRule.K_ACCESSIBLE));
}
- rules[i++] = JavaCore.newAccessRule(new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE
- | IAccessRule.IGNORE_IF_BETTER);
- return rules;
+ rules.add(JavaCore.newAccessRule(new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE
+ | IAccessRule.IGNORE_IF_BETTER));
+ return rules.toArray(new IAccessRule[rules.size()]);
}
private Path getArtifactPath(ArtifactDownloadReport artifact, String innerPath) {