Added names to contacts, created Contact class in API.

This commit is contained in:
akwizgran
2013-02-12 17:38:49 +00:00
parent 79fc630ab7
commit 96f8e49d64
8 changed files with 153 additions and 75 deletions

View File

@@ -0,0 +1,31 @@
package net.sf.briar.api;
public class Contact {
private final ContactId id;
private final String name;
public Contact(ContactId id, String name) {
this.id = id;
this.name = name;
}
public ContactId getId() {
return id;
}
public String getName() {
return name;
}
@Override
public int hashCode() {
return id.hashCode();
}
@Override
public boolean equals(Object o) {
if(o instanceof Contact) return id.equals(((Contact) o).id);
return false;
}
}

View File

@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import net.sf.briar.api.Contact;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.Rating;
import net.sf.briar.api.TransportConfig;
@@ -50,11 +51,12 @@ public interface DatabaseComponent {
void removeListener(DatabaseListener d);
/**
* Adds a new contact to the database and returns an ID for the contact.
* Adds a contact with the given name to the database and returns an ID for
* the contact.
*/
ContactId addContact() throws DbException;
ContactId addContact(String name) throws DbException;
/** Adds an endpoitn to the database. */
/** Adds an endpoint to the database. */
void addEndpoint(Endpoint ep) throws DbException;
/** Adds a locally generated group message to the database. */
@@ -155,8 +157,8 @@ public interface DatabaseComponent {
/** Returns the configuration for the given transport. */
TransportConfig getConfig(TransportId t) throws DbException;
/** Returns the IDs of all contacts. */
Collection<ContactId> getContacts() throws DbException;
/** Returns all contacts. */
Collection<Contact> getContacts() throws DbException;
/** Returns the local transport properties for the given transport. */
TransportProperties getLocalProperties(TransportId t) throws DbException;