Converted Group from an interface to an immutable class.

This commit is contained in:
akwizgran
2012-12-15 19:42:00 +00:00
parent ac0420d276
commit 6dd17a22eb
14 changed files with 56 additions and 148 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}