commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1556201 - in /commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers: OwnerInformation.java spi/SimpleArchiveEntry.java
Date Tue, 07 Jan 2014 13:01:58 GMT
Author: bodewig
Date: Tue Jan  7 13:01:58 2014
New Revision: 1556201

URL: http://svn.apache.org/r1556201
Log:
implement equals

Modified:
    commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/OwnerInformation.java
    commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/spi/SimpleArchiveEntry.java

Modified: commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/OwnerInformation.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/OwnerInformation.java?rev=1556201&r1=1556200&r2=1556201&view=diff
==============================================================================
--- commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/OwnerInformation.java
(original)
+++ commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/OwnerInformation.java
Tue Jan  7 13:01:58 2014
@@ -84,4 +84,27 @@ public class OwnerInformation {
         return groupId;
     }
 
+    @Override
+    public int hashCode() {
+        return 17 * groupId + userId;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        OwnerInformation other = (OwnerInformation) obj;
+        return userId == other.userId
+            && groupId == other.groupId
+            && equals(userName, other.userName)
+            && equals(groupName, other.groupName);
+    }
+
+    private static boolean equals(Object o1, Object o2) {
+        return o1 == null ? o2 == null : o1.equals(o2);
+    }
 }

Modified: commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/spi/SimpleArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/spi/SimpleArchiveEntry.java?rev=1556201&r1=1556200&r2=1556201&view=diff
==============================================================================
--- commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/spi/SimpleArchiveEntry.java
(original)
+++ commons/proper/compress/branches/compress-2.0/src/main/java/org/apache/commons/compress2/archivers/spi/SimpleArchiveEntry.java
Tue Jan  7 13:01:58 2014
@@ -72,8 +72,37 @@ public class SimpleArchiveEntry implemen
         return owner;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (name == null ? 0 : name.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        SimpleArchiveEntry other = (SimpleArchiveEntry) obj;
+        return equals(name, other.name)
+            && size == other.size
+            && dirFlag == other.dirFlag
+            && equals(lastModified, other.lastModified)
+            && equals(owner, other.owner);
+    }
+
     // TODO second instance (after ArchiveEntryParameters)
     private static Date clone(Date d) {
         return d == null ? null : (Date) d.clone();
     }
+
+    // TODO second instance (after OwnerInformation)
+    private static boolean equals(Object o1, Object o2) {
+        return o1 == null ? o2 == null : o1.equals(o2);
+    }
 }



Mime
View raw message