From ac7eba9e06e5bee50cc67a6a2c7c49eb63f24cd0 Mon Sep 17 00:00:00 2001 From: "moandji.ezana" Date: Sun, 21 Oct 2012 02:17:37 +0200 Subject: [PATCH] Added methods to Entities to get a name from a profile --- .../com/moandjiezana/tent/essayist/tent/Entities.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/moandjiezana/tent/essayist/tent/Entities.java b/src/main/java/com/moandjiezana/tent/essayist/tent/Entities.java index fb63ab0..bd95fe0 100644 --- a/src/main/java/com/moandjiezana/tent/essayist/tent/Entities.java +++ b/src/main/java/com/moandjiezana/tent/essayist/tent/Entities.java @@ -1,5 +1,8 @@ package com.moandjiezana.tent.essayist.tent; +import com.google.common.base.Strings; +import com.moandjiezana.tent.client.users.Profile; + public class Entities { public static String getForUrl(String entity) { @@ -26,4 +29,12 @@ public class Entities { 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; + } }