@Test(expected = BadGroupIdException.class) public void bad_encoding__gv2_prefix_with_wrong_length() throws BadGroupIdException { GroupId.parse("__signal_group__v2__!000102030405060708090a0b0c0d0e0f"); }
public static @NonNull GroupId parse(@NonNull String encodedGroupId) throws BadGroupIdException { try { if (!isEncodedGroup(encodedGroupId)) { throw new BadGroupIdException("Invalid encoding"); } byte[] bytes = extractDecodedId(encodedGroupId); if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V2_PREFIX)) return v2(bytes); else if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V1_PREFIX)) return v1(bytes); else if (encodedGroupId.startsWith(ENCODED_MMS_GROUP_PREFIX)) return mms(bytes); throw new BadGroupIdException(); } catch (IOException e) { throw new BadGroupIdException(e); } }
GroupId { public static @NonNull GroupId parse(@NonNull String encodedGroupId) throws BadGroupIdException { try { if (!isEncodedGroup(encodedGroupId)) { throw new BadGroupIdException("Invalid encoding"); } byte[] bytes = extractDecodedId(encodedGroupId); if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V2_PREFIX)) return v2(bytes); else if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V1_PREFIX)) return v1(bytes); else if (encodedGroupId.startsWith(ENCODED_MMS_GROUP_PREFIX)) return mms(bytes); throw new BadGroupIdException(); } catch (IOException e) { throw new BadGroupIdException(e); } } }
GroupId { public static @NonNull GroupId parse(@NonNull String encodedGroupId) throws BadGroupIdException { try { if (!isEncodedGroup(encodedGroupId)) { throw new BadGroupIdException("Invalid encoding"); } byte[] bytes = extractDecodedId(encodedGroupId); if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V2_PREFIX)) return v2(bytes); else if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V1_PREFIX)) return v1(bytes); else if (encodedGroupId.startsWith(ENCODED_MMS_GROUP_PREFIX)) return mms(bytes); throw new BadGroupIdException(); } catch (IOException e) { throw new BadGroupIdException(e); } } private  GroupId(@NonNull String prefix, @NonNull byte[] bytes); }
GroupId { public static @NonNull GroupId parse(@NonNull String encodedGroupId) throws BadGroupIdException { try { if (!isEncodedGroup(encodedGroupId)) { throw new BadGroupIdException("Invalid encoding"); } byte[] bytes = extractDecodedId(encodedGroupId); if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V2_PREFIX)) return v2(bytes); else if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V1_PREFIX)) return v1(bytes); else if (encodedGroupId.startsWith(ENCODED_MMS_GROUP_PREFIX)) return mms(bytes); throw new BadGroupIdException(); } catch (IOException e) { throw new BadGroupIdException(e); } } private  GroupId(@NonNull String prefix, @NonNull byte[] bytes); static @NonNull GroupId.Mms mms(byte[] mmsGroupIdBytes); static @NonNull GroupId.V1 v1orThrow(byte[] gv1GroupIdBytes); static @NonNull GroupId.V1 v1(byte[] gv1GroupIdBytes); static @NonNull GroupId.V1 v1Exact(byte[] gv1GroupIdBytes); static GroupId.V1 createV1(@NonNull SecureRandom secureRandom); static GroupId.Mms createMms(@NonNull SecureRandom secureRandom); static GroupId.V2 v2(@NonNull GroupIdentifier groupIdentifier); static GroupId.V2 v2(@NonNull GroupMasterKey masterKey); static GroupId.Push push(byte[] bytes); static GroupId.Push pushOrThrow(byte[] bytes); static @NonNull GroupId parseOrThrow(@NonNull String encodedGroupId); static @NonNull GroupId parse(@NonNull String encodedGroupId); static @Nullable GroupId parseNullable(@Nullable String encodedGroupId); static @Nullable GroupId parseNullableOrThrow(@Nullable String encodedGroupId); static boolean isEncodedGroup(@NonNull String groupId); byte[] getDecodedId(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @NonNull @Override String toString(); abstract boolean isMms(); abstract boolean isV1(); abstract boolean isV2(); abstract boolean isPush(); GroupId.Mms requireMms(); GroupId.V1 requireV1(); GroupId.V2 requireV2(); GroupId.Push requirePush(); }
GroupId { public static @NonNull GroupId parse(@NonNull String encodedGroupId) throws BadGroupIdException { try { if (!isEncodedGroup(encodedGroupId)) { throw new BadGroupIdException("Invalid encoding"); } byte[] bytes = extractDecodedId(encodedGroupId); if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V2_PREFIX)) return v2(bytes); else if (encodedGroupId.startsWith(ENCODED_SIGNAL_GROUP_V1_PREFIX)) return v1(bytes); else if (encodedGroupId.startsWith(ENCODED_MMS_GROUP_PREFIX)) return mms(bytes); throw new BadGroupIdException(); } catch (IOException e) { throw new BadGroupIdException(e); } } private  GroupId(@NonNull String prefix, @NonNull byte[] bytes); static @NonNull GroupId.Mms mms(byte[] mmsGroupIdBytes); static @NonNull GroupId.V1 v1orThrow(byte[] gv1GroupIdBytes); static @NonNull GroupId.V1 v1(byte[] gv1GroupIdBytes); static @NonNull GroupId.V1 v1Exact(byte[] gv1GroupIdBytes); static GroupId.V1 createV1(@NonNull SecureRandom secureRandom); static GroupId.Mms createMms(@NonNull SecureRandom secureRandom); static GroupId.V2 v2(@NonNull GroupIdentifier groupIdentifier); static GroupId.V2 v2(@NonNull GroupMasterKey masterKey); static GroupId.Push push(byte[] bytes); static GroupId.Push pushOrThrow(byte[] bytes); static @NonNull GroupId parseOrThrow(@NonNull String encodedGroupId); static @NonNull GroupId parse(@NonNull String encodedGroupId); static @Nullable GroupId parseNullable(@Nullable String encodedGroupId); static @Nullable GroupId parseNullableOrThrow(@Nullable String encodedGroupId); static boolean isEncodedGroup(@NonNull String groupId); byte[] getDecodedId(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @NonNull @Override String toString(); abstract boolean isMms(); abstract boolean isV1(); abstract boolean isV2(); abstract boolean isPush(); GroupId.Mms requireMms(); GroupId.V1 requireV1(); GroupId.V2 requireV2(); GroupId.Push requirePush();  }