Skip to content

Commit

Permalink
Remove redundant type information
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Sep 12, 2023
1 parent 139d64e commit 0255284
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ public IQueryable<IArtifactDescriptor> descriptorQueryable() {
synchronized (SimpleArtifactRepository.this) {
snapshotNeeded = true;
Collection<List<IArtifactDescriptor>> descs = SimpleArtifactRepository.this.artifactMap.values();
return query.perform(new CompoundIterator<IArtifactDescriptor>(descs.iterator()));
return query.perform(new CompoundIterator<>(descs.iterator()));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust
private BundleContext context;
private volatile boolean stopped = false;
private ServiceRegistration<IProvisioningAgent> reg;
private final Map<ServiceReference<IAgentServiceFactory>, ServiceTracker<IAgentServiceFactory, Object>> trackers = Collections.synchronizedMap(new HashMap<ServiceReference<IAgentServiceFactory>, ServiceTracker<IAgentServiceFactory, Object>>());
private final Map<ServiceReference<IAgentServiceFactory>, ServiceTracker<IAgentServiceFactory, Object>> trackers = Collections
.synchronizedMap(new HashMap<>());

/**
* Instantiates a provisioning agent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ public IArtifactKey createArtifactKey(String classifier, String id, Version vers
@Override
public IQueryable<IArtifactDescriptor> descriptorQueryable() {
final Collection<List<IArtifactDescriptor>> descs = artifactMap.values();
IQueryable<IArtifactDescriptor> cached = (query, monitor) -> query.perform(new CompoundIterator<IArtifactDescriptor>(descs.iterator()));
IQueryable<IArtifactDescriptor> cached = (query, monitor) -> query
.perform(new CompoundIterator<>(descs.iterator()));

return QueryUtil.compoundQueryable(cached, innerRepo.descriptorQueryable());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected IStatus run(IProgressMonitor monitor) {
}

// cache which nodes have been loaded from disk
private static Set<String> loadedNodes = Collections.synchronizedSet(new HashSet<String>());
private static Set<String> loadedNodes = Collections.synchronizedSet(new HashSet<>());

public static final Object PROFILE_SAVE_JOB_FAMILY = new Object();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected IStatus initializeOperand(IProfile profile, InstallableUnitOperand ope

@Override
protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map<String, Object> parameters) {
parameters.put(PARM_ARTIFACTS, new HashMap<IArtifactDescriptor, File>());
parameters.put(PARM_ARTIFACTS, new HashMap<>());
return super.initializePhase(monitor, profile, parameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map<

@Override
protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map<String, Object> parameters) {
parameters.put(PARM_ARTIFACT_REQUESTS, new ArrayList<IArtifactRequest[]>());
parameters.put(PARM_IUS, new HashSet<IInstallableUnit>());
parameters.put(PARM_ARTIFACT_REQUESTS, new ArrayList<>());
parameters.put(PARM_IUS, new HashSet<>());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
Expand Down Expand Up @@ -131,7 +131,7 @@ protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map<

@Override
protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map<String, Object> parameters) {
parameters.put(Collect.PARM_ARTIFACT_REQUESTS, new ArrayList<IArtifactRequest[]>());
parameters.put(Collect.PARM_ARTIFACT_REQUESTS, new ArrayList<>());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,41 @@
package org.eclipse.equinox.internal.p2.metadata;

import java.io.Serializable;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.equinox.internal.p2.metadata.VersionFormatParser.Fragment;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.IVersionFormat;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionFormatException;
import org.eclipse.osgi.util.NLS;

/**
* <p>The VersionFormat represents the Omni Version Format in compiled form. It
* is also a parser for versions of that format.</p>
* <p>An instance of VersionFormat is immutable and thus thread safe. The parser
* does not maintain any state.</p>
* <p>
* The VersionFormat represents the Omni Version Format in compiled form. It is
* also a parser for versions of that format.
* </p>
* <p>
* An instance of VersionFormat is immutable and thus thread safe. The parser
* does not maintain any state.
* </p>
*
* @Immutable
* @noextend This class is not intended to be subclassed by clients.
*/
public class VersionFormat implements IVersionFormat, Serializable {

/**
* The string representation of the Omni Version format used for parsing OSGi versions.
* The string representation of the Omni Version format used for parsing OSGi
* versions.
*/
public static final String OSGI_FORMAT_STRING = "n[.n=0;[.n=0;[.S='';=[A-Za-z0-9_-];]]]"; //$NON-NLS-1$

/**
* The string representation of the Omni Version format used for parsing raw versions.
* The string representation of the Omni Version format used for parsing raw
* versions.
*/
public static final String RAW_FORMAT_STRING = "r(.r)*p?"; //$NON-NLS-1$

Expand Down Expand Up @@ -109,17 +121,15 @@ void setPosition(int pos) {
}
}

private static final Map<String, VersionFormat> formatCache = Collections.synchronizedMap(new HashMap<String, VersionFormat>());
private static final Map<String, VersionFormat> formatCache = Collections.synchronizedMap(new HashMap<>());

/**
* The predefined OSGi format that is used when parsing OSGi
* versions.
* The predefined OSGi format that is used when parsing OSGi versions.
*/
public static final VersionFormat OSGI_FORMAT;

/**
* The predefined OSGi format that is used when parsing raw
* versions.
* The predefined OSGi format that is used when parsing raw versions.
*/
public static final VersionFormat RAW_FORMAT;

Expand All @@ -140,7 +150,13 @@ void setPosition(int pos) {

/**
* Compile a version format string into a compiled format. This method is
* shorthand for:<pre>CompiledFormat.compile(format, 0, format.length())</pre>.
* shorthand for:
*
* <pre>
* CompiledFormat.compile(format, 0, format.length())
* </pre>
*
* .
*
* @param format The format to compile.
* @return The compiled format
Expand All @@ -151,14 +167,14 @@ public static IVersionFormat compile(String format) throws VersionFormatExceptio
}

/**
* Compile a version format string into a compiled format. The parsing starts
* at position start and ends at position end. The returned format is cached so
* Compile a version format string into a compiled format. The parsing starts at
* position start and ends at position end. The returned format is cached so
* subsequent calls to this method using the same format string will yield the
* same compiled format instance.
*
* @param format The format string to compile.
* @param start Start position in the format string
* @param end End position in the format string
* @param start Start position in the format string
* @param end End position in the format string
* @return The compiled format
* @throws VersionFormatException If the format could not be compiled
*/
Expand All @@ -178,15 +194,18 @@ public static VersionFormat compile(String format, int start, int end) throws Ve
/**
* Parse a version string using the {@link #RAW_FORMAT} parser.
*
* @param version The version to parse.
* @param originalFormat The original format to assign to the created version. Can be <code>null</code>.
* @param original The original version string to assign to the created version. Can be <code>null</code>.
* @param version The version to parse.
* @param originalFormat The original format to assign to the created version.
* Can be <code>null</code>.
* @param original The original version string to assign to the created
* version. Can be <code>null</code>.
* @return A created version
* @throws IllegalArgumentException If the version string could not be parsed.
*/
public static BasicVersion parseRaw(String version, IVersionFormat originalFormat, String original) {
List<Comparable<?>> vector = RAW_FORMAT.parse(version, 0, version.length());
return (originalFormat == OSGI_FORMAT) ? OSGiVersion.fromVector(vector) : OmniVersion.fromVector(vector, originalFormat, original);
return (originalFormat == OSGI_FORMAT) ? OSGiVersion.fromVector(vector)
: OmniVersion.fromVector(vector, originalFormat, original);
}

static void rawToString(StringBuffer sb, boolean forRange, Comparable<?> e) {
Expand All @@ -203,19 +222,25 @@ static void rawToString(StringBuffer sb, boolean forRange, Comparable<?> e) {
}

/**
* Write a string within quotes. If the string is found to contain the quote, an attempt is made
* to flip quote character (single quote becomes double quote and vice versa). A string that contains
* both will be written as several adjacent quoted strings so that each string is quoted with a
* quote character that it does not contain.
* @param sb The buffer that will receive the string
* @param rangeSafe Set to <code>true</code> if the resulting string will be used in a range string
* and hence need to escape the range delimiter characters
* @param s The string to be written
* @param quote The quote character to start with. Must be the single or double quote character.
* @param startPos The start position
* @param didFlip True if the call is recursive and thus, cannot switch quotes in the first string.
* Write a string within quotes. If the string is found to contain the quote, an
* attempt is made to flip quote character (single quote becomes double quote
* and vice versa). A string that contains both will be written as several
* adjacent quoted strings so that each string is quoted with a quote character
* that it does not contain.
*
* @param sb The buffer that will receive the string
* @param rangeSafe Set to <code>true</code> if the resulting string will be
* used in a range string and hence need to escape the range
* delimiter characters
* @param s The string to be written
* @param quote The quote character to start with. Must be the single or
* double quote character.
* @param startPos The start position
* @param didFlip True if the call is recursive and thus, cannot switch quotes
* in the first string.
*/
private static void writeQuotedString(StringBuffer sb, boolean rangeSafe, String s, char quote, int startPos, boolean didFlip) {
private static void writeQuotedString(StringBuffer sb, boolean rangeSafe, String s, char quote, int startPos,
boolean didFlip) {
int quotePos = sb.length();
sb.append(quote);
boolean otherSeen = false;
Expand Down Expand Up @@ -274,11 +299,13 @@ public Version parse(String version) {

List<Comparable<?>> parse(String version, int start, int maxPos) {
if (start == maxPos)
throw new IllegalArgumentException(NLS.bind(Messages.format_0_unable_to_parse_empty_version, this, version.substring(start, maxPos)));
throw new IllegalArgumentException(
NLS.bind(Messages.format_0_unable_to_parse_empty_version, this, version.substring(start, maxPos)));
TreeInfo info = new TreeInfo(topFragment, start);
ArrayList<Comparable<?>> entries = new ArrayList<>(5);
if (!(topFragment.parse(entries, version, maxPos, info) && info.getPosition() == maxPos))
throw new IllegalArgumentException(NLS.bind(Messages.format_0_unable_to_parse_1, this, version.substring(start, maxPos)));
throw new IllegalArgumentException(
NLS.bind(Messages.format_0_unable_to_parse_1, this, version.substring(start, maxPos)));
entries.add(VersionParser.removeRedundantTrail(entries, info.getPadValue()));
return entries;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
public class ProvisioningSession {
private IProvisioningAgent agent;

Set<Job> scheduledJobs = Collections.synchronizedSet(new HashSet<Job>());
Set<Job> scheduledJobs = Collections.synchronizedSet(new HashSet<>());

/**
* Create a provisioning session using the services of the supplied agent.
Expand Down Expand Up @@ -149,9 +149,8 @@ public IStatus performProvisioningPlan(IProvisioningPlan plan, IPhaseSet phaseSe
// at the same time as the actual install artifacts. This way, we will only install the install handler
// after already knowing we have successfully obtained the artifacts that will be installed afterward.
IProvisioningPlan downloadPlan = getEngine().createPlan(profile, context);
Iterator<IInstallableUnit> it = QueryUtil.compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()).query(QueryUtil.createIUAnyQuery(), null).iterator();
while (it.hasNext()) {
downloadPlan.addInstallableUnit(it.next());
for (IInstallableUnit element : QueryUtil.compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()).query(QueryUtil.createIUAnyQuery(), null)) {
downloadPlan.addInstallableUnit(element);
}
IPhaseSet download = PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_COLLECT});
IStatus downloadStatus = getEngine().perform(downloadPlan, download, mon.newChild(300));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ public static Dictionary<String, String> basicLoadManifest(File bundleLocation)
private static Headers<String, String> parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(
InputStream manifestStream) throws IOException, BundleException {
return (Headers<String, String>) ManifestElement.parseBundleManifest(manifestStream,
new Headers<String, String>(10));
new Headers<>(10));
}

private static ManifestElement[] parseManifestHeader(String header, Map<String, String> manifest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
import org.eclipse.equinox.internal.p2.discovery.model.*;
import org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory;
import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
import org.eclipse.equinox.p2.discovery.tests.DiscoveryTestConstants;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -39,10 +40,10 @@ public class RemoteBundleDiscoveryStrategyTest {
public void setUp() throws Exception {
discoveryStrategy = new RemoteBundleDiscoveryStrategy();
discoveryStrategy.setDirectoryUrl(DiscoveryTestConstants.DISCOVERY_URL);
discoveryStrategy.setCategories(new ArrayList<CatalogCategory>());
discoveryStrategy.setItems(new ArrayList<CatalogItem>());
discoveryStrategy.setCertifications(new ArrayList<Certification>());
discoveryStrategy.setTags(new ArrayList<Tag>());
discoveryStrategy.setCategories(new ArrayList<>());
discoveryStrategy.setItems(new ArrayList<>());
discoveryStrategy.setCertifications(new ArrayList<>());
discoveryStrategy.setTags(new ArrayList<>());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
import java.util.HashMap;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.engine.IEngine;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
import org.eclipse.equinox.p2.query.IQueryResult;
Expand Down Expand Up @@ -60,7 +67,12 @@ protected void setUp() throws Exception {
requirements.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "com.tssap.selena.model.providers.resources", new VersionRange("[1.0.0, 1.0.0]"), null, false, false));
requirements.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "com.tssap.selena.model", new VersionRange("[1.0.0, 1.0.0]"), null, false, false));

IInstallableUnit group = createIU("com.borland.tg.modeling.feature.group", Version.create("8.2.0.v20081113-0500-_87S7nELRXmpf6G0dO3emm"), null, requirements.toArray(new IRequirement[requirements.size()]), new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "com.borland.tg.modeling", Version.create("8.2.0.v20081113-0500-_87S7nELRXmpf6G0dO3emm"))}, new HashMap<String, String>(), null, null, true);
IInstallableUnit group = createIU("com.borland.tg.modeling.feature.group",
Version.create("8.2.0.v20081113-0500-_87S7nELRXmpf6G0dO3emm"), null,
requirements.toArray(new IRequirement[requirements.size()]),
new IProvidedCapability[] { MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID,
"com.borland.tg.modeling", Version.create("8.2.0.v20081113-0500-_87S7nELRXmpf6G0dO3emm")) },
new HashMap<>(), null, null, true);

ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.addInstallableUnits(new IInstallableUnit[] {group});
Expand Down
Loading

0 comments on commit 0255284

Please sign in to comment.