public void updateIdIfAbsent(String value) { if (StringUtils.isNotEmpty(value) && StringUtils.isEmpty(id)) { this.id = value; } }
private String getMockExceptionMessage(Throwable t, Throwable mt) { String msg = "mock error : " + mt.getMessage(); if (t != null) { msg = msg + ", invoke error is :" + StringUtils.toString(t); } return msg; }
public static int parseInteger(String str) { return isInteger(str) ? Integer.parseInt(str) : 0; }
/** * parse query string to Parameters. * * @param qs query string. * @return Parameters instance. */ public static Map<String, String> parseQueryString(String qs) { if (isEmpty(qs)) { return new HashMap<String, String>(); } return parseKeyValuePair(qs, "\\&"); }
private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List<URL> registryURLs) { String name = protocolConfig.getName(); if (StringUtils.isEmpty(name)) { name = Constants.DUBBO; map.put(Constants.METHODS_KEY, Constants.ANY_VALUE); } else { map.put(Constants.METHODS_KEY, StringUtils.join(new HashSet<String>(Arrays.asList(methods)), ",")); if (StringUtils.isEmpty(contextPath) && provider != null) { contextPath = provider.getContextpath(); URL url = new URL(name, host, port, (StringUtils.isEmpty(contextPath) ? "" : contextPath + "/") + path, map); if (StringUtils.isNotEmpty(proxy)) { registryURL = registryURL.addParameter(Constants.PROXY_KEY, proxy);
public AbstractPrefixConfiguration(String prefix, String id) { super(); if (StringUtils.isNotEmpty(prefix) && !prefix.endsWith(".")) { this.prefix = prefix + "."; } else { this.prefix = prefix; } this.id = id; }
String times; if (StringUtils.isEmpty(service)) { service = parts.length > 0 ? parts[0] : null; method = parts.length > 1 ? parts[1] : null; times = parts.length > 1 ? parts[1] : "1"; if (StringUtils.isInteger(method)) { times = method; method = null; if (!StringUtils.isInteger(times)) { return "Illegal times " + times + ", must be integer.";
public void init(String rule) { try { if (rule == null || rule.trim().length() == 0) { throw new IllegalArgumentException("Illegal route rule!"); } rule = rule.replace("consumer.", "").replace("provider.", ""); int i = rule.indexOf("=>"); String whenRule = i < 0 ? null : rule.substring(0, i).trim(); String thenRule = i < 0 ? rule.trim() : rule.substring(i + 2).trim(); Map<String, MatchPair> when = StringUtils.isBlank(whenRule) || "true".equals(whenRule) ? new HashMap<String, MatchPair>() : parseRule(whenRule); Map<String, MatchPair> then = StringUtils.isBlank(thenRule) || "false".equals(thenRule) ? null : parseRule(thenRule); // NOTE: It should be determined on the business level whether the `When condition` can be empty or not. this.whenCondition = when; this.thenCondition = then; } catch (ParseException e) { throw new IllegalStateException(e.getMessage(), e); } }
if (StringUtils.isNotEmpty(message)) { String[] parameters = message.split("\\s+"); if (parameters.length == 2 && parameters[0].equals("-t") && StringUtils.isInteger(parameters[1])) { sleepMilliseconds = Integer.parseInt(parameters[1]); } else {
if ("filter".equals(property) || "listener".equals(property)) { parameterType = String.class; value = StringUtils.join((String[]) value, ","); } else if ("parameters".equals(property)) { parameterType = Map.class;
@Override protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { if (StringUtils.isBlank(msg)) { ctx.writeAndFlush(QosProcessHandler.prompt); } else { CommandContext commandContext = TelnetCommandDecoder.decode(msg); commandContext.setRemote(ctx.channel()); try { String result = commandExecutor.execute(commandContext); if (StringUtils.isEquals(QosConstants.CLOSE, result)) { ctx.writeAndFlush(getByeLabel()).addListener(ChannelFutureListener.CLOSE); } else { ctx.writeAndFlush(result + QosConstants.BR_STR + QosProcessHandler.prompt); } } catch (NoSuchCommandException ex) { ctx.writeAndFlush(msg + " :no such command"); ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.prompt); log.error("can not found command " + commandContext, ex); } catch (Exception ex) { ctx.writeAndFlush(msg + " :fail to execute commandContext by " + ex.getMessage()); ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.prompt); log.error("execute commandContext got exception " + commandContext, ex); } } }
private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List<URL> registryURLs) { String name = protocolConfig.getName(); if (StringUtils.isEmpty(name)) { name = Constants.DUBBO; map.put(Constants.METHODS_KEY, Constants.ANY_VALUE); } else { map.put(Constants.METHODS_KEY, StringUtils.join(new HashSet<String>(Arrays.asList(methods)), ",")); if (StringUtils.isEmpty(contextPath) && provider != null) { contextPath = provider.getContextpath(); URL url = new URL(name, host, port, (StringUtils.isEmpty(contextPath) ? "" : contextPath + "/") + path, map); if (StringUtils.isNotEmpty(proxy)) { registryURL = registryURL.addParameter(Constants.PROXY_KEY, proxy);
/** * is integer string. * * @param str * @return is integer */ public static boolean isInteger(String str) { return isNotEmpty(str) && INT_PATTERN.matcher(str).matches(); }
String times; if (StringUtils.isEmpty(service)) { service = parts.length > 0 ? parts[0] : null; method = parts.length > 1 ? parts[1] : null; times = parts.length > 1 ? parts[1] : "1"; if (StringUtils.isInteger(method)) { times = method; method = null; if (!StringUtils.isInteger(times)) { return "Illegal times " + times + ", must be integer.";
public void init(String rule) { try { if (rule == null || rule.trim().length() == 0) { throw new IllegalArgumentException("Illegal route rule!"); } rule = rule.replace("consumer.", "").replace("provider.", ""); int i = rule.indexOf("=>"); String whenRule = i < 0 ? null : rule.substring(0, i).trim(); String thenRule = i < 0 ? rule.trim() : rule.substring(i + 2).trim(); Map<String, MatchPair> when = StringUtils.isBlank(whenRule) || "true".equals(whenRule) ? new HashMap<String, MatchPair>() : parseRule(whenRule); Map<String, MatchPair> then = StringUtils.isBlank(thenRule) || "false".equals(thenRule) ? null : parseRule(thenRule); // NOTE: It should be determined on the business level whether the `When condition` can be empty or not. this.whenCondition = when; this.thenCondition = then; } catch (ParseException e) { throw new IllegalStateException(e.getMessage(), e); } }
if (StringUtils.isNotEmpty(message)) { String[] parameters = message.split("\\s+"); if (parameters.length == 2 && parameters[0].equals("-t") && StringUtils.isInteger(parameters[1])) { sleepMilliseconds = Integer.parseInt(parameters[1]); } else {