mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Addressed issues from code review.
This commit is contained in:
@@ -1,37 +1,18 @@
|
||||
package org.briarproject.api.contact;
|
||||
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
|
||||
public class Contact {
|
||||
|
||||
public enum Status {
|
||||
|
||||
ADDING(0), ACTIVE(1), REMOVING(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
Status(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Status fromValue(int value) {
|
||||
for (Status s : values()) if (s.value == value) return s;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private final ContactId id;
|
||||
private final Author author;
|
||||
private final AuthorId localAuthorId;
|
||||
private final Status status;
|
||||
private final StorageStatus status;
|
||||
|
||||
public Contact(ContactId id, Author author, AuthorId localAuthorId,
|
||||
Status status) {
|
||||
StorageStatus status) {
|
||||
this.id = id;
|
||||
this.author = author;
|
||||
this.localAuthorId = localAuthorId;
|
||||
@@ -50,7 +31,7 @@ public class Contact {
|
||||
return localAuthorId;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
public StorageStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.util.Collection;
|
||||
public interface ContactManager {
|
||||
|
||||
/** Registers a hook to be called whenever a contact is added. */
|
||||
void registerContactAddedHook(ContactAddedHook hook);
|
||||
void registerAddContactHook(AddContactHook hook);
|
||||
|
||||
/** Registers a hook to be called whenever a contact is removed. */
|
||||
void registerContactRemovedHook(ContactRemovedHook hook);
|
||||
void registerRemoveContactHook(RemoveContactHook hook);
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
@@ -29,11 +29,11 @@ public interface ContactManager {
|
||||
/** Removes a contact and all associated state. */
|
||||
void removeContact(ContactId c) throws DbException;
|
||||
|
||||
interface ContactAddedHook {
|
||||
void contactAdded(ContactId c);
|
||||
interface AddContactHook {
|
||||
void addingContact(ContactId c);
|
||||
}
|
||||
|
||||
interface ContactRemovedHook {
|
||||
void contactRemoved(ContactId c);
|
||||
interface RemoveContactHook {
|
||||
void removingContact(ContactId c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user