mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Converted Group from an interface to an immutable class.
This commit is contained in:
@@ -1,17 +1,43 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
/** A group to which users may subscribe. */
|
||||
public interface Group {
|
||||
public class Group {
|
||||
|
||||
private final GroupId id;
|
||||
private final String name;
|
||||
private final byte[] publicKey;
|
||||
|
||||
public Group(GroupId id, String name, byte[] publicKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
|
||||
/** Returns the group's unique identifier. */
|
||||
GroupId getId();
|
||||
public GroupId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/** Returns the group's name. */
|
||||
String getName();
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the group is restricted, returns the public key that is used to
|
||||
* authorise all messages sent to the group. Otherwise returns null.
|
||||
*/
|
||||
byte[] getPublicKey();
|
||||
public byte[] getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Group && id.equals(((Group) o).id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,4 @@ import java.io.IOException;
|
||||
public interface GroupFactory {
|
||||
|
||||
Group createGroup(String name, byte[] publicKey) throws IOException;
|
||||
|
||||
Group createGroup(GroupId id, String name, byte[] publicKey);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user