1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-27 06:22:07 +01:00

EqualsUtil, HashCode: Add methods for lists

This commit is contained in:
Paul Schaub 2020-09-11 14:36:11 +02:00
parent 0a6c21982b
commit d4e205beed
2 changed files with 28 additions and 0 deletions

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smack.util;
import java.util.List;
public final class EqualsUtil {
private EqualsUtil() {
@ -244,6 +246,19 @@ public final class EqualsUtil {
});
return this;
}
public <O> Builder append(List<O> left, List<O> right) {
nullSafeCompare(left, right, () -> {
if (left.size() != right.size()) {
isEquals = false;
return;
}
for (int i = 0; i < left.size() && isEquals; i++) {
append(left.get(i), right.get(i));
}
});
return this;
}
}
}

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smack.util;
import java.util.List;
public class HashCode {
private static final int MULTIPLIER_VALUE = 37;
@ -203,6 +205,17 @@ public class HashCode {
return this;
}
public <O> Builder append(List<O> list) {
if (list == null) {
applyHash();
return this;
}
for (O o : list) {
append(o);
}
return this;
}
public int build() {
return hashcode;
}