List of usage examples for org.apache.commons.lang3 StringUtils isBlank
public static boolean isBlank(final CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
From source file:cn.wanghaomiao.seimi.utils.StructValidator.java
public static boolean validateAnno(Object object) { for (Field field : object.getClass().getDeclaredFields()) { NotNull notNullCheck = field.getAnnotation(NotNull.class); if (notNullCheck != null) { try { Object val = FieldUtils.readField(field, object, true); if (StringUtils.isBlank(String.valueOf(val))) { logger.error("Field={}.{} can not be null!", object.getClass().getSimpleName(), field.getName()); return false; }/*ww w .j av a 2 s .c om*/ } catch (IllegalAccessException e) { logger.error(e.getMessage(), e); } } } return true; }
From source file:ch.aonyx.broker.ib.api.order.Rule80A.java
public static final Rule80A fromInitial(final String initial) { if (StringUtils.isBlank(initial)) { return EMPTY; }/*ww w. j a v a2s . c om*/ final String initialUpperCase = initial.toUpperCase(); if (MAP.containsKey(initialUpperCase)) { return MAP.get(initialUpperCase); } return UNKNOWN; }
From source file:com.trenako.values.Visibility.java
/** * Parses the string argument as a {@code Visibility}. * * @param vis the string to be parsed * @param defaultVis the default {@code Visibility} value * @return a {@code Visibility} value//w ww. j av a 2 s .c o m */ public static Visibility parse(String vis, Visibility defaultVis) { if (StringUtils.isBlank(vis)) { return defaultVis; } return LocalizedEnum.parseString(vis, Visibility.class); }
From source file:ch.aonyx.broker.ib.api.order.OrderStatus.java
public static final OrderStatus fromLabel(final String label) { if (StringUtils.isBlank(label)) { return EMPTY; }//from w w w .j a va 2 s .co m final String labelUpperCase = label.toUpperCase(); if (MAP.containsKey(labelUpperCase)) { return MAP.get(labelUpperCase); } return UNKNOWN; }
From source file:gov.nih.nci.caintegrator.application.analysis.FloatParameterValue.java
/** * {@inheritDoc}/*from ww w . ja v a2s . co m*/ */ @Override public void setValueFromString(String stringValue) { if (StringUtils.isBlank(stringValue)) { setValue(null); } else { setValue(Float.parseFloat(stringValue)); } }
From source file:controllers.api.v2.Dataset.java
public static Promise<Result> listSegments(@Nullable String platform, @Nonnull String prefix) { try {/*from w w w.j a va 2 s . com*/ if (StringUtils.isBlank(platform)) { return Promise.promise(() -> ok(Json.toJson(DATA_TYPES_DAO.getAllPlatforms().stream() .map(s -> s.get("name")).collect(Collectors.toList())))); } List<String> names = DATASET_VIEW_DAO.listSegments(platform, "PROD", getPlatformPrefix(platform, prefix)); // if prefix is a dataset name, then return empty list if (names.size() == 1 && names.get(0).equalsIgnoreCase(prefix)) { return Promise.promise(() -> ok(Json.toJson(Collections.emptyList()))); } return Promise.promise(() -> ok(Json.toJson(names))); } catch (Exception e) { Logger.error("Fail to list dataset names/sections", e); return Promise.promise(() -> internalServerError("Fetch data Error: " + e.toString())); } }
From source file:ch.citux.td.util.Log.java
public static void v(Object caller, String message) { String tag = caller.getClass().getSimpleName(); if (!StringUtils.isBlank(message)) { android.util.Log.v(tag, message); }/*from ww w . java2 s. co m*/ }
From source file:com.cognifide.aet.executor.xmlparser.xml.models.ModelConverterUtils.java
static List<ExtendedUrl> extendUrlsList(List<Url> urls) throws ParseException, UnsupportedEncodingException { List<ExtendedUrl> extendedUrls = Lists.newArrayList(); List<ExtendedUrl> duplicatedUrls = Lists.newArrayList(); Set<String> names = Sets.newHashSet(); for (Url url : urls) { String urlName;/*from w ww .ja v a 2s. c o m*/ if (StringUtils.isBlank(url.getName())) { urlName = url.getHref().trim(); } else { urlName = URLEncoder.encode(url.getName().trim(), StandardCharsets.UTF_8.displayName()); } ExtendedUrl extendedUrl = new ExtendedUrl(url.getHref(), urlName, url.getDescription()); if (!names.add(urlName)) { duplicatedUrls.add(extendedUrl); } else { extendedUrls.add(extendedUrl); } } if (!duplicatedUrls.isEmpty()) { StringBuilder builder = new StringBuilder("Duplicated urls:"); for (ExtendedUrl url : duplicatedUrls) { builder.append(String.format("%n%s with name %s", url.getUrl(), url.getName())); } throw new ParseException(builder.toString()); } return extendedUrls; }
From source file:com.edmunds.etm.tools.urltoken.util.OptionUtils.java
public static String firstNonOptionArgument(OptionSet options) { List<String> arguments = options.nonOptionArguments(); if (arguments.isEmpty()) { return null; }//from w w w. j a v a2 s. c o m String tokenName = arguments.get(0); if (StringUtils.isBlank(tokenName)) { return null; } return tokenName; }
From source file:ch.aonyx.broker.ib.api.data.historical.HistoricalDataType.java
public static final HistoricalDataType fromLabel(final String label) { if (StringUtils.isBlank(label)) { return EMPTY; }//from w w w . ja va 2s.c om final String labelUpperCase = label.toUpperCase(); if (MAP.containsKey(labelUpperCase)) { return MAP.get(labelUpperCase); } return UNKNOWN; }