diff options
author | cyberta <cyberta@riseup.net> | 2022-07-19 17:26:25 +0000 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2022-07-19 17:26:25 +0000 |
commit | 6bc3a79e6d09a8fa1857f1d502a87c1c0633be35 (patch) | |
tree | 7aa914e63bb6aae27c8521dd198e3f7416e9890c /app/src/main/java/se/leap/bitmaskclient/base/models/Pair.java | |
parent | abd8c8d06f01cc5b794a18779c2ea36b9317b4e3 (diff) | |
parent | 4a95fbad79333bc1cc83b22c8122293a3d8d332f (diff) |
Merge branch 'integrate_obfsvpn' into 'master'
update bitmaskcore, integrating obfsvpn
See merge request leap/bitmask_android!190
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/base/models/Pair.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/base/models/Pair.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Pair.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Pair.java new file mode 100644 index 00000000..e2ef4622 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Pair.java @@ -0,0 +1,57 @@ +package se.leap.bitmaskclient.base.models; + +import java.util.Objects; + +/** + * Container to ease passing around a tuple of two objects. This object provides a sensible + * implementation of equals(), returning true if equals() is true on each of the contained + * objects. + */ +public class Pair<F, S> { + public final F first; + public final S second; + + /** + * Constructor for a Pair. + * + * @param first the first object in the Pair + * @param second the second object in the pair + */ + public Pair(F first, S second) { + this.first = first; + this.second = second; + } + + /** + * Checks the two objects for equality by delegating to their respective + * {@link Object#equals(Object)} methods. + * + * @param o the {@link Pair} to which this one is to be checked for equality + * @return true if the underlying objects of the Pair are both considered + * equal + */ + @Override + public boolean equals(Object o) { + if (!(o instanceof Pair)) { + return false; + } + Pair<?, ?> p = (Pair<?, ?>) o; + return Objects.equals(p.first, first) && Objects.equals(p.second, second); + } + + /** + * Compute a hash code using the hash codes of the underlying objects + * + * @return a hashcode of the Pair + */ + @Override + public int hashCode() { + return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode()); + } + + @Override + public String toString() { + return "Pair{" + String.valueOf(first) + " " + String.valueOf(second) + "}"; + } + +} |