Java Code Examples for com.alipay.sofa.rpc.common.utils.StringUtils#EMPTY
The following examples show how to use
com.alipay.sofa.rpc.common.utils.StringUtils#EMPTY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SofaRegistryRestClient.java From sofa-dashboard with Apache License 2.0 | 5 votes |
/** * Extract value from map ,if null return empty String * * @param map * @param key * @return */ private String getEmptyStringIfNull(Map map, String key) { if (map == null || map.size() <= 0) { return StringUtils.EMPTY; } Object valueObject = map.get(key); String valueStr; try { valueStr = (String) valueObject; } catch (Throwable throwable) { return StringUtils.EMPTY; } return StringUtils.isBlank(valueStr) ? StringUtils.EMPTY : valueStr; }
Example 2
Source File: RpcSofaTracer.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected String getEmptyStringIfNull(Map map, String key) { if (map == null || map.size() <= 0) { return StringUtils.EMPTY; } Object valueObject = map.get(key); String valueStr = null; try { valueStr = (String) valueObject; } catch (Throwable throwable) { return StringUtils.EMPTY; } return StringUtils.isBlank(valueStr) ? StringUtils.EMPTY : valueStr; }
Example 3
Source File: SimpleMapSerializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * 读取一个字符串 * * @param in 输入流程 * @return 字符串 * @throws IOException 读取异常 */ protected String readString(InputStream in) throws IOException { int length = readInt(in); if (length < 0) { return null; } else if (length == 0) { return StringUtils.EMPTY; } else { byte[] value = new byte[length]; in.read(value); return StringSerializer.decode(value); } }
Example 4
Source File: SofaRegistryHelper.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * convert map to url pair * * @param map * @return url paramters */ private static String convertMap2Pair(Map<String, String> map) { if (CommonUtils.isEmpty(map)) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(128); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(getKeyPairs(entry.getKey(), entry.getValue())); } return sb.toString(); }
Example 5
Source File: SofaRegistryHelper.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Gets key pairs. * * @param key the key * @param value the value * @return the key pairs */ private static String getKeyPairs(String key, Object value) { if (value != null) { return "&" + key + "=" + value.toString(); } else { return StringUtils.EMPTY; } }
Example 6
Source File: SofaRegistryHelper.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * convert map to url pair * * @param map * @return url paramters */ private static String convertMap2Pair(Map<String, String> map) { if (CommonUtils.isEmpty(map)) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(128); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(getKeyPairs(entry.getKey(), entry.getValue())); } return sb.toString(); }
Example 7
Source File: SofaRegistryHelper.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Gets key pairs. * * @param key the key * @param value the value * @return the key pairs */ private static String getKeyPairs(String key, Object value) { if (value != null) { return "&" + key + "=" + value.toString(); } else { return StringUtils.EMPTY; } }
Example 8
Source File: ConsistentHashLoadBalancer.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * 获取第一参数作为hash的key * * @param args the args * @return the string */ private String buildKeyOfHash(Object[] args) { if (CommonUtils.isEmpty(args)) { return StringUtils.EMPTY; } else { return StringUtils.toString(args[0]); } }
Example 9
Source File: WeightConsistentHashLoadBalancer.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * 获取第一参数作为hash的key * * @param args the args * @return the string */ private String buildKeyOfHash(Object[] args) { if (CommonUtils.isEmpty(args)) { return StringUtils.EMPTY; } else { return StringUtils.toString(args[0]); } }
Example 10
Source File: MockTestRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Gets key pairs. * * @param key the key * @param value the value * @return the key pairs */ private static String getKeyPairs(CharSequence key, Object value) { if (value != null) { return "&" + key + "=" + value.toString(); } else { return StringUtils.EMPTY; } }
Example 11
Source File: RegistryUtils.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * 转换 map to url pair * * @param map 属性 */ private static String convertMap2Pair(Map<String, String> map) { if (CommonUtils.isEmpty(map)) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(128); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(getKeyPairs(entry.getKey(), entry.getValue())); } return sb.toString(); }
Example 12
Source File: AbstractHttpServer.java From sofa-rpc with Apache License 2.0 | 4 votes |
private String getUniqueName(ProviderConfig providerConfig) { String uniqueId = providerConfig.getUniqueId(); return providerConfig.getInterfaceId() + (StringUtils.isEmpty(uniqueId) ? StringUtils.EMPTY : ":" + uniqueId); }
Example 13
Source File: SLF4JLoggerImpl.java From sofa-rpc with Apache License 2.0 | 4 votes |
private String prefix(String appName) { return appName == null ? StringUtils.EMPTY : "[" + appName + "]"; }