Added methods to Entities to get a name from a profile

This commit is contained in:
moandji.ezana 2012-10-21 02:17:37 +02:00
parent 1864e69c6b
commit ac7eba9e06

View file

@ -1,5 +1,8 @@
package com.moandjiezana.tent.essayist.tent; package com.moandjiezana.tent.essayist.tent;
import com.google.common.base.Strings;
import com.moandjiezana.tent.client.users.Profile;
public class Entities { public class Entities {
public static String getForUrl(String entity) { public static String getForUrl(String entity) {
@ -26,4 +29,12 @@ public class Entities {
return expandedEntity; return expandedEntity;
} }
public static String getName(Profile profile) {
return getName(profile, profile.getCore().getEntity());
}
public static String getName(Profile profile, String fallback) {
return profile.getBasic() != null && !Strings.isNullOrEmpty(profile.getBasic().getName()) ? profile.getBasic().getName() : fallback;
}
} }