diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata')
111 files changed, 931 insertions, 258 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.metadata/.settings/org.eclipse.jdt.core.prefs index 47d687a60..c7b349024 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.metadata/.settings/org.eclipse.jdt.core.prefs @@ -10,10 +10,14 @@ org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 @@ -22,6 +26,7 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000 +org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -33,7 +38,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod= org.eclipse.jdt.core.compiler.problem.discouragedReference=error org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning @@ -53,7 +58,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -63,7 +68,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -71,19 +76,21 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore @@ -93,12 +100,16 @@ org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore @@ -106,6 +117,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java index 740bcc467..64fc90d17 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,7 +36,7 @@ public class ArtifactKey implements IArtifactKey, IMemberProvider { private static String[] getArrayFromList(String stringList, String separator) { if (stringList == null || stringList.trim().length() == 0) return new String[0]; - ArrayList<String> list = new ArrayList<String>(); + ArrayList<String> list = new ArrayList<>(); boolean separatorSeen = true; StringTokenizer tokens = new StringTokenizer(stringList, separator, true); while (tokens.hasMoreTokens()) { @@ -90,14 +90,17 @@ public class ArtifactKey implements IArtifactKey, IMemberProvider { this.version = artifactKey.getVersion(); } + @Override public String getClassifier() { return classifier; } + @Override public Version getVersion() { return version; } + @Override public int hashCode() { int hash = id.hashCode(); hash = 17 * hash + getVersion().hashCode(); @@ -105,10 +108,12 @@ public class ArtifactKey implements IArtifactKey, IMemberProvider { return hash; } + @Override public String toString() { return classifier + SEPARATOR + id + SEPARATOR + getVersion(); } + @Override public boolean equals(Object obj) { if (!(obj instanceof IArtifactKey)) return false; @@ -116,10 +121,12 @@ public class ArtifactKey implements IArtifactKey, IMemberProvider { return ak.getId().equals(id) && ak.getVersion().equals(getVersion()) && ak.getClassifier().equals(classifier); } + @Override public String getId() { return id; } + @Override public String toExternalForm() { StringBuffer data = new StringBuffer(classifier).append(SEPARATOR); data.append(id).append(SEPARATOR); @@ -127,6 +134,7 @@ public class ArtifactKey implements IArtifactKey, IMemberProvider { return data.toString(); } + @Override public Object getMember(String memberName) { // It is OK to use identity comparisons here since // a) All constant valued strings are always interned diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java index b56578830..1d9cd6bc7 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/Copyright.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,6 +49,7 @@ public class Copyright implements ICopyright { * * @return The location of the copyright notice, or <code>null</code> */ + @Override public URI getLocation() { return location; } @@ -58,6 +59,7 @@ public class Copyright implements ICopyright { * * @return the license body, never <code>null</code> */ + @Override public String getBody() { return body; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/EnumDefinition.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/EnumDefinition.java index c8377382e..3aff643ae 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/EnumDefinition.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/EnumDefinition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,6 +28,7 @@ class EnumDefinition implements Comparable<EnumDefinition>, Serializable { this.definition = definition; } + @Override public int compareTo(EnumSegment other) { if (other == this) return 0; @@ -69,10 +70,12 @@ class EnumDefinition implements Comparable<EnumDefinition>, Serializable { return definition.compareTo(other.definition); } + @Override public boolean equals(Object other) { return other == this || other instanceof EnumSegment && compareTo((EnumSegment) other) == 0; } + @Override public int hashCode() { return (1 + ordinal) * 31 + definition.getIdentifier(ordinal).hashCode(); } @@ -96,7 +99,7 @@ class EnumDefinition implements Comparable<EnumDefinition>, Serializable { } private static final long serialVersionUID = 7237775466362654473L; - private static final Map<EnumDefinition, EnumSegment[]> enumDefinitionCache = new HashMap<EnumDefinition, EnumSegment[]>(); + private static final Map<EnumDefinition, EnumSegment[]> enumDefinitionCache = new HashMap<>(); private static EnumSegment[] getEnumSegments(EnumDefinition ed) { EnumSegment[] values = enumDefinitionCache.get(ed); @@ -226,6 +229,7 @@ class EnumDefinition implements Comparable<EnumDefinition>, Serializable { return true; } + @Override public int compareTo(EnumDefinition o) { if (o == this) return 0; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java index bc2f95c30..f3971163f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 IBM Corporation and others. + * Copyright (c) 2009, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,10 +38,12 @@ public class IUMap implements Cloneable { unitIterator = units.values().iterator(); } + @Override public boolean hasNext() { return positionNext(); } + @Override public IInstallableUnit next() { if (!positionNext()) throw new NoSuchElementException(); @@ -51,6 +53,7 @@ public class IUMap implements Cloneable { return nxt; } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -86,7 +89,7 @@ public class IUMap implements Cloneable { /** * Map<String,Object> mapping IU id to either arrays of iu's or a single iu with that id. */ - final Map<String, Object> units = new HashMap<String, Object>(); + final Map<String, Object> units = new HashMap<>(); public IUMap() { // @@ -179,7 +182,7 @@ public class IUMap implements Cloneable { Collection<IInstallableUnit> idUnits = getUnits(id); if (idUnits.isEmpty()) return Collector.emptyCollector(); - return version == null ? new CollectionResult<IInstallableUnit>(idUnits) : QueryUtil.createIUQuery(id, version).perform(idUnits.iterator()); + return version == null ? new CollectionResult<>(idUnits) : QueryUtil.createIUQuery(id, version).perform(idUnits.iterator()); } public IInstallableUnit get(String id, Version version) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java index 48dcf2344..1c8c43483 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,6 +20,7 @@ import org.eclipse.equinox.p2.metadata.expression.*; public class InstallableUnit implements IInstallableUnit, IMemberProvider { @SuppressWarnings("serial") private static final Map<IFilterExpression, IMatchExpression<IInstallableUnit>> filterCache = new LinkedHashMap<IFilterExpression, IMatchExpression<IInstallableUnit>>() { + @Override public boolean removeEldestEntry(Map.Entry<IFilterExpression, IMatchExpression<IInstallableUnit>> expr) { return size() > 64; } @@ -94,6 +95,7 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { } } + @Override public int compareTo(IInstallableUnit other) { int cmp = getId().compareTo(other.getId()); if (cmp == 0) @@ -101,6 +103,7 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { return cmp; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -122,18 +125,22 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { return true; } + @Override public Collection<IArtifactKey> getArtifacts() { return CollectionUtils.unmodifiableList(artifacts); } + @Override public IMatchExpression<IInstallableUnit> getFilter() { return filter; } + @Override public Collection<IInstallableUnitFragment> getFragments() { return Collections.<IInstallableUnitFragment> emptyList(); } + @Override public String getId() { return id; } @@ -144,6 +151,7 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { * * @return an <i>unmodifiable copy</i> of the IU properties. */ + @Override public Map<String, String> getProperties() { return OrderedProperties.unmodifiableProperties(properties()); } @@ -158,35 +166,43 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { return result; } + @Override public String getProperty(String key) { return properties().getProperty(key); } + @Override public Collection<IProvidedCapability> getProvidedCapabilities() { return CollectionUtils.unmodifiableList(providedCapabilities); } + @Override public String getProperty(String key, String locale) { return TranslationSupport.getInstance().getIUProperty(this, key, locale); } + @Override public List<IRequirement> getRequirements() { return CollectionUtils.unmodifiableList(requires); } + @Override public Collection<ITouchpointData> getTouchpointData() { return CollectionUtils.unmodifiableList(touchpointData); } + @Override public ITouchpointType getTouchpointType() { return touchpointType != null ? touchpointType : ITouchpointType.NONE; } + @Override public Version getVersion() { return version; } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -195,10 +211,12 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { return result; } + @Override public boolean isResolved() { return false; } + @Override public boolean isSingleton() { return singleton; } @@ -287,14 +305,17 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { this.version = (newVersion != null ? newVersion : Version.emptyVersion); } + @Override public String toString() { return id + ' ' + getVersion(); } + @Override public IInstallableUnit unresolved() { return this; } + @Override public IUpdateDescriptor getUpdateDescriptor() { return updateInfo; } @@ -307,10 +328,12 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { this.licenses = license == null ? NO_LICENSE : license; } + @Override public Collection<ILicense> getLicenses() { return CollectionUtils.unmodifiableList(licenses); } + @Override public Collection<ILicense> getLicenses(String locale) { return CollectionUtils.unmodifiableList(TranslationSupport.getInstance().getLicenses(this, locale)); } @@ -319,18 +342,22 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { this.copyright = copyright; } + @Override public ICopyright getCopyright() { return copyright; } + @Override public ICopyright getCopyright(String locale) { return TranslationSupport.getInstance().getCopyright(this, locale); } + @Override public boolean satisfies(IRequirement candidate) { return candidate.isMatch(this); } + @Override public Collection<IRequirement> getMetaRequirements() { return CollectionUtils.unmodifiableList(metaRequires); } @@ -344,6 +371,7 @@ public class InstallableUnit implements IInstallableUnit, IMemberProvider { } } + @Override public Object getMember(String memberName) { // It is OK to use identity comparisons here since // a) All constant valued strings are always interned diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java index 426b6234b..e5dfef43d 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,10 +28,12 @@ public class InstallableUnitFragment extends InstallableUnit implements IInstall this.hostRequirements = hostRequirements; } + @Override public Collection<IRequirement> getHost() { return hostRequirements; } + @Override public Object getMember(String memberName) { return "host".equals(memberName) ? hostRequirements : super.getMember(memberName); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitPatch.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitPatch.java index 344b6c72f..f400770e8 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitPatch.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitPatch.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2008, 2017 IBM Corporation and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -31,14 +31,17 @@ public class InstallableUnitPatch extends InstallableUnit implements IInstallabl setRequiredCapabilities(result); } + @Override public IRequirement[][] getApplicabilityScope() { return scope; } + @Override public IRequirement getLifeCycle() { return lifeCycle; } + @Override public List<IRequirementChange> getRequirementsChange() { return CollectionUtils.unmodifiableList(changes); } @@ -58,6 +61,7 @@ public class InstallableUnitPatch extends InstallableUnit implements IInstallabl this.changes = changes; } + @Override public Object getMember(String memberName) { if (MEMBER_APPLICABILITY_SCOPE == memberName) return scope; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java index 12514599f..194212883 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java @@ -1,5 +1,6 @@ /******************************************************************************* - * Copyright (c) 2008, 2017 Genuitec, LLC and others. All rights reserved. This + * Copyright (c) 2008, 2017 Genuitec, LLC and others. + * All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -62,6 +63,7 @@ public class License implements ILicense { * * @return the location of the license document, or <code>null</code> */ + @Override public URI getLocation() { return location; } @@ -70,6 +72,7 @@ public class License implements ILicense { * Returns the license body. * @return the license body, never <code>null</code> */ + @Override public String getBody() { return body; } @@ -79,6 +82,7 @@ public class License implements ILicense { * version of the license where all whitespace has been reduced to one space. * @return the message digest as a <code>BigInteger</code>, never <code>null</code> */ + @Override public synchronized String getUUID() { if (digest == null) digest = calculateLicenseDigest().toString(16); @@ -86,9 +90,7 @@ public class License implements ILicense { return digest; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ + @Override public boolean equals(Object obj) { if (obj == this) return true; @@ -102,9 +104,7 @@ public class License implements ILicense { return false; } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ + @Override public int hashCode() { return getUUID().hashCode(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/MetadataActivator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/MetadataActivator.java index e0c57e821..0686efde9 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/MetadataActivator.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/MetadataActivator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,11 +25,13 @@ public class MetadataActivator implements BundleActivator { return activator == null ? null : activator.context; } + @Override public void start(BundleContext aContext) throws Exception { context = aContext; instance = this; } + @Override public void stop(BundleContext aContext) throws Exception { instance = null; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OSGiVersion.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OSGiVersion.java index 728cc75cd..37f65c88f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OSGiVersion.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OSGiVersion.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -94,6 +94,7 @@ public class OSGiVersion extends BasicVersion { this.qualifier = qualifier; } + @Override public int compareTo(Version v) { int result; if (!(v instanceof OSGiVersion)) { @@ -114,6 +115,7 @@ public class OSGiVersion extends BasicVersion { return result; } + @Override public boolean equals(Object object) { if (object == this) return true; @@ -130,42 +132,52 @@ public class OSGiVersion extends BasicVersion { return micro == other.micro && minor == other.minor && major == other.major && qualifier.equals(other.qualifier); } + @Override public IVersionFormat getFormat() { return VersionFormat.OSGI_FORMAT; } + @Override public int getMajor() { return major; } + @Override public int getMicro() { return micro; } + @Override public int getMinor() { return minor; } + @Override public String getOriginal() { return toString(); } + @Override public String getQualifier() { return qualifier == VersionVector.MAXS_VALUE ? IVersionFormat.DEFAULT_MAX_STRING_TRANSLATION : (String) qualifier; } + @Override public int hashCode() { return (major << 24) + (minor << 16) + (micro << 8) + qualifier.hashCode(); } + @Override public boolean isOSGiCompatible() { return true; } + @Override public void originalToString(StringBuffer sb, boolean rangeSafe) { toString(sb); } + @Override public void rawToString(StringBuffer sb, boolean rangeSafe) { sb.append(major); sb.append('.'); @@ -178,6 +190,7 @@ public class OSGiVersion extends BasicVersion { sb.append('\''); } + @Override public void toString(StringBuffer sb) { sb.append(major); sb.append('.'); @@ -190,14 +203,17 @@ public class OSGiVersion extends BasicVersion { } } + @Override public Comparable<?>[] getVector() { return new Comparable[] {VersionParser.valueOf(major), VersionParser.valueOf(minor), VersionParser.valueOf(micro), qualifier}; } + @Override public Comparable<?> getPad() { return null; } + @Override public Comparable<?> getSegment(int index) { switch (index) { case 0 : @@ -212,6 +228,7 @@ public class OSGiVersion extends BasicVersion { throw new ArrayIndexOutOfBoundsException(index); // Not in the imaginary vector array } + @Override public int getSegmentCount() { return 4; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java index b5a6f6372..410fdb3de 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -94,6 +94,7 @@ public class OmniVersion extends BasicVersion { this.original = original; } + @Override public boolean equals(Object o) { if (o == this) return true; @@ -105,26 +106,32 @@ public class OmniVersion extends BasicVersion { return VersionVector.equals(vector, padValue, ov.getVector(), ov.getPad()); } + @Override public IVersionFormat getFormat() { return format; } + @Override public int getMajor() { return getIntElement(0); } + @Override public int getMicro() { return getIntElement(2); } + @Override public int getMinor() { return getIntElement(1); } + @Override public String getOriginal() { return original; } + @Override public String getQualifier() { if (vector.length == 3) return VersionVector.MINS_VALUE; @@ -140,6 +147,7 @@ public class OmniVersion extends BasicVersion { return (String) qualifier; } + @Override public int hashCode() { return VersionVector.hashCode(vector, padValue); } @@ -148,6 +156,7 @@ public class OmniVersion extends BasicVersion { * Checks if this version is in compliance with the OSGi version spec. * @return A flag indicating whether the version is OSGi compatible or not. */ + @Override public boolean isOSGiCompatible() { if (vector.length < 3 || vector.length > 4) return (this == emptyVersion || this == MAX_VERSION); @@ -172,6 +181,7 @@ public class OmniVersion extends BasicVersion { * @param sb The buffer that will receive the raw string format * @param rangeSafe Set to <code>true</code> if range delimiters should be escaped */ + @Override public void originalToString(StringBuffer sb, boolean rangeSafe) { if (original != null) { if (rangeSafe) { @@ -194,6 +204,7 @@ public class OmniVersion extends BasicVersion { * @param sb The buffer that will receive the raw string format * @param rangeSafe Set to <code>true</code> if range delimiters should be escaped */ + @Override public void rawToString(StringBuffer sb, boolean rangeSafe) { VersionVector.toString(sb, vector, padValue, rangeSafe); } @@ -203,6 +214,7 @@ public class OmniVersion extends BasicVersion { * <code>sb</code> StringBuffer. * @param sb The buffer that will receive the version string */ + @Override public void toString(StringBuffer sb) { if (this == emptyVersion) sb.append("0.0.0"); //$NON-NLS-1$ @@ -237,22 +249,27 @@ public class OmniVersion extends BasicVersion { return v; } + @Override public Comparable<?> getPad() { return padValue; } + @Override public Comparable<?> getSegment(int index) { return vector[index]; } + @Override public int getSegmentCount() { return vector.length; } + @Override Comparable<?>[] getVector() { return vector; } + @Override public int compareTo(Version v) { BasicVersion ov = (BasicVersion) v; return VersionVector.compare(vector, padValue, ov.getVector(), ov.getPad()); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java index 5d36a1913..13eb67642 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ProvidedCapability.java @@ -51,8 +51,7 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider this.attributes = new HashMap<>(attrs); // Verify the name - Assert.isTrue(attributes.containsKey(namespace) && (attributes.get(namespace) instanceof String), - NLS.bind(Messages.provided_capability_name_not_defined, namespace)); + Assert.isTrue(attributes.containsKey(namespace) && (attributes.get(namespace) instanceof String), NLS.bind(Messages.provided_capability_name_not_defined, namespace)); // Verify the version Object version = attributes.get(ATTRIBUTE_VERSION); @@ -72,6 +71,7 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider attributes.put(ATTRIBUTE_VERSION, version == null ? Version.emptyVersion : version); } + @Override public boolean equals(Object other) { if (other == null) { return false; @@ -94,26 +94,32 @@ public class ProvidedCapability implements IProvidedCapability, IMemberProvider return true; } + @Override public String getNamespace() { return namespace; } + @Override public String getName() { return (String) attributes.get(namespace); } + @Override public Version getVersion() { return (Version) attributes.get(ATTRIBUTE_VERSION); } + @Override public Map<String, Object> getAttributes() { return attributes; } + @Override public int hashCode() { return namespace.hashCode() * attributes.hashCode(); } + @Override public String toString() { StringBuilder str = new StringBuilder(); str.append(namespace); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java index 2a97d36d5..984720c47 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -129,6 +129,7 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider this.description = description; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -146,10 +147,12 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider return min == other.getMin() && max == other.getMax() && greedy == other.isGreedy() && matchExpression.equals(other.getMatches()); } + @Override public String getName() { return (String) matchExpression.getParameters()[0]; } + @Override public String getNamespace() { return (String) matchExpression.getParameters()[1]; } @@ -160,10 +163,12 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider * will satisfy the capability. * @return the range of versions that satisfy this required capability. */ + @Override public VersionRange getRange() { return extractRange(matchExpression); } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -172,10 +177,12 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider return result; } + @Override public boolean isGreedy() { return greedy; } + @Override public String toString() { StringBuffer result = new StringBuffer(); if (matchExpression.getParameters().length == 0) @@ -212,22 +219,27 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider return result.toString(); } + @Override public int getMin() { return min; } + @Override public int getMax() { return max; } + @Override public IMatchExpression<IInstallableUnit> getMatches() { return matchExpression; } + @Override public IMatchExpression<IInstallableUnit> getFilter() { return filter; } + @Override public boolean isMatch(IInstallableUnit candidate) { return matchExpression.isMatch(candidate); } @@ -276,6 +288,7 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider return expr.equals(allVersionsExpression) || expr.equals(range_II_Expression) || expr.equals(range_IN_Expression) || expr.equals(range_NI_Expression) || expr.equals(range_NN_Expression) || expr.equals(strictVersionExpression) || expr.equals(openEndedExpression) || expr.equals(openEndedNonInclusiveExpression); } + @Override public Object getMember(String memberName) { // It is OK to use identity comparisons here since // a) All constant valued strings are always interned @@ -294,6 +307,7 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider throw new IllegalArgumentException("No such member: " + memberName); //$NON-NLS-1$ } + @Override public String getDescription() { return description; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java index eb3c5cfe6..aca051962 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequirementChange.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,14 +23,17 @@ public class RequirementChange implements IRequirementChange { this.newValue = newValue2; } + @Override public IRequiredCapability applyOn() { return applyOn; } + @Override public IRequiredCapability newValue() { return newValue; } + @Override public boolean matches(IRequiredCapability toMatch) { if (!toMatch.getNamespace().equals(applyOn.getNamespace())) return false; @@ -42,6 +45,7 @@ public class RequirementChange implements IRequirementChange { return toMatch.getRange().intersect(applyOn.getRange()) != null; } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -50,6 +54,7 @@ public class RequirementChange implements IRequirementChange { return result; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -71,6 +76,7 @@ public class RequirementChange implements IRequirementChange { return true; } + @Override public String toString() { return applyOn + " --> " + newValue; //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java index 7e036b69e..f641546b7 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,12 +34,13 @@ public class ResolvedInstallableUnit implements IInstallableUnit, IMemberProvide this.fragments = fragments == null ? NO_IU : fragments; } + @Override public Collection<IInstallableUnitFragment> getFragments() { int fcount = fragments.length; if (fcount == 0) return Collections.<IInstallableUnitFragment> emptyList(); - ArrayList<IInstallableUnitFragment> result = new ArrayList<IInstallableUnitFragment>(fcount); + ArrayList<IInstallableUnitFragment> result = new ArrayList<>(fcount); result.addAll(Arrays.asList(fragments)); for (int i = 0; i < fcount; i++) { IInstallableUnit fragment = fragments[i]; @@ -49,86 +50,100 @@ public class ResolvedInstallableUnit implements IInstallableUnit, IMemberProvide return result; } + @Override public Collection<IArtifactKey> getArtifacts() { return original.getArtifacts(); } + @Override public IMatchExpression<IInstallableUnit> getFilter() { return original.getFilter(); } + @Override public String getId() { return original.getId(); } + @Override public String getProperty(String key) { return original.getProperty(key); } + @Override public Map<String, String> getProperties() { return original.getProperties(); } + @Override public String getProperty(String key, String locale) { return original.getProperty(key, locale); } + @Override public Collection<IProvidedCapability> getProvidedCapabilities() { Collection<IProvidedCapability> originalCapabilities = original.getProvidedCapabilities(); if (fragments.length == 0) return originalCapabilities; - ArrayList<IProvidedCapability> result = new ArrayList<IProvidedCapability>(originalCapabilities); + ArrayList<IProvidedCapability> result = new ArrayList<>(originalCapabilities); for (int i = 0; i < fragments.length; i++) result.addAll(fragments[i].getProvidedCapabilities()); return result; } + @Override public Collection<IRequirement> getRequirements() { Collection<IRequirement> originalCapabilities = original.getRequirements(); if (fragments.length == 0) return originalCapabilities; - ArrayList<IRequirement> result = new ArrayList<IRequirement>(originalCapabilities); + ArrayList<IRequirement> result = new ArrayList<>(originalCapabilities); for (int i = 0; i < fragments.length; i++) result.addAll(fragments[i].getRequirements()); return result; } + @Override public Collection<IRequirement> getMetaRequirements() { Collection<IRequirement> originalCapabilities = original.getMetaRequirements(); if (fragments.length == 0) return originalCapabilities; - ArrayList<IRequirement> result = new ArrayList<IRequirement>(originalCapabilities); + ArrayList<IRequirement> result = new ArrayList<>(originalCapabilities); for (int i = 0; i < fragments.length; i++) result.addAll(fragments[i].getMetaRequirements()); return result; } + @Override public Collection<ITouchpointData> getTouchpointData() { Collection<ITouchpointData> originalTouchpointData = original.getTouchpointData(); if (fragments.length == 0) return originalTouchpointData; - ArrayList<ITouchpointData> result = new ArrayList<ITouchpointData>(originalTouchpointData); + ArrayList<ITouchpointData> result = new ArrayList<>(originalTouchpointData); for (int i = 0; i < fragments.length; i++) result.addAll(fragments[i].getTouchpointData()); return result; } + @Override public ITouchpointType getTouchpointType() { return original.getTouchpointType(); } + @Override public Version getVersion() { return original.getVersion(); } + @Override public boolean isSingleton() { return original.isSingleton(); } + @Override public boolean equals(Object obj) { //TODO This is pretty ugly.... boolean result = original.equals(obj); @@ -139,11 +154,13 @@ public class ResolvedInstallableUnit implements IInstallableUnit, IMemberProvide return false; } + @Override public int hashCode() { // TODO Auto-generated method stub return original.hashCode(); } + @Override public String toString() { return "[R]" + original.toString(); //$NON-NLS-1$ } @@ -152,6 +169,7 @@ public class ResolvedInstallableUnit implements IInstallableUnit, IMemberProvide return original; } + @Override public int compareTo(IInstallableUnit other) { int cmp = getId().compareTo(other.getId()); if (cmp == 0) @@ -159,34 +177,42 @@ public class ResolvedInstallableUnit implements IInstallableUnit, IMemberProvide return cmp; } + @Override public boolean isResolved() { return true; } + @Override public IInstallableUnit unresolved() { return original.unresolved(); } + @Override public IUpdateDescriptor getUpdateDescriptor() { return original.getUpdateDescriptor(); } + @Override public Collection<ILicense> getLicenses() { return original.getLicenses(); } + @Override public Collection<ILicense> getLicenses(String locale) { return original.getLicenses(locale); } + @Override public ICopyright getCopyright() { return original.getCopyright(); } + @Override public ICopyright getCopyright(String locale) { return original.getCopyright(locale); } + @Override public boolean satisfies(IRequirement candidate) { return candidate.isMatch(this); } @@ -194,6 +220,7 @@ public class ResolvedInstallableUnit implements IInstallableUnit, IMemberProvide /* (non-Javadoc) * @see org.eclipse.equinox.p2.metadata.expression.IMemberProvider#getMember(java.lang.String) */ + @Override public Object getMember(String memberName) { if (MEMBER_FRAGMENTS == memberName) return fragments; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointData.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointData.java index fd1896c71..737c2741c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointData.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,13 +11,10 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata; -import org.eclipse.equinox.p2.metadata.MetadataFactory; - import java.util.Collections; import java.util.Map; import java.util.Map.Entry; -import org.eclipse.equinox.p2.metadata.ITouchpointData; -import org.eclipse.equinox.p2.metadata.ITouchpointInstruction; +import org.eclipse.equinox.p2.metadata.*; /** * Touchpoint data instances contain the additional information needed by a touchpoint @@ -37,10 +34,12 @@ public class TouchpointData implements ITouchpointData { */ private Map<String, ITouchpointInstruction> instructions; + @Override public int hashCode() { return 31 * 1 + ((instructions == null) ? 0 : instructions.hashCode()); } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -67,6 +66,7 @@ public class TouchpointData implements ITouchpointData { /** * Returns the touchpoint instruction corresponding to the given key. */ + @Override public ITouchpointInstruction getInstruction(String instructionKey) { return instructions.get(instructionKey); } @@ -77,6 +77,7 @@ public class TouchpointData implements ITouchpointData { * * @return the touchpoint instructions */ + @Override public Map<String, ITouchpointInstruction> getInstructions() { return Collections.unmodifiableMap(instructions); } @@ -84,6 +85,7 @@ public class TouchpointData implements ITouchpointData { /** * Returns a string representation of the touchpoint data for debugging purposes only. */ + @Override public String toString() { StringBuffer result = new StringBuffer(); for (Entry<String, ITouchpointInstruction> instruction : instructions.entrySet()) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java index afd14cfeb..af1ffd58b 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,11 +11,10 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata; -import org.eclipse.equinox.p2.metadata.MetadataFactory; - import java.util.Map; import java.util.Map.Entry; import org.eclipse.equinox.p2.metadata.ITouchpointInstruction; +import org.eclipse.equinox.p2.metadata.MetadataFactory; /** * A touchpoint instruction contains either a sequence of instruction statements @@ -113,6 +112,7 @@ public class TouchpointInstruction implements ITouchpointInstruction { this.importAttribute = importAttribute; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -140,15 +140,18 @@ public class TouchpointInstruction implements ITouchpointInstruction { * * @return The body of this touchpoint instruction */ + @Override public String getBody() { return body; } //TODO What is this? Please doc + @Override public String getImportAttribute() { return importAttribute; } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -160,6 +163,7 @@ public class TouchpointInstruction implements ITouchpointInstruction { /** * Returns a string representation of this instruction for debugging purposes only. */ + @Override public String toString() { return "Instruction[" + body + ',' + importAttribute + ']'; //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java index 42a32941e..e289e16ff 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,9 +11,8 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata; -import org.eclipse.equinox.p2.metadata.Version; - import org.eclipse.equinox.p2.metadata.ITouchpointType; +import org.eclipse.equinox.p2.metadata.Version; /** * Identifies a particular touchpoint. A touchpoint is identified by an id @@ -28,6 +27,7 @@ public class TouchpointType implements ITouchpointType { this.version = aVersion; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -39,18 +39,22 @@ public class TouchpointType implements ITouchpointType { return id.equals(other.getId()) && version.equals(other.getVersion()); } + @Override public String getId() { return id; } + @Override public Version getVersion() { return version; } + @Override public int hashCode() { return 31 * id.hashCode() + version.hashCode(); } + @Override public String toString() { return "Touchpoint: " + id + ' ' + getVersion(); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java index fbe447577..ad7c16790 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,7 +43,7 @@ public class TranslationSupport { // Cache the IU fragments that provide localizations for a given locale. // Map<String,SoftReference<IQueryResult>>: locale => soft reference to a queryResult - private final Map<String, SoftReference<IQueryResult<IInstallableUnit>>> localeCollectorCache = new HashMap<String, SoftReference<IQueryResult<IInstallableUnit>>>(2); + private final Map<String, SoftReference<IQueryResult<IInstallableUnit>>> localeCollectorCache = new HashMap<>(2); private LocaleProvider localeProvider; private boolean loggedMissingSource = false; @@ -78,7 +78,7 @@ public class TranslationSupport { /** */ private List<String> buildLocaleVariants(String locale) { - ArrayList<String> result = new ArrayList<String>(4); + ArrayList<String> result = new ArrayList<>(4); int lastSeparator; while (true) { result.add(locale); @@ -244,7 +244,7 @@ public class TranslationSupport { IQuery<IInstallableUnit> iuQuery = QueryUtil.<IInstallableUnit> createMatchQuery(IInstallableUnitFragment.class, capabilityMatch, NAMESPACE_IU_LOCALIZATION, localeVariants); IQueryResult<IInstallableUnit> collected = fragmentSource.query(iuQuery, null); - localeCollectorCache.put(locale, new SoftReference<IQueryResult<IInstallableUnit>>(collected)); + localeCollectorCache.put(locale, new SoftReference<>(collected)); return collected; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java index 8b261fbeb..99bd9533f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/UpdateDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2008, 2017 IBM Corporation and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -28,22 +28,27 @@ public class UpdateDescriptor implements IUpdateDescriptor { this.location = location; } + @Override public String getDescription() { return description; } + @Override public int getSeverity() { return severity; } + @Override public boolean isUpdateOf(IInstallableUnit iu) { return descriptors.iterator().next().isMatch(iu); } + @Override public Collection<IMatchExpression<IInstallableUnit>> getIUsBeingUpdated() { return descriptors; } + @Override public URI getLocation() { return location; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormat.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormat.java index 2fdc5e958..2c11c7a35 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormat.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormat.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -253,14 +253,17 @@ public class VersionFormat implements IVersionFormat, Serializable { return new TreeInfo(topFragment, start); } + @Override public boolean equals(Object o) { return this == o || o instanceof VersionFormat && toString().equals(o.toString()); } + @Override public int hashCode() { return 11 * toString().hashCode(); } + @Override public Version parse(String version) { List<Comparable<?>> vector = parse(version, 0, version.length()); return (this == OSGI_FORMAT) ? OSGiVersion.fromVector(vector) : OmniVersion.fromVector(vector, this, version); @@ -270,7 +273,7 @@ public class VersionFormat implements IVersionFormat, Serializable { if (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<Comparable<?>>(5); + 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))); entries.add(VersionParser.removeRedundantTrail(entries, info.getPadValue())); @@ -294,6 +297,7 @@ public class VersionFormat implements IVersionFormat, Serializable { /** * Returns the string representation of this compiled format */ + @Override public synchronized String toString() { if (fmtString == null) { StringBuffer sb = new StringBuffer(); @@ -302,6 +306,7 @@ public class VersionFormat implements IVersionFormat, Serializable { return fmtString; } + @Override public synchronized void toString(StringBuffer sb) { if (fmtString != null) sb.append(fmtString); @@ -330,6 +335,7 @@ class RawFormat extends VersionFormat { * Parse but do not assign this format as the Version format nor the version * string as the original. */ + @Override public Version parse(String version) { List<Comparable<?>> vector = parse(version, 0, version.length()); return OmniVersion.fromVector(vector, null, null); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java index 19ce082ed..fe2556949 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -124,10 +124,12 @@ class VersionFormatParser { this.qualifier = qualifier; } + @Override public final boolean equals(Object f) { return f == this || getClass().equals(f.getClass()) && qualifier.equals(((Fragment) f).qualifier); } + @Override public final int hashCode() { return 11 * qualifier.hashCode(); } @@ -136,6 +138,7 @@ class VersionFormatParser { return false; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); toString(sb); @@ -188,6 +191,7 @@ class VersionFormatParser { this.max = max; } + @Override public boolean equals(Object o) { if (o == this) return true; @@ -197,10 +201,12 @@ class VersionFormatParser { return min == oq.min && max == oq.max; } + @Override public int hashCode() { return 31 * min + 67 * max; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); toString(sb); @@ -339,6 +345,7 @@ class VersionFormatParser { super(instr, qualifier); } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); maxPos = checkRange(pos, maxPos); @@ -406,6 +413,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { sb.append('a'); super.toString(sb); @@ -441,6 +449,7 @@ class VersionFormatParser { return true; } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); if (pos < maxPos && isMatch(version, pos)) { @@ -452,6 +461,7 @@ class VersionFormatParser { return false; } + @Override void toString(StringBuffer sb) { sb.append('d'); if (delimChars != null) @@ -554,10 +564,12 @@ class VersionFormatParser { } } + @Override Comparable<?> getDefaultValue() { return defaultValue; } + @Override Comparable<?> getPadValue() { return padValue; } @@ -566,12 +578,14 @@ class VersionFormatParser { return ignored; } + @Override void setDefaults(List<Comparable<?>> segments) { Comparable<?> defaultVal = getDefaultValue(); if (defaultVal != null) segments.add(defaultVal); } + @Override void toString(StringBuffer sb) { if (ignored) { sb.append('='); @@ -604,17 +618,20 @@ class VersionFormatParser { this.array = array; } + @Override public boolean isGroup() { return !array; } + @Override Fragment getFirstLeaf() { return fragments[0].getFirstLeaf(); } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { if (array) { - ArrayList<Comparable<?>> subSegs = new ArrayList<Comparable<?>>(); + ArrayList<Comparable<?>> subSegs = new ArrayList<>(); boolean success = fragments[0].getQualifier().parse(fragments, 0, subSegs, version, maxPos, info); if (!success || subSegs.isEmpty()) return false; @@ -639,6 +656,7 @@ class VersionFormatParser { return false; } + @Override void setDefaults(List<Comparable<?>> segments) { Comparable<?> dflt = getDefaultValue(); if (dflt != null) { @@ -652,6 +670,7 @@ class VersionFormatParser { } } + @Override void toString(StringBuffer sb) { if (array) { sb.append('<'); @@ -684,6 +703,7 @@ class VersionFormatParser { this.string = string; } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); int litLen = string.length(); @@ -698,6 +718,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { String str = string; if (str.length() != 1) { @@ -741,6 +762,7 @@ class VersionFormatParser { this.signed = signed; } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); maxPos = checkRange(pos, maxPos); @@ -801,6 +823,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { sb.append(signed ? 'N' : 'n'); super.toString(sb); @@ -814,6 +837,7 @@ class VersionFormatParser { super(null, qualifier); } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); if (pos >= maxPos || version.charAt(pos) != 'p') @@ -830,6 +854,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { sb.append('p'); super.toString(sb); @@ -843,6 +868,7 @@ class VersionFormatParser { super(instr, qualifier); } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); if (pos >= maxPos) @@ -899,6 +925,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { sb.append('q'); super.toString(sb); @@ -971,6 +998,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { if (characters != null) appendCharacterRange(sb, characters, inverted); @@ -999,6 +1027,7 @@ class VersionFormatParser { super(processing, qualifier); } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int[] position = new int[] {info.getPosition()}; Comparable<?> v = VersionParser.parseRawElement(version, position, maxPos); @@ -1011,6 +1040,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { sb.append('r'); super.toString(sb); @@ -1065,6 +1095,7 @@ class VersionFormatParser { return false; } + @Override boolean parseOne(List<Comparable<?>> segments, String version, int maxPos, TreeInfo info) { int pos = info.getPosition(); maxPos = checkRange(pos, maxPos); @@ -1128,6 +1159,7 @@ class VersionFormatParser { return true; } + @Override void toString(StringBuffer sb) { sb.append(anyChar ? 'S' : 's'); super.toString(sb); @@ -1152,7 +1184,7 @@ class VersionFormatParser { start = pos; current = pos; eos = maxPos; - currentList = new ArrayList<Fragment>(); + currentList = new ArrayList<>(); while (current < eos) parseFragment(); @@ -1233,7 +1265,7 @@ class VersionFormatParser { private void parseBracketGroup() throws VersionFormatException { List<Fragment> saveList = currentList; - currentList = new ArrayList<Fragment>(); + currentList = new ArrayList<>(); while (current < eos && format.charAt(current) != ']') parseFragment(); @@ -1314,8 +1346,8 @@ class VersionFormatParser { private void parseEnum(Instructions processing) throws VersionFormatException { ++current; - ArrayList<List<String>> identifiers = new ArrayList<List<String>>(); - ArrayList<String> idents = new ArrayList<String>(); + ArrayList<List<String>> identifiers = new ArrayList<>(); + ArrayList<String> idents = new ArrayList<>(); StringBuffer sb = new StringBuffer(); for (;;) { if (current >= eos) @@ -1343,7 +1375,7 @@ class VersionFormatParser { break; // c must be ',' at this point - idents = new ArrayList<String>(); + idents = new ArrayList<>(); } boolean enumCaseSensitive = true; @@ -1366,7 +1398,7 @@ class VersionFormatParser { // Ensure that all identifiers are unique and make them // lower case if necessary - HashSet<String> unique = new HashSet<String>(); + HashSet<String> unique = new HashSet<>(); int ordinal = identifiers.size(); while (--ordinal >= 0) { List<String> ids = identifiers.get(ordinal); @@ -1432,7 +1464,7 @@ class VersionFormatParser { private void parseGroup(boolean array) throws VersionFormatException { List<Fragment> saveList = currentList; - currentList = new ArrayList<Fragment>(); + currentList = new ArrayList<>(); char expectedEnd = array ? '>' : ')'; while (current < eos && format.charAt(current) != expectedEnd) parseFragment(); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java index 49fda092c..5120103c3 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -320,7 +320,7 @@ public abstract class VersionParser { if (c == '>') return null; - ArrayList<Comparable<?>> rawList = new ArrayList<Comparable<?>>(); + ArrayList<Comparable<?>> rawList = new ArrayList<>(); boolean padMarkerSeen = (c == 'p'); if (padMarkerSeen) { if (++pos >= maxPos) @@ -365,7 +365,7 @@ public abstract class VersionParser { private static Comparable<?> parseRawEnum(String value, int[] position, int maxPos) { int pos = position[0]; - ArrayList<List<String>> identifiers = new ArrayList<List<String>>(); + ArrayList<List<String>> identifiers = new ArrayList<>(); int ordinal = -1; StringBuffer sb = new StringBuffer(); for (;;) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionVector.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionVector.java index f2d5fec19..f98bf67b3 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionVector.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionVector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,6 +31,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { // Empty constructor } + @Override public int compareTo(Object o) { return o == this ? 0 : (o == MAX_VALUE || o instanceof Integer || o instanceof EnumDefinition.EnumSegment || o instanceof VersionVector ? -1 : 1); } @@ -40,6 +41,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { return MAXS_VALUE; } + @Override public String toString() { return "m"; //$NON-NLS-1$ } @@ -52,6 +54,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { // Empty constructor } + @Override public int compareTo(Object o) { return o == this ? 0 : 1; } @@ -61,6 +64,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { return MAX_VALUE; } + @Override public String toString() { return "M"; //$NON-NLS-1$ } @@ -73,6 +77,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { // Empty constructor } + @Override public int compareTo(Object o) { return o == this ? 0 : -1; } @@ -81,6 +86,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { return MIN_VALUE; } + @Override public String toString() { return "-M"; //$NON-NLS-1$ } @@ -245,6 +251,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { this.padValue = (pad == MIN_VALUE) ? null : pad; } + @Override public int compareTo(VersionVector ov) { if (ov == this) return 0; @@ -252,6 +259,7 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { return compare(vector, padValue, ov.vector, ov.padValue); } + @Override public boolean equals(Object o) { if (o == this) return true; @@ -298,10 +306,12 @@ public class VersionVector implements Comparable<VersionVector>, Serializable { return vector; } + @Override public int hashCode() { return hashCode(vector, padValue); } + @Override public String toString() { StringBuffer sb = new StringBuffer(); toString(sb); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/All.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/All.java index f62e28e19..c17456bf1 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/All.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/All.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ final class All extends CollectionFilter { super(collection, lambda); } + @Override protected Object evaluate(IEvaluationContext context, Iterator<?> itor) { Variable variable = lambda.getItemVariable(); while (itor.hasNext()) { @@ -32,10 +33,12 @@ final class All extends CollectionFilter { return Boolean.TRUE; } + @Override public int getExpressionType() { return TYPE_ALL; } + @Override public String getOperator() { return KEYWORD_ALL; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/And.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/And.java index 7e8adf20e..93a0c9cc1 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/And.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/And.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ final class And extends NAry { super(assertLength(operands, 2, OPERATOR_AND)); } + @Override public Object evaluate(IEvaluationContext context) { for (int idx = 0; idx < operands.length; ++idx) { if (operands[idx].evaluate(context) != Boolean.TRUE) @@ -29,18 +30,22 @@ final class And extends NAry { return Boolean.TRUE; } + @Override public int getExpressionType() { return TYPE_AND; } + @Override public String getOperator() { return OPERATOR_AND; } + @Override public int getPriority() { return PRIORITY_AND; } + @Override public void toLDAPString(StringBuffer buf) { buf.append("(&"); //$NON-NLS-1$ for (int idx = 0; idx < operands.length; ++idx) diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Array.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Array.java index 8f0ef7044..1e354f177 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Array.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Array.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,10 +27,12 @@ final class Array extends NAry { this.context = context; } + @Override public boolean hasNext() { return pos + 1 < operands.length; } + @Override public Object next() { if (++pos >= operands.length) { --pos; @@ -39,6 +41,7 @@ final class Array extends NAry { return operands[pos].evaluate(context); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -48,28 +51,34 @@ final class Array extends NAry { super(assertLength(operands, 0, OPERATOR_ARRAY)); } + @Override public Object evaluate(IEvaluationContext context) { return evaluateAsIterator(context); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { return new ArrayIterator(context); } + @Override public int getExpressionType() { return TYPE_ARRAY; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { bld.append('['); elementsToString(bld, rootVariable, operands); bld.append(']'); } + @Override public String getOperator() { return OPERATOR_ARRAY; } + @Override public int getPriority() { return PRIORITY_FUNCTION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Assignment.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Assignment.java index 2724e2920..54b7398f3 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Assignment.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Assignment.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,24 +21,29 @@ class Assignment extends Binary { super(variable, expression); } + @Override public final Object evaluate(IEvaluationContext context) { Object value = rhs.evaluate(context); context.setValue(lhs, value); return value; } + @Override public int getExpressionType() { return TYPE_ASSIGNMENT; } + @Override public int getPriority() { return IExpressionConstants.PRIORITY_ASSIGNMENT; } + @Override public String getOperator() { return OPERATOR_ASSIGN; } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Iterator<?> value = rhs.evaluateAsIterator(context); context.setValue(lhs, value); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java index 794eaf5c8..4ad44ee35 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,6 +26,7 @@ class At extends Binary { super(lhs, rhs); } + @Override public Object evaluate(org.eclipse.equinox.p2.metadata.expression.IEvaluationContext context) { Object lval; if (lhs instanceof DynamicMember) { @@ -68,6 +69,7 @@ class At extends Binary { throw new IllegalArgumentException("Unable to use [] on a " + lval.getClass().getName()); //$NON-NLS-1$ } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Object value = evaluate(context); if (!(value instanceof Iterator<?>)) @@ -75,10 +77,12 @@ class At extends Binary { return (Iterator<?>) value; } + @Override public int getExpressionType() { return TYPE_AT; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { appendOperand(bld, rootVariable, lhs, getPriority()); bld.append('['); @@ -86,10 +90,12 @@ class At extends Binary { bld.append(']'); } + @Override public String getOperator() { return OPERATOR_AT; } + @Override public int getPriority() { return PRIORITY_MEMBER; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Binary.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Binary.java index 546ebf564..5e9719064 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Binary.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Binary.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,10 +27,12 @@ public abstract class Binary extends Expression { this.rhs = rhs; } + @Override public boolean accept(IExpressionVisitor visitor) { return super.accept(visitor) && lhs.accept(visitor) && rhs.accept(visitor); } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) { @@ -42,6 +44,7 @@ public abstract class Binary extends Expression { return cmp; } + @Override public boolean equals(Object o) { if (super.equals(o)) { Binary bo = (Binary) o; @@ -50,15 +53,18 @@ public abstract class Binary extends Expression { return false; } + @Override public int getPriority() { return PRIORITY_BINARY; // Default priority } + @Override public int hashCode() { int result = 31 + lhs.hashCode(); return 31 * result + rhs.hashCode(); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { appendOperand(bld, rootVariable, lhs, getPriority()); bld.append(' '); @@ -133,6 +139,7 @@ public abstract class Binary extends Expression { throw new UnsupportedOperationException(); } + @Override int countAccessToEverything() { return lhs.countAccessToEverything() + rhs.countAccessToEverything(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/BooleanFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/BooleanFunction.java index 6749180f1..06e01380c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/BooleanFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/BooleanFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.expression; - - /** * A function that obtains a class based on a String */ @@ -21,10 +19,12 @@ public final class BooleanFunction extends Function { super(assertLength(operands, 1, 1, KEYWORD_BOOLEAN)); } + @Override boolean assertSingleArgumentClass(Object v) { return v instanceof String || v instanceof Boolean; } + @Override Object createInstance(Object arg) { if (arg instanceof String) return Boolean.valueOf("true".equalsIgnoreCase((String) arg)); //$NON-NLS-1$ @@ -33,6 +33,7 @@ public final class BooleanFunction extends Function { return Boolean.FALSE; } + @Override public String getOperator() { return KEYWORD_BOOLEAN; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ClassFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ClassFunction.java index 87e9bfee1..0d0a7961e 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ClassFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ClassFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.expression; - - /** * A function that obtains a class based on a String */ @@ -21,10 +19,12 @@ public final class ClassFunction extends Function { super(assertLength(operands, 1, 1, KEYWORD_CLASS)); } + @Override boolean assertSingleArgumentClass(Object v) { return v instanceof String; } + @Override Object createInstance(Object arg) { try { return Class.forName((String) arg); @@ -33,6 +33,7 @@ public final class ClassFunction extends Function { } } + @Override public String getOperator() { return KEYWORD_CLASS; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java index b1eb3185f..6cb8008f7 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.equinox.p2.metadata.Version; */ public abstract class CoercingComparator<T> { static class BooleanCoercer extends CoercingComparator<Boolean> { + @Override public int compare(Boolean o1, Boolean o2) { return o1.booleanValue() == o2.booleanValue() ? 0 : (o1.booleanValue() ? 1 : -1); } @@ -54,6 +55,7 @@ public abstract class CoercingComparator<T> { } static class ClassCoercer extends CoercingComparator<Class<?>> { + @Override public int compare(Class<?> o1, Class<?> o2) { return o1.getName().compareTo(o2.getName()); } @@ -123,6 +125,7 @@ public abstract class CoercingComparator<T> { } static class IntegerCoercer extends CoercingComparator<Integer> { + @Override public int compare(Integer o1, Integer o2) { return o1.compareTo(o2); } @@ -155,6 +158,7 @@ public abstract class CoercingComparator<T> { } static class LongCoercer extends CoercingComparator<Long> { + @Override public int compare(Long o1, Long o2) { return o1.compareTo(o2); } @@ -187,6 +191,7 @@ public abstract class CoercingComparator<T> { } static class StringCoercer extends CoercingComparator<String> { + @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } @@ -210,10 +215,12 @@ public abstract class CoercingComparator<T> { } static class VersionCoercer extends CoercingComparator<Version> { + @Override public int compare(Version o1, Version o2) { return o1.compareTo(o2); } + @Override boolean canCoerceTo(Class<?> cls) { return Version.class.isAssignableFrom(cls); } @@ -252,6 +259,7 @@ public abstract class CoercingComparator<T> { this.accessible = accessible; } + @Override public Object run() { accessible.setAccessible(true); return null; @@ -348,7 +356,7 @@ public abstract class CoercingComparator<T> { int top = coercers.length; CoercingComparator<?>[] nc = new CoercingComparator<?>[top + 1]; System.arraycopy(coercers, 0, nc, 1, top); - CoercingComparator<V> cv = (CoercingComparator<V>) new FromStringCoercer<Comparable<Object>>(cClass, constructor); + CoercingComparator<V> cv = (CoercingComparator<V>) new FromStringCoercer<>(cClass, constructor); nc[0] = cv; coercers = nc; return cv; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Collect.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Collect.java index e5d7812fc..22abc8cf2 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Collect.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Collect.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,15 +30,18 @@ final class Collect extends CollectionFilter { this.innerIterator = iterator; } + @Override public boolean hasNext() { return innerIterator.hasNext(); } + @Override public Object next() { context.setValue(variable, innerIterator.next()); return lambda.evaluate(context); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -48,18 +51,22 @@ final class Collect extends CollectionFilter { super(collection, lambda); } + @Override public Object evaluate(IEvaluationContext context, Iterator<?> itor) { return evaluateAsIterator(context, itor); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context, Iterator<?> itor) { return new CollectIterator(context, itor); } + @Override public int getExpressionType() { return TYPE_COLLECT; } + @Override public String getOperator() { return KEYWORD_COLLECT; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CollectionFilter.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CollectionFilter.java index c671214fc..c56215f1a 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CollectionFilter.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CollectionFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,10 +37,12 @@ public abstract class CollectionFilter extends Unary { this.lambda = lambda; } + @Override public boolean accept(IExpressionVisitor visitor) { return super.accept(visitor) && lambda.accept(visitor); } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -48,33 +50,39 @@ public abstract class CollectionFilter extends Unary { return cmp; } + @Override public boolean equals(Object o) { return super.equals(o) && lambda.equals(((CollectionFilter) o).lambda); } + @Override public final Object evaluate(IEvaluationContext context) { Iterator<?> lval = getInnerIterator(context); context = lambda.prolog(context); return evaluate(context, lval); } + @Override public final Iterator<?> evaluateAsIterator(IEvaluationContext context) { Iterator<?> lval = getInnerIterator(context); context = lambda.prolog(context); return evaluateAsIterator(context, lval); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { appendProlog(bld, rootVariable, operand, getOperator()); appendOperand(bld, rootVariable, lambda, PRIORITY_LAMBDA); bld.append(')'); } + @Override public int hashCode() { int result = 31 + operand.hashCode(); return 31 * result + lambda.hashCode(); } + @Override public int getPriority() { return PRIORITY_COLLECTION; } @@ -128,6 +136,7 @@ public abstract class CollectionFilter extends Unary { return itor; } + @Override int countAccessToEverything() { return operand.countAccessToEverything() + lambda.countAccessToEverything(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Compare.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Compare.java index 5ee16f77b..f08c1c3f3 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Compare.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Compare.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,6 +31,7 @@ final class Compare extends Binary { this.equalOK = equalOK; } + @Override public Object evaluate(IEvaluationContext context) { Object lhsVal = lhs.evaluate(context); Object rhsVal = rhs.evaluate(context); @@ -59,14 +60,17 @@ final class Compare extends Binary { return Boolean.valueOf(cmpResult == 0 ? equalOK : (cmpResult < 0 ? compareLess : !compareLess)); } + @Override public int getExpressionType() { return compareLess ? (equalOK ? TYPE_LESS_EQUAL : TYPE_LESS) : (equalOK ? TYPE_GREATER_EQUAL : TYPE_GREATER); } + @Override public String getOperator() { return compareLess ? (equalOK ? OPERATOR_LT_EQUAL : OPERATOR_LT) : (equalOK ? OPERATOR_GT_EQUAL : OPERATOR_GT); } + @Override public void toLDAPString(StringBuffer buf) { if (!equalOK) buf.append("(!"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CompoundIterator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CompoundIterator.java index 4aaf2a417..bf3ab6ebe 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CompoundIterator.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CompoundIterator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 - 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,10 +39,12 @@ public class CompoundIterator<T> implements Iterator<T> { this.iteratorIterator = iterator; } + @Override public boolean hasNext() { return positionNext(); } + @Override public T next() { if (!positionNext()) throw new NoSuchElementException(); @@ -57,6 +59,7 @@ public class CompoundIterator<T> implements Iterator<T> { * will always yield an exception. * @throws UnsupportedOperationException */ + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Condition.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Condition.java index 36fb854b4..906fbc542 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Condition.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Condition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,22 +24,27 @@ final class Condition extends Binary { this.ifFalse = ifFalse; } + @Override public boolean equals(Object o) { return super.equals(o) && ifFalse.equals(((Condition) o).ifFalse); } + @Override public Object evaluate(IEvaluationContext context) { return lhs.evaluate(context) == Boolean.TRUE ? rhs.evaluate(context) : ifFalse.evaluate(context); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { return lhs.evaluate(context) == Boolean.TRUE ? rhs.evaluateAsIterator(context) : ifFalse.evaluateAsIterator(context); } + @Override public int hashCode() { return super.hashCode() * 31 + ifFalse.hashCode(); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { super.toString(bld, rootVariable); bld.append(' '); @@ -48,14 +53,17 @@ final class Condition extends Binary { appendOperand(bld, rootVariable, ifFalse, getPriority()); } + @Override public int getExpressionType() { return TYPE_CONDITION; } + @Override public String getOperator() { return OPERATOR_IF; } + @Override public int getPriority() { return IExpressionConstants.PRIORITY_CONDITION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java index abad7485d..56ab496fd 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,58 +28,70 @@ public class ContextExpression<T> extends Unary implements IContextExpression<T> this.parameters = parameters == null ? noParams : parameters; } + @Override public boolean accept(IExpressionVisitor visitor) { return super.accept(visitor) && operand.accept(visitor); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { operand.toString(bld, rootVariable); } + @Override public IEvaluationContext createContext(Class<? extends T> elementClass, IIndexProvider<T> indexProvider) { Variable everything = ExpressionFactory.EVERYTHING; IEvaluationContext context = EvaluationContext.create(parameters, everything); - context.setValue(everything, new Everything<T>(elementClass, indexProvider)); + context.setValue(everything, new Everything<>(elementClass, indexProvider)); context.setIndexProvider(indexProvider); return context; } + @Override public IEvaluationContext createContext(Class<? extends T> elementClass, Iterator<T> iterator) { Variable everything = ExpressionFactory.EVERYTHING; IEvaluationContext context = EvaluationContext.create(parameters, everything); - context.setValue(everything, new Everything<T>(elementClass, iterator, operand)); + context.setValue(everything, new Everything<>(elementClass, iterator, operand)); return context; } + @Override public Object evaluate(IEvaluationContext context) { return operand.evaluate(parameters.length == 0 ? context : EvaluationContext.create(context, parameters)); } + @Override public int getExpressionType() { return 0; } + @Override public String getOperator() { throw new UnsupportedOperationException(); } + @Override public int getPriority() { return operand.getPriority(); } + @Override public Object[] getParameters() { return parameters; } + @Override public int hashCode() { return operand.hashCode(); } + @Override @SuppressWarnings("unchecked") public Iterator<T> iterator(IEvaluationContext context) { return (Iterator<T>) operand.evaluateAsIterator(context); } + @Override public void toString(StringBuffer bld) { toString(bld, ExpressionFactory.EVERYTHING); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CurryedLambdaExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CurryedLambdaExpression.java index 116b4709e..dc97ab152 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CurryedLambdaExpression.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CurryedLambdaExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,6 +27,7 @@ final class CurryedLambdaExpression extends LambdaExpression { this.assignments = assignments; } + @Override public boolean accept(IExpressionVisitor visitor) { if (super.accept(visitor) && each.accept(visitor)) { for (int idx = 0; idx < assignments.length; ++idx) @@ -37,6 +38,7 @@ final class CurryedLambdaExpression extends LambdaExpression { return false; } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -44,14 +46,17 @@ final class CurryedLambdaExpression extends LambdaExpression { return cmp; } + @Override public boolean equals(Object o) { return super.equals(o) && equals(assignments, ((CurryedLambdaExpression) o).assignments); } + @Override public int hashCode() { return 31 * super.hashCode() + hashCode(assignments); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { int top = assignments.length; if (top > 0) { @@ -71,6 +76,7 @@ final class CurryedLambdaExpression extends LambdaExpression { bld.append('}'); } + @Override public IEvaluationContext prolog(IEvaluationContext context) { IEvaluationContext lambdaContext; int top = assignments.length + 1; @@ -84,6 +90,7 @@ final class CurryedLambdaExpression extends LambdaExpression { return lambdaContext; } + @Override int countAccessToEverything() { int cnt = 0; for (int idx = 0; idx < assignments.length; ++idx) diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Equals.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Equals.java index 4992d7980..98fcc3c3a 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Equals.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Equals.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ final class Equals extends Binary { this.negate = negate; } + @Override public Object evaluate(IEvaluationContext context) { Object lhsVal = lhs.evaluate(context); Object rhsVal = rhs.evaluate(context); @@ -44,14 +45,17 @@ final class Equals extends Binary { return negate ? !eq : eq; } + @Override public int getExpressionType() { return negate ? TYPE_NOT_EQUALS : TYPE_EQUALS; } + @Override public String getOperator() { return negate ? OPERATOR_NOT_EQUALS : OPERATOR_EQUALS; } + @Override public void toLDAPString(StringBuffer buf) { if (negate) buf.append("(!"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/EvaluationContext.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/EvaluationContext.java index 0fa45c846..0d2dee64e 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/EvaluationContext.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/EvaluationContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,10 +28,12 @@ public class EvaluationContext implements IEvaluationContext { this.variable = variable; } + @Override public Object getValue(IExpression var) { return variable == var ? value : parentContext.getValue(var); } + @Override public void setValue(IExpression var, Object val) { if (variable == var) value = val; @@ -50,6 +52,7 @@ public class EvaluationContext implements IEvaluationContext { values[idx] = variables[ndx]; } + @Override public Object getValue(IExpression variable) { for (int idx = 0; idx < values.length; ++idx) if (values[idx++] == variable) @@ -57,6 +60,7 @@ public class EvaluationContext implements IEvaluationContext { return parentContext.getValue(variable); } + @Override public void setValue(IExpression variable, Object value) { for (int idx = 0; idx < values.length; ++idx) if (values[idx++] == variable) { @@ -126,22 +130,26 @@ public class EvaluationContext implements IEvaluationContext { this.parameters = parameters; } + @Override public final Object getParameter(int position) { return parameters[position]; } + @Override public Object getValue(IExpression variable) { if (parentContext == null) throw new IllegalArgumentException("No such variable: " + variable); //$NON-NLS-1$ return parentContext.getValue(variable); } + @Override public void setValue(IExpression variable, Object value) { if (parentContext == null) throw new IllegalArgumentException("No such variable: " + variable); //$NON-NLS-1$ parentContext.setValue(variable, value); } + @Override public IIndexProvider<?> getIndexProvider() { if (indexProvider == null) { if (parentContext == null) @@ -151,6 +159,7 @@ public class EvaluationContext implements IEvaluationContext { return indexProvider; } + @Override public void setIndexProvider(IIndexProvider<?> indexProvider) { this.indexProvider = indexProvider; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Everything.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Everything.java index 4cc51cff9..e77d49738 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Everything.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Everything.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,15 +40,17 @@ public final class Everything<T> extends MatchIteratorFilter<T> implements IRepe this.elementClass = elementClass; } + @Override public IRepeatableIterator<T> getCopy() { Iterator<? extends T> iterator = getInnerIterator(); if (iterator instanceof IRepeatableIterator<?>) - return new Everything<T>(elementClass, ((IRepeatableIterator<? extends T>) iterator).getCopy(), false); + return new Everything<>(elementClass, ((IRepeatableIterator<? extends T>) iterator).getCopy(), false); if (atStart) return this; throw new UnsupportedOperationException(); } + @Override public T next() { atStart = false; return super.next(); @@ -58,6 +60,7 @@ public final class Everything<T> extends MatchIteratorFilter<T> implements IRepe return elementClass; } + @Override public Object getIteratorProvider() { Iterator<? extends T> iterator = getInnerIterator(); if (iterator instanceof IRepeatableIterator<?>) @@ -65,6 +68,7 @@ public final class Everything<T> extends MatchIteratorFilter<T> implements IRepe return this; } + @Override protected boolean isMatch(T val) { return elementClass.isInstance(val); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Exists.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Exists.java index b2a5f421c..99ae0ee9f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Exists.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Exists.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ final class Exists extends CollectionFilter { super(collection, lambda); } + @Override protected Object evaluate(IEvaluationContext context, Iterator<?> itor) { Variable variable = lambda.getItemVariable(); while (itor.hasNext()) { @@ -32,10 +33,12 @@ final class Exists extends CollectionFilter { return Boolean.FALSE; } + @Override public int getExpressionType() { return TYPE_EXISTS; } + @Override public String getOperator() { return KEYWORD_EXISTS; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Expression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Expression.java index 7966215ae..bd004d409 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Expression.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Expression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -108,10 +108,12 @@ public abstract class Expression implements IExpression, Comparable<Expression>, * @param visitor The visiting visitor. * @return <code>true</code> if the visitor should continue visiting, <code>false</code> otherwise. */ + @Override public boolean accept(IExpressionVisitor visitor) { return visitor.visit(this); } + @Override public int compareTo(Expression e) { int cmp = getPriority() - e.getPriority(); if (cmp == 0) { @@ -122,6 +124,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, return cmp; } + @Override public boolean equals(Object e) { if (e == this) return true; @@ -135,6 +138,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, * @param context The evaluation context * @return The result of the evaluation. */ + @Override public abstract Object evaluate(IEvaluationContext context); public Iterator<?> evaluateAsIterator(IEvaluationContext context) { @@ -158,16 +162,19 @@ public abstract class Expression implements IExpression, Comparable<Expression>, return bld.toString(); } + @Override public void toLDAPString(StringBuffer buf) { throw new UnsupportedOperationException(); } + @Override public final String toString() { StringBuffer bld = new StringBuffer(); toString(bld); return bld.toString(); } + @Override public void toString(StringBuffer bld) { toString(bld, ExpressionFactory.THIS); } @@ -220,14 +227,14 @@ public abstract class Expression implements IExpression, Comparable<Expression>, Expression bf = bArr[bidx]; if (af.equals(bf)) { if (common == null) - common = new ArrayList<Expression>(); + common = new ArrayList<>(); common.add(af); break; } } if (bidx == btop) { if (onlyA == null) - onlyA = new ArrayList<Expression>(); + onlyA = new ArrayList<>(); onlyA.add(af); } } @@ -246,7 +253,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, break; if (aidx == atop) { if (onlyB == null) - onlyB = new ArrayList<Expression>(); + onlyB = new ArrayList<>(); onlyB.add(bf); } } @@ -258,7 +265,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, } if (parts == null) - parts = new ArrayList<Expression>(); + parts = new ArrayList<>(); if (onlyA != null) { base = normalize(common, op); @@ -281,6 +288,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, this.variable = variable; } + @Override public boolean visit(IExpression expression) { if (((Expression) expression).isReferenceTo(variable)) found = true; @@ -306,6 +314,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, this.operand = operand; } + @Override public boolean visit(IExpression expression) { if (expression instanceof Matches) { if (IInstallableUnit.class.isAssignableFrom(elementClass)) { @@ -316,7 +325,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, Matches matches = (Matches) expression; if (matches.lhs == operand) { if (members == null) - members = new ArrayList<String>(); + members = new ArrayList<>(); if (!members.contains(InstallableUnit.MEMBER_PROVIDED_CAPABILITIES)) members.add(InstallableUnit.MEMBER_PROVIDED_CAPABILITIES); } @@ -331,7 +340,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, if (member.getOperand() == operand) { String name = member.getName(); if (members == null) - members = new ArrayList<String>(); + members = new ArrayList<>(); if (!members.contains(name)) members.add(member.getName()); return false; @@ -349,7 +358,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, if (base.equals(subFilter)) return base; - ArrayList<Expression> filters = new ArrayList<Expression>(2); + ArrayList<Expression> filters = new ArrayList<>(2); filters.add(base); filters.add(subFilter); return normalize(filters, expressionType); @@ -382,7 +391,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, return operands.get(0); Collections.sort(operands); - List<Compacter> splits = new ArrayList<Compacter>(); + List<Compacter> splits = new ArrayList<>(); int reverseOp = op == TYPE_AND ? TYPE_OR : TYPE_AND; for (int idx = 0; idx < top; ++idx) @@ -446,9 +455,9 @@ public abstract class Expression implements IExpression, Comparable<Expression>, HashSet<Object> result; if (val instanceof Collection<?>) - result = new HashSet<Object>((Collection<?>) val); + result = new HashSet<>((Collection<?>) val); else { - result = new HashSet<Object>(); + result = new HashSet<>(); Iterator<?> iterator = RepeatableIterator.create(val); while (iterator.hasNext()) result.add(iterator.next()); @@ -462,6 +471,7 @@ public abstract class Expression implements IExpression, Comparable<Expression>, TranslationSupportFinder() { // } + @Override public boolean visit(IExpression expression) { if (expression.getExpressionType() == TYPE_MEMBER && InstallableUnit.MEMBER_TRANSLATED_PROPERTIES.equals(((Member) expression).getName())) found = true; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java index e2e262086..65da351f8 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2011, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,7 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan static { Class<?>[] args = new Class[] {Expression[].class}; - Map<String, Constructor<?>> f = new HashMap<String, Constructor<?>>(); + Map<String, Constructor<?>> f = new HashMap<>(); try { f.put(KEYWORD_BOOLEAN, BooleanFunction.class.getConstructor(args)); f.put(KEYWORD_FILTER, FilterFunction.class.getConstructor(args)); @@ -46,10 +46,12 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan return ops; } + @Override public IExpression all(IExpression collection, IExpression lambda) { return new All((Expression) collection, (LambdaExpression) lambda); } + @Override public IExpression and(IExpression... operands) { if (operands.length == 0) return Literal.TRUE_CONSTANT; @@ -58,30 +60,37 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan return new And(convertArray(operands)); } + @Override public IExpression array(IExpression... operands) { return new Array(convertArray(operands)); } + @Override public IExpression assignment(IExpression variable, IExpression expression) { return new Assignment((Variable) variable, (Expression) expression); } + @Override public IExpression at(IExpression target, IExpression key) { return new At((Expression) target, (Expression) key); } + @Override public IExpression collect(IExpression collection, IExpression lambda) { return new Collect((Expression) collection, (LambdaExpression) lambda); } + @Override public IExpression condition(IExpression test, IExpression ifTrue, IExpression ifFalse) { return new Condition((Expression) test, (Expression) ifTrue, (Expression) ifFalse); } + @Override public IExpression constant(Object value) { return Literal.create(value); } + @Override @SuppressWarnings("unchecked") public <T> IContextExpression<T> contextExpression(IExpression expression, Object... parameters) { @@ -93,37 +102,45 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan } if (expression instanceof IMatchExpression<?>) throw new IllegalArgumentException("IMatchExpression cannot be turned into a context expression"); //$NON-NLS-1$ - return new ContextExpression<T>((Expression) expression, parameters); + return new ContextExpression<>((Expression) expression, parameters); } + @Override public IEvaluationContext createContext(IExpression[] variables, Object... parameters) { return EvaluationContext.create(parameters, variables); } + @Override public IEvaluationContext createContext(Object... parameters) { return EvaluationContext.create(parameters, (Variable[]) null); } + @Override public IExpression equals(IExpression lhs, IExpression rhs) { return new Equals((Expression) lhs, (Expression) rhs, false); } + @Override public IExpression exists(IExpression collection, IExpression lambda) { return new Exists((Expression) collection, (LambdaExpression) lambda); } + @Override public IFilterExpression filterExpression(IExpression expression) { return new LDAPFilter((Expression) expression); } + @Override public IExpression first(IExpression collection, IExpression lambda) { return new First((Expression) collection, (LambdaExpression) lambda); } + @Override public IExpression flatten(IExpression collection) { return new Flatten((Expression) collection); } + @Override public IExpression function(Object function, IExpression... args) { try { return (IExpression) ((Constructor<?>) function).newInstance(new Object[] {convertArray(args)}); @@ -141,30 +158,37 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan } } + @Override public Map<String, ? extends Object> getFunctionMap() { return functionMap; } + @Override public IExpression greater(IExpression lhs, IExpression rhs) { return new Compare((Expression) lhs, (Expression) rhs, false, false); } + @Override public IExpression greaterEqual(IExpression lhs, IExpression rhs) { return new Compare((Expression) lhs, (Expression) rhs, false, true); } + @Override public IExpression indexedParameter(int index) { return new Parameter(index); } + @Override public IExpression intersect(IExpression c1, IExpression c2) { return new Intersect((Expression) c1, (Expression) c2); } + @Override public IExpression lambda(IExpression variable, IExpression body) { return new LambdaExpression((Variable) variable, (Expression) body); } + @Override public IExpression lambda(IExpression variable, IExpression[] assignments, IExpression body) { if (assignments.length == 0) return lambda(variable, body); @@ -173,30 +197,37 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan return new CurryedLambdaExpression((Variable) variable, asgns, (Expression) body); } + @Override public IExpression latest(IExpression collection) { return new Latest((Expression) collection); } + @Override public IExpression less(IExpression lhs, IExpression rhs) { return new Compare((Expression) lhs, (Expression) rhs, true, false); } + @Override public IExpression lessEqual(IExpression lhs, IExpression rhs) { return new Compare((Expression) lhs, (Expression) rhs, true, true); } + @Override public IExpression limit(IExpression collection, IExpression limit) { return new Limit((Expression) collection, (Expression) limit); } + @Override public IExpression limit(IExpression collection, int count) { return new Limit((Expression) collection, Literal.create(Integer.valueOf(count))); } + @Override public IExpression matches(IExpression lhs, IExpression rhs) { return new Matches((Expression) lhs, (Expression) rhs); } + @Override @SuppressWarnings("unchecked") public <T> IMatchExpression<T> matchExpression(IExpression expression, Object... parameters) { if (expression instanceof IMatchExpression<?>) { @@ -207,9 +238,10 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan } if (expression instanceof IContextExpression<?>) throw new IllegalArgumentException("IContextExpression cannot be turned into a match expression"); //$NON-NLS-1$ - return new MatchExpression<T>((Expression) expression, parameters); + return new MatchExpression<>((Expression) expression, parameters); } + @Override public IExpression member(IExpression target, String name) { if ("empty".equals(name)) //$NON-NLS-1$ return new Member.EmptyMember((Expression) target); @@ -218,6 +250,7 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan return new Member.DynamicMember((Expression) target, name); } + @Override public IExpression memberCall(IExpression target, String name, IExpression... args) { if (args.length == 0) return member(target, name); @@ -236,11 +269,13 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan throw new IllegalArgumentException(bld.toString()); } + @Override @SuppressWarnings("unchecked") public IExpression normalize(List<? extends IExpression> operands, int expressionType) { return Expression.normalize((List<Expression>) operands, expressionType); } + @Override public IExpression not(IExpression operand) { if (operand instanceof Equals) { Equals eq = (Equals) operand; @@ -256,6 +291,7 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan return new Not((Expression) operand); } + @Override public IExpression or(IExpression... operands) { if (operands.length == 0) return Literal.TRUE_CONSTANT; @@ -264,35 +300,43 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan return new Or(convertArray(operands)); } + @Override public IExpression pipe(IExpression... operands) { return Pipe.createPipe(convertArray(operands)); } + @Override public IExpression select(IExpression collection, IExpression lambda) { return new Select((Expression) collection, (LambdaExpression) lambda); } + @Override public IExpression thisVariable() { return THIS; } + @Override public IExpression toExpression(IQuery<?> query) { Literal queryConstant = Literal.create(query); return new WrappedIQuery(new Expression[] {queryConstant}); } + @Override public IExpression traverse(IExpression collection, IExpression lambda) { return new Traverse((Expression) collection, (LambdaExpression) lambda); } + @Override public IExpression union(IExpression c1, IExpression c2) { return new Union((Expression) c1, (Expression) c2); } + @Override public IExpression unique(IExpression collection, IExpression cache) { return new Unique((Expression) collection, (Expression) cache); } + @Override public IExpression variable(String name) { if (VARIABLE_EVERYTHING.equals(name)) return EVERYTHING; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/FilterFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/FilterFunction.java index 3101ce472..fc28da81a 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/FilterFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/FilterFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.expression; - import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; /** @@ -21,14 +20,17 @@ public final class FilterFunction extends Function { super(assertLength(operands, 1, 1, KEYWORD_FILTER)); } + @Override boolean assertSingleArgumentClass(Object v) { return v instanceof String; } + @Override Object createInstance(Object arg) { return ExpressionUtil.parseLDAP((String) arg); } + @Override public String getOperator() { return KEYWORD_FILTER; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/First.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/First.java index b09056f62..40b474cbf 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/First.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/First.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ final class First extends CollectionFilter { super(collection, lambda); } + @Override protected Object evaluate(IEvaluationContext context, Iterator<?> itor) { Variable variable = lambda.getItemVariable(); while (itor.hasNext()) { @@ -33,10 +34,12 @@ final class First extends CollectionFilter { return null; } + @Override public int getExpressionType() { return TYPE_FIRST; } + @Override public String getOperator() { return KEYWORD_FIRST; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Flatten.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Flatten.java index 9a4cfd801..97b203753 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Flatten.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Flatten.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,14 +22,17 @@ final class Flatten extends UnaryCollectionFilter { super(collection); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { - return new CompoundIterator<Object>(operand.evaluateAsIterator(context)); + return new CompoundIterator<>(operand.evaluateAsIterator(context)); } + @Override public int getExpressionType() { return TYPE_FLATTEN; } + @Override public String getOperator() { return IExpressionConstants.KEYWORD_FLATTEN; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Function.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Function.java index 2087ddc54..cd8f49183 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Function.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Function.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,6 +36,7 @@ public abstract class Function extends NAry { throw new UnsupportedOperationException(); } + @Override public Object evaluate(IEvaluationContext context) { if (instance != null) return instance; @@ -53,6 +54,7 @@ public abstract class Function extends NAry { throw new IllegalArgumentException("Cannot create a " + getOperator() + " from " + what); //$NON-NLS-1$ //$NON-NLS-2$ } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Object value = evaluate(context); if (!(value instanceof Iterator<?>)) @@ -60,14 +62,17 @@ public abstract class Function extends NAry { return (Iterator<?>) value; } + @Override public int getExpressionType() { return TYPE_FUNCTION; } + @Override public int getPriority() { return PRIORITY_FUNCTION; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { bld.append(getOperator()); bld.append('('); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Intersect.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Intersect.java index 048252d30..f8d6d28cb 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Intersect.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Intersect.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,14 +21,16 @@ final class Intersect extends Binary { super(operand, param); } + @Override public Object evaluate(IEvaluationContext context) { return evaluateAsIterator(context); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Set<?> resultSet = asSet(lhs.evaluate(context), false); // Safe since it will not be modified Iterator<?> itor = rhs.evaluateAsIterator(context); - Set<Object> retained = new HashSet<Object>(); + Set<Object> retained = new HashSet<>(); while (itor.hasNext()) { Object value = itor.next(); if (resultSet.contains(value)) @@ -37,14 +39,17 @@ final class Intersect extends Binary { return RepeatableIterator.create(retained); } + @Override public int getExpressionType() { return TYPE_INTERSECT; } + @Override public String getOperator() { return KEYWORD_INTERSECT; } + @Override public int getPriority() { return PRIORITY_COLLECTION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPApproximation.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPApproximation.java index 291a6ef6c..1e2dfb017 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPApproximation.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPApproximation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,14 +25,17 @@ public final class LDAPApproximation implements Serializable, Comparable<LDAPApp this.pattern = pattern; } + @Override public int compareTo(LDAPApproximation o) { return pattern.compareTo(o.pattern); } + @Override public boolean equals(Object o) { return o == this || (o instanceof LDAPApproximation && ((LDAPApproximation) o).pattern.equals(pattern)); } + @Override public int hashCode() { return 3 * pattern.hashCode(); } @@ -52,6 +55,7 @@ public final class LDAPApproximation implements Serializable, Comparable<LDAPApp return approxString(value).equals(approxPattern); } + @Override public String toString() { return pattern; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPFilter.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPFilter.java index a96fe329d..5d189a98c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPFilter.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LDAPFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,10 +23,12 @@ public class LDAPFilter extends Unary implements IFilterExpression { super(expression); } + @Override public boolean accept(IExpressionVisitor visitor) { return operand.accept(visitor); } + @Override public boolean equals(Object o) { return (o instanceof Filter && !(o instanceof LDAPFilter)) ? equals(ExpressionUtil.parseLDAP(o.toString())) : super.equals(o); } @@ -41,14 +43,17 @@ public class LDAPFilter extends Unary implements IFilterExpression { return operand.getPriority(); } + @Override public int getExpressionType() { return 0; } + @Override public boolean match(Map<String, ? extends Object> map) { return isMatch(MemberProvider.create(map, true)); } + @Override @SuppressWarnings("rawtypes") public boolean match(Dictionary dictionary) { return isMatch(dictionary == null ? MemberProvider.emptyProvider() : MemberProvider.create(dictionary, true)); @@ -61,23 +66,28 @@ public class LDAPFilter extends Unary implements IFilterExpression { return Boolean.TRUE == operand.evaluate(ctx); } + @Override public boolean match(ServiceReference<?> reference) { return isMatch(reference == null ? MemberProvider.emptyProvider() : MemberProvider.create(reference, true)); } + @Override public boolean matchCase(Map<String, ? extends Object> map) { return isMatch(map == null ? MemberProvider.emptyProvider() : MemberProvider.create(map, false)); } + @Override public boolean matches(Map<String, ?> map) { return matchCase(map); } + @Override @SuppressWarnings("rawtypes") public boolean matchCase(Dictionary dictionary) { return isMatch(dictionary == null ? MemberProvider.emptyProvider() : MemberProvider.create(dictionary, false)); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { operand.toLDAPString(bld); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LambdaExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LambdaExpression.java index ca5c2f9ee..6e13d635a 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LambdaExpression.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/LambdaExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,10 +24,12 @@ public class LambdaExpression extends Unary { this.each = each; } + @Override public boolean accept(IExpressionVisitor visitor) { return super.accept(visitor) && each.accept(visitor); } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -35,19 +37,23 @@ public class LambdaExpression extends Unary { return cmp; } + @Override public boolean equals(Object o) { return super.equals(o) && each.equals(((LambdaExpression) o).each); } + @Override public int hashCode() { int result = 31 + operand.hashCode(); return 31 * result + each.hashCode(); } + @Override public int getExpressionType() { return TYPE_LAMBDA; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { each.toString(bld, rootVariable); bld.append(" | "); //$NON-NLS-1$ @@ -58,10 +64,12 @@ public class LambdaExpression extends Unary { return each; } + @Override public String getOperator() { return "|"; //$NON-NLS-1$ } + @Override public int getPriority() { return IExpressionConstants.PRIORITY_LAMBDA; } @@ -70,6 +78,7 @@ public class LambdaExpression extends Unary { return EvaluationContext.create(context, each); } + @Override int countAccessToEverything() { return 2 * super.countAccessToEverything(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Latest.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Latest.java index b5e2bf87e..8b647b6d6 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Latest.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Latest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,6 +25,7 @@ final class Latest extends UnaryCollectionFilter { super(collection); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { HashMap<String, IVersionedId> greatestIUVersion; if (operand instanceof Select) { @@ -35,7 +36,7 @@ final class Latest extends UnaryCollectionFilter { if (!iterator.hasNext()) return Collections.EMPTY_SET.iterator(); - greatestIUVersion = new HashMap<String, IVersionedId>(); + greatestIUVersion = new HashMap<>(); LambdaExpression lambda = select.lambda; context = lambda.prolog(context); Variable variable = lambda.getItemVariable(); @@ -63,7 +64,7 @@ final class Latest extends UnaryCollectionFilter { if (!iterator.hasNext()) return Collections.EMPTY_SET.iterator(); - greatestIUVersion = new HashMap<String, IVersionedId>(); + greatestIUVersion = new HashMap<>(); while (iterator.hasNext()) { Object next = iterator.next(); if (!(next instanceof IVersionedId)) @@ -83,10 +84,12 @@ final class Latest extends UnaryCollectionFilter { return greatestIUVersion.values().iterator(); } + @Override public int getExpressionType() { return TYPE_LATEST; } + @Override public String getOperator() { return IExpressionConstants.KEYWORD_LATEST; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java index e60e6ed72..b11bd5801 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,10 +30,12 @@ final class Limit extends Binary { this.counter = count; } + @Override public boolean hasNext() { return counter > 0 && innerIterator.hasNext(); } + @Override public T next() { if (counter > 0) { --counter; @@ -42,6 +44,7 @@ final class Limit extends Binary { throw new NoSuchElementException(); } + @Override public void remove() { innerIterator.remove(); } @@ -55,10 +58,12 @@ final class Limit extends Binary { this(operand, (Expression) ExpressionFactory.INSTANCE.constant(Integer.valueOf(limit))); } + @Override public Object evaluate(IEvaluationContext context) { return evaluateAsIterator(context); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Object rval = rhs.evaluate(context); int limit = -1; @@ -69,20 +74,24 @@ final class Limit extends Binary { return limit == 0 ? Collections.emptySet().iterator() : new CountingIterator<Object>(lhs.evaluateAsIterator(context), limit); } + @Override public int getExpressionType() { return TYPE_LIMIT; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { CollectionFilter.appendProlog(bld, rootVariable, lhs, getOperator()); appendOperand(bld, rootVariable, rhs, IExpressionConstants.PRIORITY_COMMA); bld.append(')'); } + @Override public String getOperator() { return KEYWORD_LIMIT; } + @Override public int getPriority() { return PRIORITY_COLLECTION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Literal.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Literal.java index 244b00508..d658a43e0 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Literal.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Literal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,6 +43,7 @@ public final class Literal extends Expression { this.value = value; } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public int compareTo(Expression e) { int cmp = super.compareTo(e); @@ -62,6 +63,7 @@ public final class Literal extends Expression { return eValue.getClass().getName().compareTo(value.getClass().getName()); } + @Override public boolean equals(Object o) { if (super.equals(o)) { Literal bo = (Literal) o; @@ -70,32 +72,39 @@ public final class Literal extends Expression { return false; } + @Override public Object evaluate(IEvaluationContext context) { return value; } + @Override public int getExpressionType() { return TYPE_LITERAL; } + @Override public String getOperator() { return "<literal>"; //$NON-NLS-1$ } + @Override public int getPriority() { return PRIORITY_LITERAL; } + @Override public int hashCode() { return 31 + value.hashCode(); } + @Override public void toLDAPString(StringBuffer buf) { if (!(value instanceof Filter)) throw new UnsupportedOperationException(); buf.append(value.toString()); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { appendValue(bld, value); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java index 64016e1e1..a25e5815f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,30 +28,37 @@ public class MatchExpression<T> extends Unary implements IMatchExpression<T> { this.parameters = parameters == null ? noParams : parameters; } + @Override public boolean accept(IExpressionVisitor visitor) { return operand.accept(visitor); } + @Override public IEvaluationContext createContext() { return EvaluationContext.create(parameters, ExpressionFactory.THIS); } + @Override public boolean equals(Object o) { return super.equals(o) && Arrays.equals(parameters, ((MatchExpression<?>) o).parameters); } + @Override public Object evaluate(IEvaluationContext context) { return operand.evaluate(parameters.length == 0 ? context : EvaluationContext.create(context, parameters)); } + @Override public int getExpressionType() { return 0; } + @Override public String getOperator() { throw new UnsupportedOperationException(); } + @Override public Object[] getParameters() { return parameters; } @@ -64,27 +71,33 @@ public class MatchExpression<T> extends Unary implements IMatchExpression<T> { return operand; } + @Override public int getPriority() { return operand.getPriority(); } + @Override public int hashCode() { return operand.hashCode() * 31 + CollectionUtils.hashCode(parameters); } + @Override public boolean isMatch(IEvaluationContext context, T value) { ExpressionFactory.THIS.setValue(context, value); return Boolean.TRUE == operand.evaluate(context); } + @Override public boolean isMatch(T value) { return isMatch(createContext(), value); } + @Override public void toLDAPString(StringBuffer bld) { operand.toLDAPString(bld); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { operand.toString(bld, rootVariable); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchIteratorFilter.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchIteratorFilter.java index 8d21ed8f7..2efbb8acd 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchIteratorFilter.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchIteratorFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 - 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,10 +27,12 @@ public abstract class MatchIteratorFilter<T> implements Iterator<T> { this.innerIterator = iterator; } + @Override public boolean hasNext() { return positionNext(); } + @Override public T next() { if (!positionNext()) throw new NoSuchElementException(); @@ -40,6 +42,7 @@ public abstract class MatchIteratorFilter<T> implements Iterator<T> { return nxt; } + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java index 2033b3875..b7d1ecce8 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,6 +32,7 @@ public class Matches extends Binary { super(lhs, rhs); } + @Override public Object evaluate(IEvaluationContext context) { return Boolean.valueOf(match(lhs.evaluate(context), rhs.evaluate(context))); } @@ -60,7 +61,7 @@ public class Matches extends Binary { return ((LDAPFilter) rval).isMatch(MemberProvider.create(lval, true)); } else if (rval instanceof Filter) { if (lval instanceof IInstallableUnit) - return Boolean.valueOf(((Filter) rval).match(new Hashtable<String, String>(((IInstallableUnit) lval).getProperties()))); + return Boolean.valueOf(((Filter) rval).match(new Hashtable<>(((IInstallableUnit) lval).getProperties()))); // TODO Below we use raw types for simplicity; // we could convert to Dictionary<String, ?> but that is work and the filter impl // must still handle (and ignore) non String keys. @@ -89,14 +90,17 @@ public class Matches extends Binary { throw new IllegalArgumentException("Cannot match a " + lval.getClass().getName() + " with a " + rval.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$ } + @Override public int getExpressionType() { return TYPE_MATCHES; } + @Override public String getOperator() { return OPERATOR_MATCHES; } + @Override public void toLDAPString(StringBuffer buf) { if (!(rhs instanceof Literal)) throw new UnsupportedOperationException(); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java index 15e8935f4..d93b5097c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,6 +38,7 @@ public abstract class Member extends Unary { super(operand, name, Expression.emptyArray); } + @Override public Object evaluate(IEvaluationContext context) { return invoke(operand.evaluate(context)); } @@ -110,6 +111,7 @@ public abstract class Member extends Unary { super(operand, "length", Expression.emptyArray); //$NON-NLS-1$ } + @Override public Object evaluate(IEvaluationContext context) { int len = getLength(operand.evaluate(context)); return Integer.valueOf(len); @@ -140,6 +142,7 @@ public abstract class Member extends Unary { super(operand); } + @Override public Object evaluate(IEvaluationContext context) { Object val = operand.evaluate(context); boolean empty = (val instanceof Iterator<?>) ? !((Iterator<?>) val).hasNext() : getLength(val) == 0; @@ -163,6 +166,7 @@ public abstract class Member extends Unary { this.argExpressions = args; } + @Override public boolean accept(IExpressionVisitor visitor) { if (super.accept(visitor)) for (int idx = 0; idx < argExpressions.length; ++idx) @@ -171,6 +175,7 @@ public abstract class Member extends Unary { return true; } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) { @@ -181,6 +186,7 @@ public abstract class Member extends Unary { return cmp; } + @Override public boolean equals(Object o) { if (super.equals(o)) { Member mo = (Member) o; @@ -189,6 +195,7 @@ public abstract class Member extends Unary { return false; } + @Override public int getExpressionType() { return TYPE_MEMBER; } @@ -197,20 +204,24 @@ public abstract class Member extends Unary { return name; } + @Override public String getOperator() { return OPERATOR_MEMBER; } + @Override public int getPriority() { return PRIORITY_MEMBER; } + @Override public int hashCode() { int result = 31 + name.hashCode(); result = 31 * result + operand.hashCode(); return 31 * result + hashCode(argExpressions); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { if (operand != rootVariable) { appendOperand(bld, rootVariable, operand, getPriority()); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java index dccb00397..7ec288b62 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MemberProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Cloudsmith Inc. and others. + * Copyright (c) 2011, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ public abstract class MemberProvider implements IMemberProvider { this.dictionary = dictionary; } + @Override public Object getMember(String memberName) { return dictionary.get(memberName); } @@ -51,7 +52,7 @@ public abstract class MemberProvider implements IMemberProvider { if (!hasUpperCase) return dictionary; - Dictionary<String, Object> lcMap = new Hashtable<String, Object>(dictionary.size()); + Dictionary<String, Object> lcMap = new Hashtable<>(dictionary.size()); for (Enumeration<String> keys = dictionary.keys(); keys.hasMoreElements();) { String key = keys.nextElement(); if (lcMap.put(key.toLowerCase(), dictionary.get(key)) != null) @@ -68,6 +69,7 @@ public abstract class MemberProvider implements IMemberProvider { this.map = map; } + @Override public Object getMember(String memberName) { return map.get(memberName); } @@ -97,7 +99,7 @@ public abstract class MemberProvider implements IMemberProvider { if (!hasUpperCase) return map; - Map<String, Object> lcMap = new HashMap<String, Object>(map.size()); + Map<String, Object> lcMap = new HashMap<>(map.size()); for (Entry<String, ?> entry : entrySet) { if (lcMap.put(entry.getKey().toLowerCase(), entry.getValue()) != null) throw new IllegalArgumentException("case variants of the same key name: '" + entry.getKey() + '\''); //$NON-NLS-1$ @@ -113,6 +115,7 @@ public abstract class MemberProvider implements IMemberProvider { this.serviceRef = serviceRef; } + @Override public Object getMember(String memberName) { return serviceRef.getProperty(memberName); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/NAry.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/NAry.java index da8491e92..6e10bda0c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/NAry.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/NAry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ public abstract class NAry extends Expression { this.operands = operands; } + @Override public boolean accept(IExpressionVisitor visitor) { if (super.accept(visitor)) for (int idx = 0; idx < operands.length; ++idx) @@ -30,6 +31,7 @@ public abstract class NAry extends Expression { return true; } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -37,16 +39,20 @@ public abstract class NAry extends Expression { return cmp; } + @Override public boolean equals(Object o) { return super.equals(o) && equals(operands, ((NAry) o).operands); } + @Override public abstract String getOperator(); + @Override public int hashCode() { return hashCode(operands); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { appendOperand(bld, rootVariable, operands[0], getPriority()); for (int idx = 1; idx < operands.length; ++idx) { @@ -57,6 +63,7 @@ public abstract class NAry extends Expression { } } + @Override int countAccessToEverything() { int cnt = 0; for (int idx = 0; idx < operands.length; ++idx) diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Not.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Not.java index 0058b4e69..3dbd303be 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Not.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Not.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,26 +20,32 @@ final class Not extends Unary { super(operand); } + @Override public Object evaluate(IEvaluationContext context) { return Boolean.valueOf(operand.evaluate(context) != Boolean.TRUE); } + @Override public int getExpressionType() { return TYPE_NOT; } + @Override public String getOperator() { return OPERATOR_NOT; } + @Override public int getPriority() { return PRIORITY_NOT; } + @Override public int hashCode() { return 3 * operand.hashCode(); } + @Override public void toLDAPString(StringBuffer buf) { buf.append("(!"); //$NON-NLS-1$ operand.toLDAPString(buf); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Or.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Or.java index f6d361e5b..08ec3582c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Or.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Or.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ final class Or extends NAry { super(assertLength(operands, 2, OPERATOR_OR)); } + @Override public Object evaluate(IEvaluationContext context) { for (int idx = 0; idx < operands.length; ++idx) { if (operands[idx].evaluate(context) == Boolean.TRUE) @@ -29,18 +30,22 @@ final class Or extends NAry { return Boolean.FALSE; } + @Override public int getExpressionType() { return TYPE_OR; } + @Override public String getOperator() { return OPERATOR_OR; } + @Override public int getPriority() { return PRIORITY_OR; } + @Override public void toLDAPString(StringBuffer buf) { buf.append("(|"); //$NON-NLS-1$ for (int idx = 0; idx < operands.length; ++idx) diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Parameter.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Parameter.java index cc790e382..b15c8cc9e 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Parameter.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Parameter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ public class Parameter extends Expression { this.position = position; } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -29,6 +30,7 @@ public class Parameter extends Expression { return cmp; } + @Override public boolean equals(Object o) { if (o == this) return true; @@ -37,26 +39,32 @@ public class Parameter extends Expression { return getClass() == o.getClass() && position == ((Parameter) o).position; } + @Override public Object evaluate(IEvaluationContext context) { return context.getParameter(position); } + @Override public int getExpressionType() { return TYPE_PARAMETER; } + @Override public String getOperator() { return OPERATOR_PARAMETER; } + @Override public int getPriority() { return PRIORITY_VARIABLE; } + @Override public int hashCode() { return 31 * (1 + position); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { bld.append('$'); bld.append(position); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Pipe.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Pipe.java index 9fe5eb375..dc35e6954 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Pipe.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Pipe.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,14 +29,17 @@ public class Pipe extends NAry { this.indexProvider = indexProvider; } + @Override public IIndex<Object> getIndex(String memberName) { return null; } + @Override public Iterator<Object> everything() { return everything.getCopy(); } + @Override public Object getManagedProperty(Object client, String memberName, Object key) { if (indexProvider != null) return indexProvider.getManagedProperty(client, memberName, key); @@ -67,8 +70,8 @@ public class Pipe extends NAry { // <expr1>, <expr2> becomes select(x | <expr1> && <expr2>) IExpressionFactory factory = ExpressionUtil.getFactory(); - ArrayList<Expression> pipeables = new ArrayList<Expression>(); - ArrayList<Expression> booleans = new ArrayList<Expression>(); + ArrayList<Expression> pipeables = new ArrayList<>(); + ArrayList<Expression> booleans = new ArrayList<>(); VariableFinder finder = new VariableFinder(ExpressionFactory.EVERYTHING); for (int idx = 0; idx < operands.length; ++idx) { Expression operand = operands[idx]; @@ -120,7 +123,7 @@ public class Pipe extends NAry { } Expression expr = (Expression) factory.select(ExpressionFactory.EVERYTHING, factory.lambda(ExpressionFactory.THIS, boolExpr)); if (params != null) - expr = new ContextExpression<Object>(expr, params); + expr = new ContextExpression<>(expr, params); return expr; } @@ -128,6 +131,7 @@ public class Pipe extends NAry { super(operands); } + @Override public int getExpressionType() { return TYPE_PIPE; } @@ -156,7 +160,7 @@ public class Pipe extends NAry { nextContext.setIndexProvider(noIndexProvider); for (int idx = 1; idx < operands.length; ++idx) { Expression expr = operands[idx]; - noIndexProvider.setEverything(new Everything<Object>(elementClass, iterator, expr)); + noIndexProvider.setEverything(new Everything<>(elementClass, iterator, expr)); iterator = expr.evaluateAsIterator(nextContext); if (!iterator.hasNext()) break; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/QueryResult.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/QueryResult.java index 2c2619a01..7f4dcb0b1 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/QueryResult.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/QueryResult.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 - 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,10 +42,12 @@ public class QueryResult<T> implements IQueryResult<T> { this.iterator = RepeatableIterator.create(collection); } + @Override public boolean isEmpty() { return !iterator.hasNext(); } + @Override public Iterator<T> iterator() { if (firstUse) { firstUse = false; @@ -54,6 +56,7 @@ public class QueryResult<T> implements IQueryResult<T> { return iterator.getCopy(); } + @Override @SuppressWarnings("unchecked") public T[] toArray(Class<T> clazz) { Object provider = iterator.getIteratorProvider(); @@ -64,30 +67,33 @@ public class QueryResult<T> implements IQueryResult<T> { return c.toArray((T[]) Array.newInstance(clazz, c.size())); } + @Override @SuppressWarnings("unchecked") public Set<T> toSet() { Object provider = iterator.getIteratorProvider(); if (provider instanceof Collection<?>) - return new HashSet<T>((Collection<T>) provider); + return new HashSet<>((Collection<T>) provider); if (provider instanceof IIndexProvider<?>) return iteratorToSet(((IIndexProvider<T>) provider).everything()); if (provider.getClass().isArray()) { T[] elems = (T[]) provider; int idx = elems.length; - HashSet<T> copy = new HashSet<T>(idx); + HashSet<T> copy = new HashSet<>(idx); while (--idx >= 0) copy.add(elems[idx]); return copy; } if (provider instanceof Map<?, ?>) - return new HashSet<T>((Set<T>) ((Map<?, ?>) provider).entrySet()); + return new HashSet<>((Set<T>) ((Map<?, ?>) provider).entrySet()); return iteratorToSet(iterator()); } + @Override public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor) { return query.perform(iterator()); } + @Override @SuppressWarnings("unchecked") public Set<T> toUnmodifiableSet() { Object provider = iterator.getIteratorProvider(); @@ -99,7 +105,7 @@ public class QueryResult<T> implements IQueryResult<T> { } private Set<T> iteratorToSet(Iterator<T> iter) { - HashSet<T> set = new HashSet<T>(); + HashSet<T> set = new HashSet<>(); while (iter.hasNext()) set.add(iter.next()); return set; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java index 09d241253..c69620429 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,14 +21,17 @@ public final class RangeFunction extends Function { super(assertLength(operands, 1, 1, KEYWORD_RANGE)); } + @Override boolean assertSingleArgumentClass(Object v) { return v instanceof String; } + @Override Object createInstance(Object arg) { return VersionRange.create((String) arg); } + @Override public String getOperator() { return KEYWORD_RANGE; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java index 6df6dacd5..5558168fb 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,27 +38,27 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> { } public static <T> IRepeatableIterator<T> create(Iterator<T> iterator) { - return iterator instanceof IRepeatableIterator<?> ? ((IRepeatableIterator<T>) iterator).getCopy() : new RepeatableIterator<T>(iterator); + return iterator instanceof IRepeatableIterator<?> ? ((IRepeatableIterator<T>) iterator).getCopy() : new RepeatableIterator<>(iterator); } public static <T> IRepeatableIterator<T> create(Collection<T> values) { - return new RepeatableIterator<T>(values); + return new RepeatableIterator<>(values); } public static <T> IRepeatableIterator<T> create(IQueryResult<T> values) { - return new QueryResultIterator<T>(values); + return new QueryResultIterator<>(values); } public static <T> IRepeatableIterator<T> create(T[] values) { - return new ArrayIterator<T>(values); + return new ArrayIterator<>(values); } public static <T> IRepeatableIterator<T> create(IIndexProvider<T> values) { - return new IndexProviderIterator<T>(values); + return new IndexProviderIterator<>(values); } RepeatableIterator(Iterator<T> iterator) { - HashSet<T> v = new HashSet<T>(); + HashSet<T> v = new HashSet<>(); while (iterator.hasNext()) v.add(iterator.next()); values = v; @@ -70,22 +70,27 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> { this.iterator = values.iterator(); } + @Override public IRepeatableIterator<T> getCopy() { - return new RepeatableIterator<T>(values); + return new RepeatableIterator<>(values); } + @Override public boolean hasNext() { return iterator.hasNext(); } + @Override public T next() { return iterator.next(); } + @Override public void remove() { throw new UnsupportedOperationException(); } + @Override public Object getIteratorProvider() { return values; } @@ -98,26 +103,31 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> { this.array = array; } + @Override public Object getIteratorProvider() { return array; } + @Override public boolean hasNext() { return position + 1 < array.length; } + @Override public T next() { if (++position >= array.length) throw new NoSuchElementException(); return array[position]; } + @Override public void remove() { throw new UnsupportedOperationException(); } + @Override public IRepeatableIterator<T> getCopy() { - return new ArrayIterator<T>(array); + return new ArrayIterator<>(array); } } @@ -130,22 +140,27 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> { this.indexProvider = indexProvider; } + @Override public IRepeatableIterator<T> getCopy() { - return new IndexProviderIterator<T>(indexProvider); + return new IndexProviderIterator<>(indexProvider); } + @Override public Object getIteratorProvider() { return indexProvider; } + @Override public boolean hasNext() { return iterator.hasNext(); } + @Override public T next() { return iterator.next(); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -161,22 +176,27 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> { this.iterator = queryResult.iterator(); } + @Override public IRepeatableIterator<T> getCopy() { - return new QueryResultIterator<T>(queryResult); + return new QueryResultIterator<>(queryResult); } + @Override public Object getIteratorProvider() { return queryResult; } + @Override public boolean hasNext() { return iterator.hasNext(); } + @Override public T next() { return iterator.next(); } + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Select.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Select.java index 59c3d9e3f..54577ed37 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Select.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Select.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,12 +22,15 @@ final class Select extends CollectionFilter { super(collection, lambda); } + @Override protected Object evaluate(IEvaluationContext context, Iterator<?> itor) { return evaluateAsIterator(context, itor); } + @Override protected Iterator<?> evaluateAsIterator(final IEvaluationContext context, Iterator<?> itor) { return new MatchIteratorFilter<Object>(itor) { + @Override protected boolean isMatch(Object val) { lambda.getItemVariable().setValue(context, val); return lambda.evaluate(context) == Boolean.TRUE; @@ -35,10 +38,12 @@ final class Select extends CollectionFilter { }; } + @Override public int getExpressionType() { return TYPE_SELECT; } + @Override public String getOperator() { return KEYWORD_SELECT; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java index ee3f09b28..59480fad9 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,13 +19,15 @@ public final class SetFunction extends Function { super(operands); } + @Override public Object evaluate(IEvaluationContext context) { - HashSet<Object> result = new HashSet<Object>(); + HashSet<Object> result = new HashSet<>(); for (int idx = 0; idx < operands.length; ++idx) result.add(operands[idx].evaluate(context)); return result; } + @Override public String getOperator() { return KEYWORD_SET; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Traverse.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Traverse.java index c94d028cc..4a23cef3d 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Traverse.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Traverse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,21 +26,25 @@ final class Traverse extends CollectionFilter { super(collection, lambda); } + @Override public Object evaluate(IEvaluationContext context, Iterator<?> itor) { return evaluateAsIterator(context, itor); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context, Iterator<?> iterator) { - HashSet<Object> collector = new HashSet<Object>(); + HashSet<Object> collector = new HashSet<>(); while (iterator.hasNext()) traverse(collector, iterator.next(), context); return collector.iterator(); } + @Override public int getExpressionType() { return TYPE_TRAVERSE; } + @Override public String getOperator() { return KEYWORD_TRAVERSE; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unary.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unary.java index c37609da4..347b9bb2e 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unary.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unary.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,10 +23,12 @@ public abstract class Unary extends Expression { this.operand = operand; } + @Override public boolean accept(IExpressionVisitor visitor) { return super.accept(visitor) && operand.accept(visitor); } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -34,14 +36,17 @@ public abstract class Unary extends Expression { return cmp; } + @Override public boolean equals(Object o) { return super.equals(o) && operand.equals(((Unary) o).operand); } + @Override public Object evaluate(IEvaluationContext context) { return operand.evaluate(context); } + @Override public int hashCode() { return operand.hashCode() * 3 + operand.getExpressionType(); } @@ -50,11 +55,13 @@ public abstract class Unary extends Expression { return operand; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { bld.append(getOperator()); appendOperand(bld, rootVariable, operand, getPriority()); } + @Override int countAccessToEverything() { return operand.countAccessToEverything(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/UnaryCollectionFilter.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/UnaryCollectionFilter.java index 061bc6c2f..2461b8e6e 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/UnaryCollectionFilter.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/UnaryCollectionFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,14 +18,17 @@ abstract class UnaryCollectionFilter extends Unary { super(collection); } + @Override public int hashCode() { return 5 * operand.hashCode(); } + @Override public Object evaluate(IEvaluationContext context) { return evaluateAsIterator(context); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { if (operand instanceof Select) { Select select = (Select) operand; @@ -36,6 +39,7 @@ abstract class UnaryCollectionFilter extends Unary { bld.append(')'); } + @Override public int getPriority() { return PRIORITY_COLLECTION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Union.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Union.java index e66703727..909a92ea2 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Union.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Union.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,10 +21,12 @@ final class Union extends Binary { super(operand, param); } + @Override public Object evaluate(IEvaluationContext context) { return evaluateAsIterator(context); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { @SuppressWarnings("unchecked") Set<Object> resultSet = (Set<Object>) asSet(lhs.evaluate(context), true); @@ -34,14 +36,17 @@ final class Union extends Binary { return RepeatableIterator.create(resultSet); } + @Override public int getExpressionType() { return TYPE_UNION; } + @Override public String getOperator() { return KEYWORD_UNION; } + @Override public int getPriority() { return PRIORITY_COLLECTION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unique.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unique.java index 94346a9c6..924904b7e 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unique.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Unique.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,6 +30,7 @@ final class Unique extends Binary { this.uniqueSet = uniqueSet; } + @Override protected boolean isMatch(T val) { synchronized (uniqueSet) { return uniqueSet.add(val); @@ -41,29 +42,33 @@ final class Unique extends Binary { super(collection, explicitCache); } + @Override public Object evaluate(IEvaluationContext context) { return evaluateAsIterator(context); } + @Override @SuppressWarnings("unchecked") public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Object explicitCache = rhs.evaluate(context); Set<Object> uniqueSet; if (explicitCache == null) // No cache, we just ensure that the iteration is unique - uniqueSet = new HashSet<Object>(); + uniqueSet = new HashSet<>(); else { if (!(explicitCache instanceof Set<?>)) throw new IllegalArgumentException("Unique cache must be a java.util.Set"); //$NON-NLS-1$ uniqueSet = (Set<Object>) explicitCache; } - return new UniqueIterator<Object>(lhs.evaluateAsIterator(context), uniqueSet); + return new UniqueIterator<>(lhs.evaluateAsIterator(context), uniqueSet); } + @Override public int getExpressionType() { return TYPE_UNIQUE; } + @Override public void toString(StringBuffer bld, Variable rootVariable) { CollectionFilter.appendProlog(bld, rootVariable, lhs, getOperator()); if (rhs != Literal.NULL_CONSTANT) @@ -71,10 +76,12 @@ final class Unique extends Binary { bld.append(')'); } + @Override public String getOperator() { return KEYWORD_UNIQUE; } + @Override public int getPriority() { return PRIORITY_COLLECTION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Variable.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Variable.java index 7a4dfadb0..fcfb2ce9d 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Variable.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Variable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ public class Variable extends Expression { this.name = name; } + @Override public int compareTo(Expression e) { int cmp = super.compareTo(e); if (cmp == 0) @@ -31,14 +32,17 @@ public class Variable extends Expression { return cmp; } + @Override public boolean equals(Object o) { return super.equals(o) && name.equals(((Variable) o).name); } + @Override public final Object evaluate(IEvaluationContext context) { return context.getValue(this); } + @Override public Iterator<?> evaluateAsIterator(IEvaluationContext context) { Object value = context.getValue(this); if (value instanceof IRepeatableIterator<?>) @@ -49,6 +53,7 @@ public class Variable extends Expression { return itor; } + @Override public int getExpressionType() { return TYPE_VARIABLE; } @@ -57,14 +62,17 @@ public class Variable extends Expression { return name; } + @Override public String getOperator() { return "<variable>"; //$NON-NLS-1$ } + @Override public int getPriority() { return PRIORITY_VARIABLE; } + @Override public int hashCode() { return name.hashCode(); } @@ -73,10 +81,12 @@ public class Variable extends Expression { context.setValue(this, value); } + @Override public void toString(StringBuffer bld, Variable rootVariable) { bld.append(name); } + @Override int countAccessToEverything() { return this == ExpressionFactory.EVERYTHING ? 1 : 0; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/VersionFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/VersionFunction.java index 3c43a73f7..d6380b631 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/VersionFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/VersionFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.expression; - import org.eclipse.equinox.p2.metadata.Version; /** @@ -22,14 +21,17 @@ public final class VersionFunction extends Function { super(assertLength(operands, 1, 1, KEYWORD_VERSION)); } + @Override boolean assertSingleArgumentClass(Object v) { return v instanceof String; } + @Override Object createInstance(Object arg) { return Version.create((String) arg); } + @Override public String getOperator() { return KEYWORD_VERSION; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/WrappedIQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/WrappedIQuery.java index 827de3580..67567cdc6 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/WrappedIQuery.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/WrappedIQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,6 +34,7 @@ public final class WrappedIQuery extends Function { super(assertLength(operands, 1, 2, KEYWORD_IQUERY)); } + @Override @SuppressWarnings("unchecked") public Object evaluate(IEvaluationContext context) { Object query = operands[0].evaluate(context); @@ -59,6 +60,7 @@ public final class WrappedIQuery extends Function { return ((IQuery<Object>) query).perform((Iterator<Object>) iterator); } + @Override public String getOperator() { return KEYWORD_IQUERY; } @@ -73,6 +75,7 @@ public final class WrappedIQuery extends Function { return false; } + @Override int countAccessToEverything() { return isReferenceTo(ExpressionFactory.EVERYTHING) ? 1 : 0; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java index 314cb7ad3..8c0d20a1f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -59,7 +59,7 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC protected static final Map<String, Integer> keywords; static { - keywords = new HashMap<String, Integer>(); + keywords = new HashMap<>(); keywords.put(KEYWORD_FALSE, Integer.valueOf(TOKEN_FALSE)); keywords.put(KEYWORD_NULL, Integer.valueOf(TOKEN_NULL)); keywords.put(KEYWORD_TRUE, Integer.valueOf(TOKEN_TRUE)); @@ -80,6 +80,7 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC this.factory = factory; } + @Override public synchronized IExpression parse(String exprString) { expression = exprString; tokenPos = 0; @@ -98,6 +99,7 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC } } + @Override public synchronized IExpression parseQuery(String exprString) { expression = exprString; tokenPos = 0; @@ -130,7 +132,7 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC if (currentToken != TOKEN_OR) return expr; - ArrayList<IExpression> exprs = new ArrayList<IExpression>(); + ArrayList<IExpression> exprs = new ArrayList<>(); exprs.add(expr); do { nextToken(); @@ -144,7 +146,7 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC if (currentToken != TOKEN_AND) return expr; - ArrayList<IExpression> exprs = new ArrayList<IExpression>(); + ArrayList<IExpression> exprs = new ArrayList<>(); exprs.add(expr); do { nextToken(); @@ -371,7 +373,7 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC if (currentToken != TOKEN_COMMA) return new IExpression[] {expr}; - ArrayList<IExpression> operands = new ArrayList<IExpression>(); + ArrayList<IExpression> operands = new ArrayList<>(); operands.add(expr); do { nextToken(); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/LDAPFilterParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/LDAPFilterParser.java index 1878fe7b1..a3b5efe07 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/LDAPFilterParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/LDAPFilterParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.osgi.util.NLS; public class LDAPFilterParser { @SuppressWarnings("serial") private static final Map<String, IFilterExpression> filterCache = Collections.<String, IFilterExpression> synchronizedMap(new LinkedHashMap<String, IFilterExpression>() { + @Override public boolean removeEldestEntry(Map.Entry<String, IFilterExpression> expr) { return size() > 64; } @@ -72,7 +73,7 @@ public class LDAPFilterParser { if (c != '(') throw syntaxException(Messages.filter_missing_leftparen); - ArrayList<IExpression> operands = new ArrayList<IExpression>(); + ArrayList<IExpression> operands = new ArrayList<>(); while (c == '(') { IExpression child = parseFilter(); if (!operands.contains(child)) @@ -196,7 +197,7 @@ public class LDAPFilterParser { if (c != '(') throw syntaxException(Messages.filter_missing_leftparen); - ArrayList<IExpression> operands = new ArrayList<IExpression>(); + ArrayList<IExpression> operands = new ArrayList<>(); while (c == '(') { IExpression child = parseFilter(); operands.add(child); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java index 54589384b..b7cd1a229 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,7 +33,7 @@ public class QLParser extends ExpressionParser { private static final Map<String, Integer> qlKeywords; static { - qlKeywords = new HashMap<String, Integer>(); + qlKeywords = new HashMap<>(); qlKeywords.putAll(keywords); qlKeywords.put(KEYWORD_COLLECT, Integer.valueOf(TOKEN_COLLECT)); qlKeywords.put(KEYWORD_FALSE, Integer.valueOf(TOKEN_FALSE)); @@ -55,10 +55,12 @@ public class QLParser extends ExpressionParser { super(factory); } + @Override protected Map<String, Integer> keywordToTokenMap() { return qlKeywords; } + @Override protected IExpression parseCondition() { IExpression expr = parseOr(); if (currentToken == TOKEN_IF) { @@ -71,6 +73,7 @@ public class QLParser extends ExpressionParser { return expr; } + @Override protected IExpression parseMember() { IExpression expr = parseFunction(); String name; @@ -134,6 +137,7 @@ public class QLParser extends ExpressionParser { return parseUnary(); } + @Override protected IExpression parseCollectionLHS() { IExpression expr; switch (currentToken) { @@ -155,6 +159,7 @@ public class QLParser extends ExpressionParser { return expr; } + @Override protected IExpression parseCollectionRHS(IExpression expr, int funcToken) { switch (funcToken) { case TOKEN_SELECT : @@ -215,6 +220,7 @@ public class QLParser extends ExpressionParser { return expr; } + @Override protected IExpression parseUnary() { IExpression expr; switch (currentToken) { @@ -234,6 +240,7 @@ public class QLParser extends ExpressionParser { return expr; } + @Override protected IExpression parseLambdaDefinition() { boolean endingRC = false; int anyIndex = -1; @@ -321,7 +328,7 @@ public class QLParser extends ExpressionParser { List<Object> ids = null; while (currentToken == TOKEN_IDENTIFIER) { if (ids == null) - ids = new ArrayList<Object>(); + ids = new ArrayList<>(); ids.add(tokenValue); nextToken(); if (currentToken == TOKEN_COMMA) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CapabilityIndex.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CapabilityIndex.java index a30d1f530..d7b2b3cac 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CapabilityIndex.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CapabilityIndex.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,7 @@ public class CapabilityIndex extends Index<IInstallableUnit> { private final Map<String, Object> capabilityMap; public CapabilityIndex(Iterator<IInstallableUnit> itor) { - HashMap<String, Object> index = new HashMap<String, Object>(300); + HashMap<String, Object> index = new HashMap<>(300); while (itor.hasNext()) { IInstallableUnit iu = itor.next(); Collection<IProvidedCapability> pcs = iu.getProvidedCapabilities(); @@ -37,7 +37,7 @@ public class CapabilityIndex extends Index<IInstallableUnit> { ArrayList<IInstallableUnit> list; if (prev instanceof IInstallableUnit) { - list = new ArrayList<IInstallableUnit>(); + list = new ArrayList<>(); list.add((IInstallableUnit) prev); } else list = (ArrayList<IInstallableUnit>) prev; @@ -113,6 +113,7 @@ public class CapabilityIndex extends Index<IInstallableUnit> { return RequiredCapability.isSimpleRequirement(rm) ? concatenateUnique(queriedKeys, rm.getParameters()[0]) : getRequirementIDs(rm.createContext(), ((Unary) rm).operand, queriedKeys); } + @Override public Iterator<IInstallableUnit> getCandidates(IEvaluationContext ctx, IExpression variable, IExpression booleanExpr) { Object queriedKeys = null; @@ -157,7 +158,7 @@ public class CapabilityIndex extends Index<IInstallableUnit> { instance &= (object instanceof IRequiredCapability); } if (instance) { - Collection<String> result = new ArrayList<String>(); + Collection<String> result = new ArrayList<>(); for (Object object : collection) { // This instance of check was done above IRequiredCapability capability = (IRequiredCapability) object; @@ -201,7 +202,7 @@ public class CapabilityIndex extends Index<IInstallableUnit> { // to succeed regardless of input matchingIUs = Collections.<IInstallableUnit> emptySet(); } else if (queriedKeys instanceof Collection<?>) { - matchingIUs = new HashSet<IInstallableUnit>(); + matchingIUs = new HashSet<>(); for (Object key : (Collection<Object>) queriedKeys) collectMatchingIUs((String) key, matchingIUs); } else { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CompoundIndex.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CompoundIndex.java index 3caa03025..884664e4b 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CompoundIndex.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/CompoundIndex.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,6 +23,7 @@ public class CompoundIndex<T> implements IIndex<T> { this.indexes = indexes; } + @Override public Iterator<T> getCandidates(IEvaluationContext ctx, IExpression variable, IExpression booleanExpr) { Set<T> result = null; for (IIndex<T> index : indexes) { @@ -31,7 +32,7 @@ public class CompoundIndex<T> implements IIndex<T> { return null; if (indexResult.hasNext()) { if (result == null) - result = new HashSet<T>(); + result = new HashSet<>(); do { result.add(indexResult.next()); } while (indexResult.hasNext()); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IdIndex.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IdIndex.java index a415e8ca4..2ad7343fc 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IdIndex.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IdIndex.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,13 +30,14 @@ public class IdIndex extends Index<IInstallableUnit> { iuMap.add(ius.next()); } + @Override public Iterator<IInstallableUnit> getCandidates(IEvaluationContext ctx, IExpression variable, IExpression booleanExpr) { Object queriedKeys = getQueriedIDs(ctx, variable, InstallableUnit.MEMBER_ID, booleanExpr, null); if (queriedKeys == null) return null; if (queriedKeys instanceof Collection<?>) { - HashSet<IInstallableUnit> collector = new HashSet<IInstallableUnit>(); + HashSet<IInstallableUnit> collector = new HashSet<>(); for (Object key : (Collection<?>) queriedKeys) collector.addAll(iuMap.getUnits((String) key)); return collector.iterator(); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/Index.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/Index.java index b5051bf3d..2923f78e4 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/Index.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/Index.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,7 +40,7 @@ public abstract class Index<T> implements IIndex<T> { if (previous.equals(toAdd)) return previous; - ArrayList<Object> arr = new ArrayList<Object>(); + ArrayList<Object> arr = new ArrayList<>(); arr.add(previous); arr.add(toAdd); return arr; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IndexProvider.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IndexProvider.java index 9917f82e7..ce173fb87 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IndexProvider.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/index/IndexProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,6 +28,7 @@ public abstract class IndexProvider<T> implements IIndexProvider<T>, IQueryable< return result; } + @Override public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor) { return query(this, query, monitor); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java index fdcba7a80..1b5261483 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.p2.metadata; - /** * Provide standardised artifact information to uniquely identify the * corresponding bytes (perhaps not stored as a file). @@ -34,12 +33,14 @@ public interface IArtifactKey extends IVersionedId { * Returns the id for this artifact key. * @return the id segment of the key. */ + @Override public String getId(); /** * Returns the version for this artifact key. * @return the version segment of the key. */ + @Override public Version getVersion(); /** diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java index 039f25968..52a411771 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2007, 2017 IBM Corporation and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -307,5 +307,6 @@ public interface IInstallableUnit extends IVersionedId, Comparable<IInstallableU * <li> The result of <b>getVersion()</b> on both objects are equal * </ul> */ + @Override public boolean equals(Object obj); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ILicense.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ILicense.java index 6f30b086c..21c598892 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ILicense.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ILicense.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2008, 2012 EclipseSource and others. All rights reserved. This +* Copyright (c) 2008, 2017 EclipseSource and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -60,6 +60,7 @@ public interface ILicense { * <li> The result of <b>getDigest()</b> on both objects are equal * </ul> */ + @Override public boolean equals(Object obj); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java index a1c0f3af8..de61165eb 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IProvidedCapability.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2008, 2012 EclipseSource and others. All rights reserved. This +* Copyright (c) 2008, 2017 EclipseSource and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -67,6 +67,7 @@ public interface IProvidedCapability { * <li> The result of <b>getAttributes()</b> on both objects are equal * </ul> */ + @Override public boolean equals(Object other); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IRequirementChange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IRequirementChange.java index 952ca5db6..69eba34dd 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IRequirementChange.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IRequirementChange.java @@ -1,5 +1,6 @@ /******************************************************************************* -* Copyright (c) 2008, 2010 EclipseSource and others. All rights reserved. This +* Copyright (c) 2008, 2017 EclipseSource and others. +* All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -51,5 +52,6 @@ public interface IRequirementChange { * @noreference This method is not intended to be referenced by clients. * @since 2.0 */ + @Override public boolean equals(Object other); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointData.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointData.java index 4bb61999d..e21c0fcab 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointData.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointData.java @@ -1,5 +1,6 @@ /******************************************************************************* -* Copyright (c) 2008, 2012 EclipseSource and others. All rights reserved. This +* Copyright (c) 2008, 2017 EclipseSource and others. +* All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -49,5 +50,6 @@ public interface ITouchpointData { * <li> The result of <b>getInstructions()</b> on both objects are equal * </ul> */ + @Override public boolean equals(Object obj); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointInstruction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointInstruction.java index da221d689..d7ffc19fd 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointInstruction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointInstruction.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2008, 2012 EclipseSource and others. All rights reserved. This +* Copyright (c) 2008, 2017 EclipseSource and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -69,6 +69,7 @@ public interface ITouchpointInstruction { * <li> The result of <b>getImportAttribute()</b> on both objects are equal * </ul> */ + @Override public boolean equals(Object obj); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointType.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointType.java index 847667d46..6e4048141 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointType.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/ITouchpointType.java @@ -1,5 +1,6 @@ /******************************************************************************* -* Copyright (c) 2008, 2010 EclipseSource and others. All rights reserved. This +* Copyright (c) 2008, 2017 EclipseSource and others. +* All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -9,7 +10,6 @@ ******************************************************************************/ package org.eclipse.equinox.p2.metadata; - /** * Identifies a particular touchpoint. A touchpoint is identified by an id * and a version. @@ -26,10 +26,12 @@ public interface ITouchpointType { */ public static final ITouchpointType NONE = new ITouchpointType() { + @Override public String getId() { return "null"; //$NON-NLS-1$ } + @Override public Version getVersion() { return Version.emptyVersion; } @@ -49,6 +51,7 @@ public interface ITouchpointType { * <li> The result of <b>getVersion()</b> on both objects are equal * </ul> */ + @Override public boolean equals(Object obj); }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/MetadataFactory.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/MetadataFactory.java index 061fd118a..ba460d3e6 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/MetadataFactory.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/MetadataFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -80,13 +80,14 @@ public final class MetadataFactory { if (additional == null || additional.size() == 0) return; Collection<IProvidedCapability> current = unit().getProvidedCapabilities(); - ArrayList<IProvidedCapability> all = new ArrayList<IProvidedCapability>(additional.size() + current.size()); + ArrayList<IProvidedCapability> all = new ArrayList<>(additional.size() + current.size()); all.addAll(current); all.addAll(additional); unit().setCapabilities(all.toArray(new IProvidedCapability[all.size()])); } /** @deprecated Use addRequirements(additional) instead */ + @Deprecated public void addRequiredCapabilities(Collection<IRequirement> additional) { addRequirements(additional); } @@ -99,7 +100,7 @@ public final class MetadataFactory { if (additional == null || additional.size() == 0) return; List<IRequirement> current = unit().getRequirements(); - ArrayList<IRequirement> all = new ArrayList<IRequirement>(additional.size() + current.size()); + ArrayList<IRequirement> all = new ArrayList<>(additional.size() + current.size()); all.addAll(current); all.addAll(additional); unit().setRequiredCapabilities(all.toArray(new IRequirement[all.size()])); @@ -125,6 +126,7 @@ public final class MetadataFactory { } /** @deprecated Use getRequirements() instead */ + @Deprecated public List<IRequirement> getRequiredCapabilities() { return getRequirements(); } @@ -137,6 +139,7 @@ public final class MetadataFactory { } /** @deprecated Use getMetaRequirements() instead */ + @Deprecated public Collection<IRequirement> getMetaRequiredCapabilities() { return getMetaRequirements(); } @@ -230,6 +233,7 @@ public final class MetadataFactory { } /** @deprecated Use setRequirements(requirements) instead */ + @Deprecated public void setRequiredCapabilities(IRequirement[] requirements) { setRequirements(requirements); } @@ -243,6 +247,7 @@ public final class MetadataFactory { } /** @deprecated Use setMetaRequirements(requirements) instead */ + @Deprecated public void setMetaRequiredCapabilities(IRequirement[] metaRequirements) { setMetaRequirements(metaRequirements); } @@ -318,6 +323,7 @@ public final class MetadataFactory { ((InstallableUnitFragment) unit()).setHost(Arrays.asList(hostRequirement)); } + @Override InstallableUnit unit() { if (unit == null) unit = new InstallableUnitFragment(); @@ -361,6 +367,7 @@ public final class MetadataFactory { ((InstallableUnitPatch) unit()).setRequirementsChange(changes); } + @Override InstallableUnit unit() { if (unit == null) { unit = new InstallableUnitPatch(); @@ -607,7 +614,7 @@ public final class MetadataFactory { if (instructions.isEmpty()) return EMPTY_TOUCHPOINT_DATA; - Map<String, ITouchpointInstruction> result = new LinkedHashMap<String, ITouchpointInstruction>(instructions.size()); + Map<String, ITouchpointInstruction> result = new LinkedHashMap<>(instructions.size()); for (Map.Entry<String, ? extends Object> entry : instructions.entrySet()) { Object value = entry.getValue(); @@ -631,7 +638,7 @@ public final class MetadataFactory { if (incomingInstructions == null || incomingInstructions.size() == 0) return initial; - Map<String, ITouchpointInstruction> resultInstructions = new HashMap<String, ITouchpointInstruction>(initial.getInstructions()); + Map<String, ITouchpointInstruction> resultInstructions = new HashMap<>(initial.getInstructions()); for (String key : incomingInstructions.keySet()) { ITouchpointInstruction instruction = incomingInstructions.get(key); ITouchpointInstruction existingInstruction = resultInstructions.get(key); @@ -717,7 +724,7 @@ public final class MetadataFactory { * @return the update descriptor */ public static IUpdateDescriptor createUpdateDescriptor(String id, VersionRange range, int severity, String description, URI location) { - Collection<IMatchExpression<IInstallableUnit>> descriptors = new ArrayList<IMatchExpression<IInstallableUnit>>(1); + Collection<IMatchExpression<IInstallableUnit>> descriptors = new ArrayList<>(1); descriptors.add(createMatchExpressionFromRange(IInstallableUnit.NAMESPACE_IU_ID, id, range)); return createUpdateDescriptor(descriptors, severity, description, location); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java index c24b8cb2f..a2db4ce55 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith and others. + * Copyright (c) 2009, 2017 Cloudsmith and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,7 +42,7 @@ import org.eclipse.equinox.internal.p2.metadata.*; */ public abstract class Version implements Comparable<Version>, Serializable { public static final String RAW_PREFIX = "raw:"; //$NON-NLS-1$ - private static WeakHashMap<String, SoftReference<Version>> POOL = new WeakHashMap<String, SoftReference<Version>>(); + private static WeakHashMap<String, SoftReference<Version>> POOL = new WeakHashMap<>(); /** * The version that is semantically greater then all other versions. @@ -92,7 +92,7 @@ public abstract class Version implements Comparable<Version>, Serializable { if (v == null) { v = VersionParser.parse(version, 0, version.length()); synchronized (POOL) { - POOL.put(version, new SoftReference<Version>(v)); + POOL.put(version, new SoftReference<>(v)); } } } @@ -203,6 +203,7 @@ public abstract class Version implements Comparable<Version>, Serializable { */ public abstract boolean isOSGiCompatible(); + @Override public String toString() { StringBuffer buf = new StringBuffer(20); toString(buf); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java index 3ddaf3413..d5e25d0e0 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,7 +36,7 @@ public class VersionRange implements Serializable { * An empty OSGi Version range. */ public static final VersionRange emptyRange = new VersionRange(Version.emptyVersion, true, Version.MAX_VERSION, true); - private static WeakHashMap<String, SoftReference<VersionRange>> POOL = new WeakHashMap<String, SoftReference<VersionRange>>(); + private static WeakHashMap<String, SoftReference<VersionRange>> POOL = new WeakHashMap<>(); private final Version minVersion; private final boolean includeMin; @@ -281,7 +281,7 @@ public class VersionRange implements Serializable { if (v == null) { v = new VersionRange(versionRange); synchronized (POOL) { - POOL.put(versionRange, new SoftReference<VersionRange>(v)); + POOL.put(versionRange, new SoftReference<>(v)); } } } @@ -414,6 +414,7 @@ public class VersionRange implements Serializable { return minVersion.isOSGiCompatible() && maxVersion.isOSGiCompatible(); } + @Override public boolean equals(Object object) { if (!(object instanceof VersionRange)) return false; @@ -421,6 +422,7 @@ public class VersionRange implements Serializable { return includeMin == vr.includeMin && includeMax == vr.includeMax && minVersion.equals(vr.getMinimum()) && maxVersion.equals(vr.getMaximum()); } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -431,6 +433,7 @@ public class VersionRange implements Serializable { return result; } + @Override public String toString() { StringBuffer result = new StringBuffer(); toString(result); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionedId.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionedId.java index ebd1273dc..695ca9aca 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionedId.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionedId.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. + * Copyright (c) 2008, 2017 Code 9 and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -73,6 +73,7 @@ public class VersionedId implements IVersionedId { /** * @return the ID of this VersionedID */ + @Override public String getId() { return id; } @@ -80,10 +81,12 @@ public class VersionedId implements IVersionedId { /** * @return the Version of this VersionedID */ + @Override public Version getVersion() { return version; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -95,6 +98,7 @@ public class VersionedId implements IVersionedId { return id.equals(vname.id) && version.equals(vname.version); } + @Override public int hashCode() { return id.hashCode() * 31 + version.hashCode(); } @@ -105,6 +109,7 @@ public class VersionedId implements IVersionedId { * instance using {{@link #parse(String)}. * @return A string representation of this versioned id */ + @Override public String toString() { return Version.emptyVersion.equals(version) ? id : id + '/' + version.toString(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/SimplePattern.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/SimplePattern.java index 0ba2c0928..917313661 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/SimplePattern.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/SimplePattern.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,18 +33,22 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { return node.match(value, 0); } + @Override public String toString() { return pattern; } + @Override public int compareTo(SimplePattern o) { return pattern.compareTo(o.pattern); } + @Override public boolean equals(Object o) { return o == this || (o instanceof SimplePattern && ((SimplePattern) o).pattern.equals(pattern)); } + @Override public int hashCode() { return 3 * pattern.hashCode(); } @@ -57,6 +61,7 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { } static class AllNode extends Node { + @Override boolean match(CharSequence value, int pos) { return true; } @@ -69,6 +74,7 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { this.next = next; } + @Override boolean match(CharSequence value, int pos) { int top = value.length(); String ending = next.getEndingConstant(); @@ -99,6 +105,7 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { this.next = next; } + @Override boolean match(CharSequence value, int pos) { int top = value.length(); return next == null ? pos + 1 == top : next.match(value, pos + 1); @@ -112,6 +119,7 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { this.constant = constant; } + @Override boolean match(CharSequence value, int pos) { int max = constant.length() + pos; int top = value.length(); @@ -125,6 +133,7 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { return true; } + @Override String getEndingConstant() { return constant; } @@ -139,6 +148,7 @@ public class SimplePattern implements Serializable, Comparable<SimplePattern> { this.constant = constant; } + @Override boolean match(CharSequence value, int pos) { int max = constant.length() + pos; int top = value.length(); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java index 797483ecf..9e6ce5816 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,18 +25,22 @@ public class CollectionResult<T> implements IQueryResult<T> { this.collection = collection == null ? Collections.<T> emptySet() : collection; } + @Override public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor) { return query.perform(iterator()); } + @Override public boolean isEmpty() { return collection.isEmpty(); } + @Override public Iterator<T> iterator() { return collection.iterator(); } + @Override public T[] toArray(Class<T> clazz) { int size = collection.size(); @SuppressWarnings("unchecked") @@ -46,10 +50,12 @@ public class CollectionResult<T> implements IQueryResult<T> { return result; } + @Override public Set<T> toSet() { - return new HashSet<T>(collection); + return new HashSet<>(collection); } + @Override public Set<T> toUnmodifiableSet() { return collection instanceof Set<?> ? Collections.<T> unmodifiableSet((Set<T>) collection) : toSet(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java index ffa7b3072..c196951d3 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,6 +32,7 @@ public class Collector<T> implements IQueryResult<T> { private Set<T> collected = null; public static final Collector<?> EMPTY_COLLECTOR = new Collector<Object>() { + @Override public boolean accept(Object val) { return false; } @@ -87,7 +88,7 @@ public class Collector<T> implements IQueryResult<T> { */ protected Collection<T> getCollection() { if (collected == null) - collected = new HashSet<T>(); + collected = new HashSet<>(); return collected; } @@ -96,6 +97,7 @@ public class Collector<T> implements IQueryResult<T> { * @return <code>true</code> if this collector has accepted any results, * and <code>false</code> otherwise. */ + @Override public boolean isEmpty() { return collected == null || collected.isEmpty(); } @@ -105,6 +107,7 @@ public class Collector<T> implements IQueryResult<T> { * * @return an iterator of the collected objects. */ + @Override public Iterator<T> iterator() { return collected == null ? Collections.<T> emptyList().iterator() : collected.iterator(); } @@ -124,6 +127,7 @@ public class Collector<T> implements IQueryResult<T> { * @throws ArrayStoreException the runtime type of the specified array is * not a super-type of the runtime type of every collected object */ + @Override public T[] toArray(Class<T> clazz) { int size = collected == null ? 0 : collected.size(); @SuppressWarnings("unchecked") @@ -138,13 +142,15 @@ public class Collector<T> implements IQueryResult<T> { * * @return An unmodifiable collection of the collected objects */ + @Override public Set<T> toSet() { - return collected == null ? new HashSet<T>() : new HashSet<T>(collected); + return collected == null ? new HashSet<>() : new HashSet<>(collected); } /** * Performs a query on this results of this collector. */ + @Override public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor) { IQueryResult<T> result; if (monitor == null) @@ -164,6 +170,7 @@ public class Collector<T> implements IQueryResult<T> { * * @return An unmodifiable collection of the collected objects */ + @Override public Set<T> toUnmodifiableSet() { if (collected == null) { return Collections.emptySet(); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java index 621838be4..727d48fa1 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java @@ -1,5 +1,6 @@ /******************************************************************************* -* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This +* Copyright (c) 2009, 2017 EclipseSource and others. +* All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -36,6 +37,7 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { this.iterator = iterator; } + @Override public Iterator<T> getCandidates(IEvaluationContext ctx, IExpression variable, IExpression booleanExpr) { return iterator; } @@ -69,6 +71,7 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { this(new IQueryable[] {query1, query2}); } + @Override public IIndex<T> getIndex(String memberName) { // Check that at least one of the queryable can present an index // for the given member. @@ -88,7 +91,7 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { // Nobody had an index for this member return null; - ArrayList<IIndex<T>> indexes = new ArrayList<IIndex<T>>(queryables.length); + ArrayList<IIndex<T>> indexes = new ArrayList<>(queryables.length); for (IQueryable<T> queryable : queryables) { if (queryable instanceof IIndexProvider<?>) { @SuppressWarnings("unchecked") @@ -97,14 +100,15 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { if (index != null) indexes.add(index); else - indexes.add(new PassThroughIndex<T>(ip.everything())); + indexes.add(new PassThroughIndex<>(ip.everything())); } else { - indexes.add(new PassThroughIndex<T>(getIteratorFromQueryable(queryable))); + indexes.add(new PassThroughIndex<>(getIteratorFromQueryable(queryable))); } } - return indexes.size() == 1 ? indexes.get(0) : new CompoundIndex<T>(indexes); + return indexes.size() == 1 ? indexes.get(0) : new CompoundIndex<>(indexes); } + @Override public Iterator<T> everything() { if (queryables.length == 0) return Collections.<T> emptySet().iterator(); @@ -112,12 +116,13 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { if (queryables.length == 1) return getIteratorFromQueryable(queryables[0]); - ArrayList<Iterator<T>> iterators = new ArrayList<Iterator<T>>(queryables.length); + ArrayList<Iterator<T>> iterators = new ArrayList<>(queryables.length); for (IQueryable<T> queryable : queryables) iterators.add(getIteratorFromQueryable(queryable)); - return new CompoundIterator<T>(iterators.iterator()); + return new CompoundIterator<>(iterators.iterator()); } + @Override public Object getManagedProperty(Object client, String memberName, Object key) { for (IQueryable<T> queryable : queryables) { if (queryable instanceof IIndexProvider<?>) { @@ -140,11 +145,13 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { static class IteratorCapture<T> implements IQuery<T> { private Iterator<T> capturedIterator; + @Override public IQueryResult<T> perform(Iterator<T> iterator) { capturedIterator = iterator; return Collector.emptyCollector(); } + @Override public IExpression getExpression() { return null; } @@ -160,7 +167,7 @@ public final class CompoundQueryable<T> extends IndexProvider<T> { IIndexProvider<T> ip = (IIndexProvider<T>) queryable; return ip.everything(); } - IteratorCapture<T> capture = new IteratorCapture<T>(); + IteratorCapture<T> capture = new IteratorCapture<>(); queryable.query(capture, new NullProgressMonitor()); return capture.getCapturedIterator(); } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java index b81bcfe9a..bbe61ae22 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java @@ -44,9 +44,10 @@ public class ExpressionMatchQuery<T> implements IMatchQuery<T>, IQueryWithIndex< return matchingClass; } + @Override public IQueryResult<T> perform(IIndexProvider<T> indexProvider) { if (((MatchExpression<T>) expression).operand == ExpressionUtil.TRUE_EXPRESSION) - return new QueryResult<T>(RepeatableIterator.create(indexProvider)); + return new QueryResult<>(RepeatableIterator.create(indexProvider)); Iterator<T> iterator = null; int top = indexedMembers.size(); for (int idx = 0; idx < top; ++idx) { @@ -63,22 +64,24 @@ public class ExpressionMatchQuery<T> implements IMatchQuery<T>, IQueryWithIndex< return perform(iterator); } + @Override public IQueryResult<T> perform(Iterator<T> iterator) { if (((MatchExpression<T>) expression).operand == ExpressionUtil.TRUE_EXPRESSION) - return new QueryResult<T>(iterator); + return new QueryResult<>(iterator); HashSet<T> result = null; while (iterator.hasNext()) { T value = iterator.next(); if (isMatch(value)) { if (result == null) - result = new HashSet<T>(); + result = new HashSet<>(); result.add(value); } } - return result == null ? Collector.<T> emptyCollector() : new CollectionResult<T>(result); + return result == null ? Collector.<T> emptyCollector() : new CollectionResult<>(result); } + @Override public boolean isMatch(T candidate) { if (!matchingClass.isInstance(candidate)) return false; @@ -86,6 +89,7 @@ public class ExpressionMatchQuery<T> implements IMatchQuery<T>, IQueryWithIndex< return Boolean.TRUE == expression.evaluate(context); } + @Override public IMatchExpression<T> getExpression() { return expression; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionQuery.java index 8ec52f4e4..3921029b0 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionQuery.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.p2.query; - import java.util.Iterator; import org.eclipse.equinox.internal.p2.metadata.expression.*; import org.eclipse.equinox.p2.metadata.expression.*; @@ -38,14 +37,17 @@ public class ExpressionQuery<T> implements IQueryWithIndex<T> { return elementClass; } + @Override public IQueryResult<T> perform(IIndexProvider<T> indexProvider) { - return new QueryResult<T>(expression.iterator(expression.createContext(elementClass, indexProvider))); + return new QueryResult<>(expression.iterator(expression.createContext(elementClass, indexProvider))); } + @Override public IQueryResult<T> perform(Iterator<T> iterator) { - return new QueryResult<T>(expression.iterator(expression.createContext(elementClass, iterator))); + return new QueryResult<>(expression.iterator(expression.createContext(elementClass, iterator))); } + @Override public IContextExpression<T> getExpression() { return expression; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IMatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IMatchQuery.java index 7995464d5..ca17b1810 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IMatchQuery.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IMatchQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This +* Copyright (c) 2009, 2017 EclipseSource and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -28,6 +28,7 @@ package org.eclipse.equinox.p2.query; * }</pre> * @since 2.0 */ +@Deprecated public interface IMatchQuery<T> extends IQuery<T> { /** diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java index acdbc5e74..0c247684a 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This +* Copyright (c) 2009, 2017 EclipseSource and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -30,6 +30,7 @@ public interface IQueryResult<T> extends IQueryable<T>, Iterable<T> { * * @return an iterator of the collected objects. */ + @Override public Iterator<T> iterator(); /** diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/MatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/MatchQuery.java index 52aaa8909..f0089f9cb 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/MatchQuery.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/MatchQuery.java @@ -1,5 +1,6 @@ /******************************************************************************* -* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This +* Copyright (c) 2009, 2017 EclipseSource and others. +* All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -35,6 +36,7 @@ import org.eclipse.equinox.p2.metadata.expression.IExpression; * }</pre> * @since 2.0 */ +@Deprecated public abstract class MatchQuery<T> implements IMatchQuery<T> { /** @@ -48,14 +50,16 @@ public abstract class MatchQuery<T> implements IMatchQuery<T> { * Clients should call {@link #perform(Iterator)} * @since 2.0 */ + @Override public abstract boolean isMatch(T candidate); /** * Performs this query on the given iterator, passing all objects in the iterator * that match the criteria of this query to the given result. */ + @Override public final IQueryResult<T> perform(Iterator<T> iterator) { - Collector<T> result = new Collector<T>(); + Collector<T> result = new Collector<>(); while (iterator.hasNext()) { T candidate = iterator.next(); if (candidate != null && isMatch(candidate)) @@ -95,6 +99,7 @@ public abstract class MatchQuery<T> implements IMatchQuery<T> { // nothing to do by default } + @Override public IExpression getExpression() { return null; } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/QueryUtil.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/QueryUtil.java index 4a66a26b1..1e0365207 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/QueryUtil.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/QueryUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 Cloudsmith Inc. and others. + * Copyright (c) 2010, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -58,7 +58,7 @@ public class QueryUtil { public static <T> IQueryable<T> compoundQueryable(Collection<? extends IQueryable<T>> queryables) { // don't suppress the warning as it will cause warnings in the official build // see bug 423628. Write this without unchecked conversion. - return new CompoundQueryable<T>(queryables.toArray(new IQueryable[queryables.size()])); + return new CompoundQueryable<>(queryables.toArray(new IQueryable[queryables.size()])); } /** @@ -159,7 +159,7 @@ public class QueryUtil { * @return A compound query */ public static <T> IQuery<T> createCompoundQuery(IQuery<? extends T> query1, IQuery<T> query2, boolean and) { - ArrayList<IQuery<? extends T>> queries = new ArrayList<IQuery<? extends T>>(2); + ArrayList<IQuery<? extends T>> queries = new ArrayList<>(2); queries.add(query1); queries.add(query2); return createCompoundQuery(queries, and); @@ -342,7 +342,7 @@ public class QueryUtil { * @return The created query */ public static IQuery<IInstallableUnit> createMatchQuery(IExpression matchExpression, Object... parameters) { - return new ExpressionMatchQuery<IInstallableUnit>(IInstallableUnit.class, matchExpression, parameters); + return new ExpressionMatchQuery<>(IInstallableUnit.class, matchExpression, parameters); } /** @@ -354,7 +354,7 @@ public class QueryUtil { * @return The created query */ public static IQuery<IInstallableUnit> createMatchQuery(String matchExpression, Object... parameters) { - return new ExpressionMatchQuery<IInstallableUnit>(IInstallableUnit.class, matchExpression, parameters); + return new ExpressionMatchQuery<>(IInstallableUnit.class, matchExpression, parameters); } /** @@ -367,7 +367,7 @@ public class QueryUtil { * @return The created query */ public static <T> IQuery<T> createMatchQuery(Class<? extends T> matchingClass, IExpression matchExpression, Object... parameters) { - return new ExpressionMatchQuery<T>(matchingClass, matchExpression, parameters); + return new ExpressionMatchQuery<>(matchingClass, matchExpression, parameters); } /** @@ -381,7 +381,7 @@ public class QueryUtil { * @return The created query */ public static <T> IQuery<T> createMatchQuery(Class<? extends T> matchingClass, String matchExpression, Object... parameters) { - return new ExpressionMatchQuery<T>(matchingClass, matchExpression, parameters); + return new ExpressionMatchQuery<>(matchingClass, matchExpression, parameters); } /** @@ -422,7 +422,7 @@ public class QueryUtil { * @return A query pipe */ public static <T> IQuery<T> createPipeQuery(IQuery<? extends T> query1, IQuery<? extends T> query2) { - ArrayList<IQuery<? extends T>> queries = new ArrayList<IQuery<? extends T>>(2); + ArrayList<IQuery<? extends T>> queries = new ArrayList<>(2); queries.add(query1); queries.add(query2); return createPipeQuery(queries); @@ -436,7 +436,7 @@ public class QueryUtil { * @return The created query */ public static IQuery<IInstallableUnit> createQuery(IExpression expression, Object... parameters) { - return new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, expression, parameters); + return new ExpressionQuery<>(IInstallableUnit.class, expression, parameters); } /** @@ -447,7 +447,7 @@ public class QueryUtil { * @return The created query */ public static IQuery<IInstallableUnit> createQuery(String expression, Object... parameters) { - return new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, expression, parameters); + return new ExpressionQuery<>(IInstallableUnit.class, expression, parameters); } /** @@ -459,7 +459,7 @@ public class QueryUtil { * @return The created query */ public static <T> IQuery<T> createQuery(Class<? extends T> matchingClass, IExpression expression, Object... parameters) { - return new ExpressionQuery<T>(matchingClass, expression, parameters); + return new ExpressionQuery<>(matchingClass, expression, parameters); } /** @@ -472,7 +472,7 @@ public class QueryUtil { * @return The created query */ public static <T> IQuery<T> createQuery(Class<? extends T> matchingClass, String expression, Object... parameters) { - return new ExpressionQuery<T>(matchingClass, expression, parameters); + return new ExpressionQuery<>(matchingClass, expression, parameters); } /** |