List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:com.mobogenie.framework.spring.LogGenerator.java
public static Map<String, String> next(HttpServletRequest request) { Map<String, String> map = Maps.newLinkedHashMap(); map.put("uri", request.getRequestURI()); map.put("timestamp", System.currentTimeMillis() + ""); StringBuilder sb = new StringBuilder(); Map<String, String> paramMap = request.getParameterMap(); Set<String> keys = paramMap.keySet(); for (String paramName : keys) { String paramValue = request.getParameter(paramName).trim(); if (!Strings.isNullOrEmpty(paramValue)) { sb.append(paramName + ":" + paramValue + ","); }/*w w w . ja v a 2s. c o m*/ } String valueString = sb.toString(); valueString = valueString.replaceAll(",$", ""); map.put("params", "[" + valueString + "]"); map.put("clientId", IpAddressUtil.getIpAddr(request)); HttpSession session = request.getSession(false); if (session != null) { map.put("session", session.getId()); } return map; }
From source file:com.quartz.web.util.RequestUtil.java
/** * ?/*www . j a v a 2s. c o m*/ * * @param request * @param paramName * @return */ public static <T> T validateParam(HttpServletRequest request, String paramName, ResponseMessage responseMessage) { String param = request.getParameter(paramName); if (!Strings.isNullOrEmpty(param)) { return (T) param; } responseMessage.setStatus(300); responseMessage.setMessage("param [" + paramName + "] is empty"); throw new ParameterException("param [" + paramName + "] is empty"); }
From source file:com.google.gcloud.datastore.Validator.java
static String validateDatabase(String projectId) { checkArgument(!Strings.isNullOrEmpty(projectId), "projectId can't be empty or null"); checkArgument(PROJECT_ID_PATTERN.matcher(projectId).matches(), "projectId must match the following pattern: " + PROJECT_ID_PATTERN.pattern()); return projectId; }
From source file:org.onehippo.intellij.groovy.config.metadata.Location.java
public static Location locationForName(final String name) { if (Strings.isNullOrEmpty(name)) { return REGISTRY; }// w w w.j a v a 2s . c o m if (name.equalsIgnoreCase(HISTORY.getName())) { return HISTORY; } else if (name.equalsIgnoreCase(QUEUE.getName())) { return QUEUE; } return REGISTRY; }
From source file:com.dssmp.watch.util.TemplateUtil.java
/** * ??/*from w w w . j a v a2 s . c om*/ * * @param content * @return */ public static String replaceTemplate(String content, MetricRecord metricRecord, Alarm alarm) { if (!Strings.isNullOrEmpty(content)) { //?? content = content.replace(METRICNAME, metricRecord.getMetricname()); content = content.replace(VALUE, String.valueOf(metricRecord.getMvalue())); content = content.replace(ALARMNAME, alarm.getName()); return content; } return null; }
From source file:com.magnet.yak.functional.GlobalConfig.java
public static synchronized Configuration getConfiguration(String name) { if (configuration == null) { String config = System.getProperty(YAK_CONFIG); if (Strings.isNullOrEmpty(config)) { LOGGER.error("getConfiguration : Launching Yak : config file : {}", config); System.exit(0);/*from w ww. j av a2 s .co m*/ } LOGGER.info("getConfiguration : Launching Yak : config file : {}", System.getProperty(YAK_CONFIG)); configuration = ConfigParser.getByName(config, name); LOGGER.trace("getConfiguration : config={}", configuration); } return configuration; }
From source file:com.hubrick.raml.mojo.util.JavaNames.java
public static String toJavaName(String string) { checkArgument(!Strings.isNullOrEmpty(string), "Input string cannot be null or empty"); final String[] elements = string.split("(?i:[^a-z0-9]+)"); return stream(spliterator(elements), false).map(indexed()) .map(element -> element.index() > 0 ? StringUtils.capitalize(element.value()) : element.value()) .collect(Collectors.joining()); }
From source file:tv.icntv.log.stb.commons.StringsUtils.java
public static String getEncodeingStr(String str) { if (!Strings.isNullOrEmpty(str)) { str = str.replace("%", "%25"); str = str.replace("|", "%7C"); }/*from ww w .j ava 2 s . com*/ return str; }
From source file:com.olacabs.fabric.common.util.PropertyReader.java
public static Boolean readBoolean(Properties properties, Properties globalProperties, final String propertyName, Boolean defaultValue) {//from w w w .ja va 2 s . c om String repr = null; if (null != properties) { repr = properties.getProperty(propertyName); } if (Strings.isNullOrEmpty(repr)) { if (null != globalProperties) { repr = globalProperties.getProperty(propertyName); } if (Strings.isNullOrEmpty(repr)) { return defaultValue; } } return Boolean.parseBoolean(repr); }
From source file:org.apache.kylin.metrics.lib.impl.TimePropertyEnum.java
public static TimePropertyEnum getByPropertyName(String propertyName) { if (Strings.isNullOrEmpty(propertyName)) { return null; }//from w ww .j a va2s . c o m for (TimePropertyEnum property : TimePropertyEnum.values()) { if (property.propertyName.equals(propertyName.toUpperCase())) { return property; } } return null; }