/** * Determines if string array contains empty strings. * @see #isEmpty(CharSequence) */ public static boolean isAllEmpty(String... strings) { for (String string : strings) { if (!isEmpty(string)) { return false; } } return true; }
/** * Determines if string array contains empty strings. * @see #isEmpty(CharSequence) */ public static boolean isAllEmpty(final String... strings) { for (String string : strings) { if (!isEmpty(string)) { return false; } } return true; }
/** * Transforms locale data to locale code. <code>null</code> values are allowed. */ public static String resolveLocaleCode(String lang, String country, String variant) { StringBuilder code = new StringBuilder(lang); if (!StringUtil.isEmpty(country)) { code.append('_').append(country); if (!StringUtil.isEmpty(variant)) { code.append('_').append(variant); } } return code.toString(); }
/** * Reads string element from the annotation. Empty strings are detected * and default value is returned instead. */ protected String readString(A annotation, String name, String defaultValue) { String value = readStringElement(annotation, name); if (StringUtil.isEmpty(value)) { value = defaultValue; } return value; }
/** * Tries to login user with form data. Returns session object, otherwise returns <code>null</code>. */ protected T loginViaRequestParams(final HttpServletRequest servletRequest) { final String username = servletRequest.getParameter(PARAM_USERNAME).trim(); if (StringUtil.isEmpty(username)) { return null; } final String password = servletRequest.getParameter(PARAM_PASSWORD).trim(); return userAuth.login(username, password); }
/** * Reads string element from the annotation. Empty strings are detected * and default value is returned instead. */ public String readString(final String name, final String defaultValue) { String value = readStringElement(name); if (StringUtil.isEmpty(value)) { value = defaultValue; } return value; }
boolean noRelativePath = StringUtil.isEmpty(path);
@Override public void inject(final ActionRequest actionRequest, final Targets targets) { final String body = actionRequest.readRequestBody(); if (StringUtil.isEmpty(body)) { return; } targets.forEachTargetAndIn(this, (target, in) -> target.writeValue(in, body, true)); }
/** * Reads action path from class. If the class is annotated with {@link MadvocAction} annotation, * class action path will be read from annotation value. Otherwise, action class path will be built from the * class name. This is done by removing the package name and the last contained word * (if there is more then one) from the class name. Such name is finally uncapitalized. */ protected String[] readClassActionPath(final Class actionClass) { // read class annotation MadvocAction madvocActionAnnotation = ((Class<?>)actionClass).getAnnotation(MadvocAction.class); String classActionPath = madvocActionAnnotation != null ? madvocActionAnnotation.value().trim() : null; if (StringUtil.isEmpty(classActionPath)) { classActionPath = null; } String actionClassName = actionClass.getSimpleName(); actionClassName = StringUtil.uncapitalize(actionClassName); actionClassName = MadvocUtil.stripLastCamelWord(actionClassName); // removes 'Action' from the class name if (classActionPath == null) { classActionPath = actionClassName; } return ArraysUtil.array(actionClassName, classActionPath); }
boolean noRelativePath = StringUtil.isEmpty(path);
if (StringUtil.isEmpty(packageActionPathFromAnnotation)) { packageActionPathFromAnnotation = null;
if (StringUtil.isEmpty(key)) { return;
private void injectMacros(final String actionPath, final PathMacros pathMacros, final Targets targets) { final String[] names = pathMacros.names(); final String[] values = pathMacros.extract(actionPath); for (int ndx = 0; ndx < values.length; ndx++) { final String value = values[ndx]; if (StringUtil.isEmpty(value)) { continue; } final String macroName = names[ndx]; targets.forEachTargetAndIn(madvocScope, (target, in) -> { final String name = in.matchedName(macroName); if (name != null) { target.writeValue(name, value, true); } }); } }
@Override public void inject(final ActionRequest actionRequest, final Targets targets) { final HttpServletRequest servletRequest = actionRequest.getHttpServletRequest(); targets.forEachTargetAndIn(this, (target, in) -> { Object value = null; if (in.type() == Cookie.class) { // get single cookie final String cookieName = StringUtil.uncapitalize(in.name()); value = ServletUtil.getCookie(servletRequest, cookieName); } else if (in.type().isArray()) { if (in.type().getComponentType().equals(Cookie.class)) { if (StringUtil.isEmpty(in.name())) { // get all cookies value = servletRequest.getCookies(); } else { // get all cookies by name value = ServletUtil.getAllCookies(servletRequest, in.name()); } } } if (value != null) { target.writeValue(in, value, true); } }); }
String value = resultPath.value(); if (StringUtil.isEmpty(value)) { value = null;
@Override public void inject(final ActionRequest actionRequest, final Targets targets) { final String body = actionRequest.readRequestBody(); if (StringUtil.isEmpty(body)) { return; } targets.forEachTargetAndIn(this, (target, in) -> { if (in.type() == String.class) { target.writeValue(in, body, true); } else { final Object value = parseRequestBody(body, in.type()); target.writeValue(in, value, true); } }); }
if (StringUtil.isEmpty(columnName)) {
@Test void testEmpty() { assertFalse(StringUtil.isBlank("foo")); assertTrue(StringUtil.isNotBlank("foo")); assertTrue(StringUtil.isBlank("")); assertFalse(StringUtil.isNotBlank("")); assertTrue(StringUtil.isBlank(" ")); assertFalse(StringUtil.isNotBlank(" ")); assertTrue(StringUtil.isBlank(" \t \t")); assertFalse(StringUtil.isNotBlank(" \t \t")); assertTrue(StringUtil.isBlank(null)); assertFalse(StringUtil.isNotBlank(null)); assertFalse(StringUtil.isEmpty("foo")); assertTrue(StringUtil.isNotEmpty("foo")); assertTrue(StringUtil.isEmpty("")); assertFalse(StringUtil.isNotEmpty("")); assertFalse(StringUtil.isEmpty(" ")); assertTrue(StringUtil.isNotEmpty(" ")); assertFalse(StringUtil.isEmpty(" \t \t")); assertTrue(StringUtil.isNotEmpty(" \t \t")); assertTrue(StringUtil.isEmpty(null)); assertFalse(StringUtil.isNotEmpty(null)); assertTrue(StringUtil.isAllEmpty("", null)); assertFalse(StringUtil.isAllEmpty("", null, "a")); assertTrue(StringUtil.isAllBlank("", " ", "\t", "\r", null)); assertFalse(StringUtil.isAllBlank("", " ", "\t", "\ra", null)); }
/** * Reads string element from the annotation. Empty strings are detected * and default value is returned instead. */ public String readString(final String name, final String defaultValue) { String value = readStringElement(name); if (StringUtil.isEmpty(value)) { value = defaultValue; } return value; }