X-Git-Url: http://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FLangUtils.java;fp=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FLangUtils.java;h=67748ccd7121ce2cbae24c428f12b6840f55fde7;hp=e4cc607d666c2777c94680222c5abcb4f1476421;hb=654cb2ca43dd4513a4d6a5bbe81762eaf6675496;hpb=a00a744d8ada0bbbeadc2b99fa56033856506e68 diff --git a/org.argeo.cms/src/org/argeo/cms/util/LangUtils.java b/org.argeo.cms/src/org/argeo/cms/util/LangUtils.java index e4cc607d6..67748ccd7 100644 --- a/org.argeo.cms/src/org/argeo/cms/util/LangUtils.java +++ b/org.argeo.cms/src/org/argeo/cms/util/LangUtils.java @@ -13,7 +13,6 @@ import java.time.temporal.Temporal; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; @@ -31,37 +30,16 @@ import javax.naming.ldap.LdapName; /** Utilities around Java basic features. */ public class LangUtils { /* - * NON-API OSGi + * OBJECTS and STRINGS */ /** - * Returns an array with the names of the provided classes. Useful when - * registering services with multiple interfaces in OSGi. + * Whether this {@link String} is null, empty, or only white + * spaces. */ - public static String[] names(Class... clzz) { - String[] res = new String[clzz.length]; - for (int i = 0; i < clzz.length; i++) - res[i] = clzz[i].getName(); - return res; + public static boolean isEmpty(String str) { + return str == null || "".equals(str.strip()); } -// /* -// * MAP -// */ -// /** -// * Creates a new {@link Map} with one key-value pair. Key should not be null, -// * but if the value is null, it returns an empty {@link Map}. -// * -// * @deprecated Use {@link Collections#singletonMap(Object, Object)} instead. -// */ -// @Deprecated -// public static Map map(String key, Object value) { -// assert key != null; -// HashMap props = new HashMap<>(); -// if (value != null) -// props.put(key, value); -// return props; -// } - /* * DICTIONARY */ @@ -345,6 +323,20 @@ public class LangUtils { return count > 1 ? count + " seconds" : count + " second"; } + /* + * NON-API OSGi + */ + /** + * Returns an array with the names of the provided classes. Useful when + * registering services with multiple interfaces in OSGi. + */ + public static String[] names(Class... clzz) { + String[] res = new String[clzz.length]; + for (int i = 0; i < clzz.length; i++) + res[i] = clzz[i].getName(); + return res; + } + /** Singleton constructor. */ private LangUtils() {