List of usage examples for org.apache.commons.lang3 StringUtils isNotBlank
public static boolean isNotBlank(final CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true
From source file:net.packet.serializer.ProjectSerializer.java
@Override public JsonElement serialize(Project src, Type typeOfSrc, JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); if (StringUtils.isNotBlank(src.getName())) { jsonObject.addProperty("name", src.getName()); }/*from ww w . j a va 2s . c o m*/ if (StringUtils.isNotBlank(src.getPaymentMethodId())) { jsonObject.addProperty("payment_method", src.getPaymentMethodId()); } return jsonObject; }
From source file:com.u2apple.rt.filter.ExcludeFilter.java
@Override public List<AndroidDeviceRanking> filter(List<AndroidDeviceRanking> androidDevices) { List<AndroidDeviceRanking> newDevices = new ArrayList<>(); if (androidDevices != null && !androidDevices.isEmpty()) { for (AndroidDeviceRanking device : androidDevices) { if (!StringUtils.equalsIgnoreCase(device.getRoProductBrand(), device.getRoProductModel()) && StringUtils.isNotBlank(device.getRoProductModel())) { newDevices.add(device);/*from w ww. j a v a 2s .c om*/ } } } return newDevices; }
From source file:com.base2.kagura.rest.helpers.ParameterUtils.java
public static void insertParameters(Parameters parameters, ReportConnector reportConnector, List<String> errors) { if (reportConnector.getParameterConfig() != null) { for (ParamConfig paramConfig : reportConnector.getParameterConfig()) { if (parameters.getParameters().containsKey(paramConfig.getId())) { Object o = parameters.getParameters().get(paramConfig.getId()); try { if (o != null && StringUtils.isNotBlank(o.toString())) BeanUtils.setProperty(paramConfig, "value", o); else BeanUtils.setProperty(paramConfig, "value", null); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (ConversionException e) { e.printStackTrace(); errors.add("Could not convert parameter: " + paramConfig.getId() + " value " + o); }//from w w w .j a va 2 s.c om } } } }
From source file:com.haulmont.cuba.web.gui.FileUploadTypesHelper.java
public static String convertSeparator(String types, String originSeparator, String separator) { return StringUtils.isNotBlank(types) ? types.replace(originSeparator, separator) : null; }
From source file:com.hybris.mobile.app.commerce.utils.HockeyAppUtils.java
/** * HockeyApp feedbacks/*from w w w . j av a 2 s.c o m*/ * * @param context */ public static void showFeedbackActivity(Context context) { if (StringUtils.isNotBlank(CommerceApplication.getConfiguration().getHockeyAppIdentifier())) { FeedbackManager.register(context, CommerceApplication.getConfiguration().getHockeyAppIdentifier()); FeedbackManager.showFeedbackActivity(context); } }
From source file:com.dtstack.jlogstash.assembly.CmdLineParams.java
public static double getInputQueueCoefficient() { String number = line.getOptionValue("c"); double coefficient = StringUtils.isNotBlank(number) ? Double.parseDouble(number) : SystemProperty.getInputProportion(); logger.warn("input queue coefficient:{}", String.valueOf(coefficient)); return coefficient; }
From source file:com.quatico.base.aem.test.api.values.TestFile.java
public static String path(String... segments) { StringBuilder buf = new StringBuilder(); for (int count = 0, idx = 0; idx < segments.length; idx++) { String cur = segments[idx]; if (StringUtils.isBlank(cur) && count == 0 || StringUtils.isNotBlank(cur) && buf.length() > 1) { buf.append(File.separator); }//from w ww. ja va 2 s .c o m if (StringUtils.isNotBlank(cur)) { buf.append(cur); } count++; } String result = buf.toString(); if (result.matches("^\\\\[\\w]{1}:")) { // java.io.File cannot handle leading slashes before drive letters on Windows result = result.substring(1); } return result.replace(ILLEGAL_FILE_SEPARATOR, File.separatorChar); }
From source file:com.ppcxy.cyfm.showcase.demos.utilities.string.ApacheStringUtilsDemo.java
@Test public void nullSafe() { // ?/*from w w w .j ava2s . c o m*/ assertThat(StringUtils.isNotBlank(null)).isFalse(); assertThat(StringUtils.isNotBlank("")).isFalse(); assertThat(StringUtils.isNotBlank(" ")).isFalse(); assertThat(StringUtils.isNotEmpty(" ")).isTrue(); // nullblankdefault assertThat(StringUtils.defaultString(null)).isEqualTo(""); assertThat(StringUtils.defaultString(null, "defaultStr")).isEqualTo("defaultStr"); assertThat(StringUtils.defaultIfBlank(null, "defaultStr")).isEqualTo("defaultStr"); assertThat(StringUtils.defaultIfBlank(" ", "defaultStr")).isEqualTo("defaultStr"); }
From source file:io.github.moosbusch.lumpi.gui.form.editor.validator.impl.BooleanValidator.java
@Override public boolean isValid(String text) { if (StringUtils.isNotBlank(text)) { return ((text.toLowerCase().equals("true")) || (text.toLowerCase().equals("false"))); }//from w ww . ja v a 2s .c o m return false; }
From source file:mobile.service.MessageService.java
/** * ?/*from www. j av a2 s. com*/ * * @return */ public static ServiceResult markRead(List<String> msgIds, Long userId) { List<Long> systemMsgIdList = new ArrayList<>(); List<String> chatMsgIdList = new ArrayList<>(); for (String msgId : msgIds) { if (StringUtils.isNotBlank(msgId) && msgId.startsWith("chat_") && msgId.length() > "chat_".length()) { chatMsgIdList.add(msgId); } else { long numId = NumberUtils.toLong(msgId, -1); if (numId > 0) { systemMsgIdList.add(numId); } } } Message.markReaded(String.valueOf(userId), systemMsgIdList); for (String chatMsgId : chatMsgIdList) { if (chatMsgId.startsWith("chat_G")) { Long groupId = HelomeUtil.toLong(chatMsgId.substring("chat_G".length()), null); MCMessageUtil.cleanGroupChatNum(groupId, userId); } else { Long senderId = HelomeUtil.toLong(chatMsgId.split("_")[1], null); if (null != senderId) { MCMessageUtil.resetCommunicateNum(senderId, userId); } } } return ServiceResult.success(); }