Author: not
Date: Mon Dec 21 14:38:30 2009
New Revision: 892836
URL: http://svn.apache.org/viewvc?rev=892836&view=rev
Log:
ARIES-52 added equals and hashcode to version range and content
Modified:
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
Modified:
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
URL:
http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java?rev=892836&r1=892835&r2=892836&view=diff
==============================================================================
---
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
(original)
+++
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
Mon Dec 21 14:38:30 2009
@@ -116,9 +116,25 @@
if (other instanceof ContentImpl) {
ContentImpl otherContent = (ContentImpl)other;
+
+ Map<String,String> attributesWithoutVersion = attributes;
+
+ if (attributes.containsKey("version")) {
+ attributesWithoutVersion = new HashMap<String, String>(attributes);
+ attributesWithoutVersion.remove("version");
+ }
+
+ Map<String, String> otherAttributesWithoutVersion =
otherContent.attributes;
+
+ if (otherContent.attributes.containsKey("version")) {
+ otherAttributesWithoutVersion = new HashMap<String,
String>(otherContent.attributes);
+ otherAttributesWithoutVersion.remove("version");
+ }
+
return contentName.equals(otherContent.contentName) &&
- attributes.equals(otherContent.attributes) &&
- directives.equals(otherContent.directives);
+ attributesWithoutVersion.equals(otherAttributesWithoutVersion) &&
+ directives.equals(otherContent.directives) &&
+ getVersion().equals(otherContent.getVersion());
}
return false;
Modified:
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
URL:
http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java?rev=892836&r1=892835&r2=892836&view=diff
==============================================================================
---
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
(original)
+++
incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
Mon Dec 21 14:38:30 2009
@@ -25,7 +25,7 @@
import org.apache.aries.application.VersionRange;
-public class VersionRangeImpl implements VersionRange
+public final class VersionRangeImpl implements VersionRange
{
private String version;
/** The minimum desired version for the bundle */
@@ -63,13 +63,30 @@
}
/* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#toString()
- */
-...@override
+ * @see org.apache.aries.application.impl.VersionRange#toString()
+ */
+ @Override
public String toString() {
return this.version;
}
+ public int hashCode()
+ {
+ return version.hashCode();
+ }
+
+ public boolean equals(Object other)
+ {
+ if (other == this) return true;
+ if (other == null) return false;
+
+ if (other instanceof VersionRangeImpl) {
+ return version.equals(((VersionRangeImpl)other).version);
+ }
+
+ return false;
+ }
+
/* (non-Javadoc)
* @see org.apache.aries.application.impl.VersionRange#getExactVersion()
*/