1 package org
.asamk
.signal
.manager
.api
;
3 import org
.asamk
.signal
.manager
.groups
.GroupId
;
4 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
5 import org
.whispersystems
.signalservice
.api
.util
.InvalidNumberException
;
6 import org
.whispersystems
.signalservice
.api
.util
.PhoneNumberFormatter
;
7 import org
.whispersystems
.signalservice
.api
.util
.UuidUtil
;
11 public abstract class RecipientIdentifier
{
13 public static class NoteToSelf
extends RecipientIdentifier
{
16 public boolean equals(final Object obj
) {
17 return obj
instanceof NoteToSelf
;
21 public int hashCode() {
26 public abstract static class Single
extends RecipientIdentifier
{
28 public static Single
fromString(String identifier
, String localNumber
) throws InvalidNumberException
{
29 return UuidUtil
.isUuid(identifier
)
30 ?
new Uuid(UUID
.fromString(identifier
))
31 : new Number(PhoneNumberFormatter
.formatNumber(identifier
, localNumber
));
34 public static Single
fromAddress(SignalServiceAddress address
) {
35 return new Uuid(address
.getUuid());
39 public static class Uuid
extends Single
{
41 public final UUID uuid
;
43 public Uuid(final UUID uuid
) {
48 public boolean equals(final Object o
) {
49 if (this == o
) return true;
50 if (o
== null || getClass() != o
.getClass()) return false;
52 final Uuid uuid1
= (Uuid
) o
;
54 return uuid
.equals(uuid1
.uuid
);
58 public int hashCode() {
59 return uuid
.hashCode();
63 public static class Number
extends Single
{
65 public final String number
;
67 public Number(final String number
) {
72 public boolean equals(final Object o
) {
73 if (this == o
) return true;
74 if (o
== null || getClass() != o
.getClass()) return false;
76 final Number number1
= (Number
) o
;
78 return number
.equals(number1
.number
);
82 public int hashCode() {
83 return number
.hashCode();
87 public static class Group
extends RecipientIdentifier
{
89 public final GroupId groupId
;
91 public Group(final GroupId groupId
) {
92 this.groupId
= groupId
;
96 public boolean equals(final Object o
) {
97 if (this == o
) return true;
98 if (o
== null || getClass() != o
.getClass()) return false;
100 final Group group
= (Group
) o
;
102 return groupId
.equals(group
.groupId
);
106 public int hashCode() {
107 return groupId
.hashCode();