2019-09-11 01:40:32 +02:00
|
|
|
package org.mercury_im.messenger.core.util;
|
|
|
|
|
2019-11-03 06:33:52 +01:00
|
|
|
import org.mercury_im.messenger.xmpp.model.ContactModel;
|
|
|
|
import org.mercury_im.messenger.xmpp.model.EntityModel;
|
2019-09-11 01:40:32 +02:00
|
|
|
|
|
|
|
public class ContactNameUtil {
|
|
|
|
|
|
|
|
public static String displayableNameFrom(ContactModel contactModel) {
|
2019-10-28 14:56:56 +01:00
|
|
|
if (contactModel == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contactModel.getRostername() != null) {
|
|
|
|
return contactModel.getRostername();
|
2019-09-11 01:40:32 +02:00
|
|
|
}
|
|
|
|
if (contactModel.getEntity() != null) {
|
|
|
|
return contactModel.getEntity().getJid().getLocalpart().asUnescapedString();
|
|
|
|
}
|
2019-10-28 14:56:56 +01:00
|
|
|
|
2019-09-11 01:40:32 +02:00
|
|
|
return null;
|
|
|
|
}
|
2019-10-28 14:56:56 +01:00
|
|
|
|
|
|
|
public static String displayableNameFrom(ContactModel contact, EntityModel entity) {
|
|
|
|
if (contact == null) {
|
|
|
|
return entity.getJid().getLocalpart().asUnescapedString();
|
|
|
|
} return displayableNameFrom(contact);
|
|
|
|
}
|
2019-09-11 01:40:32 +02:00
|
|
|
}
|