X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/22f19c406779893d08675c2d06d2b7708cc3f2a8..9e6a3534275d5bac8454792e05280f13fa5ef13c:/src/main/java/org/asamk/signal/manager/GroupId.java diff --git a/src/main/java/org/asamk/signal/manager/GroupId.java b/src/main/java/org/asamk/signal/manager/GroupId.java deleted file mode 100644 index 34e18e8e..00000000 --- a/src/main/java/org/asamk/signal/manager/GroupId.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.asamk.signal.manager; - -import org.whispersystems.util.Base64; - -import java.util.Arrays; - -public abstract class GroupId { - - private final byte[] id; - - public static GroupIdV1 v1(byte[] id) { - return new GroupIdV1(id); - } - - public static GroupIdV2 v2(byte[] id) { - return new GroupIdV2(id); - } - - public static GroupId unknownVersion(byte[] id) { - if (id.length == 16) { - return new GroupIdV1(id); - } else if (id.length == 32) { - return new GroupIdV2(id); - } - - throw new AssertionError("Invalid group id of size " + id.length); - } - - public static GroupId fromBase64(String id) throws GroupIdFormatException { - try { - return unknownVersion(java.util.Base64.getDecoder().decode(id)); - } catch (Throwable e) { - throw new GroupIdFormatException(id, e); - } - } - - public GroupId(final byte[] id) { - this.id = id; - } - - public byte[] serialize() { - return id; - } - - public String toBase64() { - return Base64.encodeBytes(id); - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - final GroupId groupId = (GroupId) o; - - return Arrays.equals(id, groupId.id); - } - - @Override - public int hashCode() { - return Arrays.hashCode(id); - } -}